Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ low-code CDK: Allow connector developers to specify the type of an added field #31638

Merged
merged 20 commits into from
Oct 23, 2023

Conversation

girarda
Copy link
Contributor

@girarda girarda commented Oct 20, 2023

What

  • Allow connector developers to specify the type of an added field

Example usage:

      - type: AddFields
        fields:
          - path:
              - transaction_id
            value: "{{ record['transaction_info']['transaction_id'] }}"
            value_type: str

This feature is necessary to fix an regression introduced in source-paypal-transaction when it was migrated to low-code.
The values are implicitly casted to numbers, which is wrong because they should be treated as strings.

This should be followed up by

  1. A PR fixing the paypal connector
  2. An issue for exposing this field in the connector builder

How

  • Add value_type field to AddedFieldDefinition object
  • The field can be any value defined in the ValueType enum
  • The component factory converts the enum value to a type before propagating it to the AddFields component
  • A few unrelated mypy issues were fixed along the way

Recommended reading order

  1. airbyte-cdk/python/airbyte_cdk/sources/declarative/declarative_component_schema.yaml
  2. airbyte-cdk/python/airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py
  3. airbyte-cdk/python/airbyte_cdk/sources/declarative/transformations/add_fields.py
  4. airbyte-cdk/python/airbyte_cdk/sources/declarative/transformations/transformation.py
  5. airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/paginators/strategies/stop_condition.py
  6. airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/paginators/strategies/pagination_strategy.py

🚨 User Impact 🚨

None. This is an additive feature.

Pre-merge Actions

Expand the relevant checklist and delete the others.

New Connector

Community member or Airbyter

  • Community member? Grant edit access to maintainers (instructions)
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Connector version is set to 0.0.1
    • Dockerfile has version 0.0.1
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • docs/integrations/<source or destination>/<name>.md including changelog with an entry for the initial version. See changelog example
    • docs/integrations/README.md

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
Updating a connector

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Unit & integration tests added

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
Connector Generator
  • Issue acceptance criteria met
  • PR name follows PR naming conventions
  • If adding a new generator, add it to the list of scaffold modules being tested
  • The generator test modules (all connectors with -scaffold in their name) have been updated with the latest scaffold by running ./gradlew :airbyte-integrations:connector-templates:generator:generateScaffolds then checking in your changes
  • Documentation which references the generator is updated as needed
Updating the Python CDK

Airbyter

Before merging:

  • Pull Request description explains what problem it is solving
  • Code change is unit tested
  • Build and my-py check pass
  • Smoke test the change on at least one affected connector
    • On Github: Run this workflow, passing --use-local-cdk --name=source-<connector> as options
    • Locally: airbyte-ci connectors --use-local-cdk --name=source-<connector> test
  • PR is reviewed and approved

After merging:

  • Publish the CDK
    • The CDK does not follow proper semantic versioning. Choose minor if this the change has significant user impact or is a breaking change. Choose patch otherwise.
    • Write a thoughtful changelog message so we know what was updated.
  • Merge the platform PR that was auto-created for updating the Connector Builder's CDK version
    • This step is optional if the change does not affect the connector builder or declarative connectors.

@vercel
Copy link

vercel bot commented Oct 20, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
airbyte-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 23, 2023 8:17pm

@octavia-squidington-iii octavia-squidington-iii added area/connectors Connector related issues CDK Connector Development Kit connectors/source/paypal-transaction labels Oct 20, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 20, 2023

Before Merging a Connector Pull Request

Wow! What a great pull request you have here! 🎉

To merge this PR, ensure the following has been done/considered for each connector added or updated:

  • PR name follows PR naming conventions
  • Breaking changes are considered. If a Breaking Change is being introduced, ensure an Airbyte engineer has created a Breaking Change Plan.
  • Connector version has been incremented in the Dockerfile and metadata.yaml according to our Semantic Versioning for Connectors guidelines
  • You've updated the connector's metadata.yaml file any other relevant changes, including a breakingChanges entry for major version bumps. See metadata.yaml docs
  • Secrets in the connector's spec are annotated with airbyte_secret
  • All documentation files are up to date. (README.md, bootstrap.md, docs.md, etc...)
  • Changelog updated in docs/integrations/<source or destination>/<name>.md with an entry for the new version. See changelog example
  • Migration guide updated in docs/integrations/<source or destination>/<name>-migrations.md with an entry for the new version, if the version is a breaking change. See migration guide example
  • If set, you've ensured the icon is present in the platform-internal repo. (Docs)

If the checklist is complete, but the CI check is failing,

  1. Check for hidden checklists in your PR description

  2. Toggle the github label checklist-action-run on/off to re-run the checklist CI.

@girarda girarda changed the title Allow connector developers to specify the type of an added field low-code: Allow connector developers to specify the type of an added field Oct 20, 2023
@octavia-squidington-iii octavia-squidington-iii removed the area/connectors Connector related issues label Oct 20, 2023
@girarda girarda added area/connectors Connector related issues and removed connectors/source/paypal-transaction labels Oct 20, 2023
@octavia-squidington-iii octavia-squidington-iii removed the area/connectors Connector related issues label Oct 20, 2023
@girarda girarda marked this pull request as ready for review October 20, 2023 04:44
@girarda girarda requested a review from a team as a code owner October 20, 2023 04:44
@airbyte-oss-build-runner
Copy link
Collaborator

source-paypal-transaction test report (commit 323d826091) - ✅

⏲️ Total pipeline duration: 01mn37s

Step Result
Build source-paypal-transaction docker image for platform(s) linux/x86_64
Acceptance tests
Code format checks
Validate metadata for source-paypal-transaction
Connector version semver check
QA checks

🔗 View the logs here

☁️ View runs for commit in Dagger Cloud

Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command

airbyte-ci connectors --name=source-paypal-transaction test

Copy link
Contributor

@clnoll clnoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @girarda! Just one small question.

self._delegate.reset()

def get_page_size(self) -> Optional[int]:
return self._delegate.get_page_size()

@property
def initial_token(self) -> Optional[Any]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the method is an abstractmethod in the parent PaginationStrategy class so it must be implemented by StopConditionPaginationStrategyDecorator

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, this is just something that was overlooked previously?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's right. mypy should've caught it when the method was introduced by it had been accidentally removed from the build pipeline for a few weeks. It caught the issue this so we should be good moving forward

@girarda girarda changed the title low-code: Allow connector developers to specify the type of an added field ✨ low-code CDK: Allow connector developers to specify the type of an added field Oct 23, 2023
@erohmensing erohmensing requested a review from a team October 23, 2023 15:05
@airbyte-oss-build-runner
Copy link
Collaborator

source-paypal-transaction test report (commit 12b94d6725) - ❌

⏲️ Total pipeline duration: 6.49s

Step Result
Build source-paypal-transaction docker image for platform(s) linux/amd64
Code format checks
Validate metadata for source-paypal-transaction
Connector version semver check
QA checks

🔗 View the logs here

☁️ View runs for commit in Dagger Cloud

Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command

airbyte-ci connectors --name=source-paypal-transaction test

@octavia-squidington-iii octavia-squidington-iii removed the area/connectors Connector related issues label Oct 23, 2023
@girarda girarda merged commit 7a764f8 into master Oct 23, 2023
22 checks passed
@girarda girarda deleted the alex/typed_add_fields branch October 23, 2023 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants