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

add the ability to upgrade CDK for java connectors #34343

Conversation

stephane-airbyte
Copy link
Contributor

@stephane-airbyte stephane-airbyte commented Jan 18, 2024

We already had the ability to update the CDK version for python connectors. I'm just adding the same thing for java connectors.

It required some minor refactoring. I haven't added any tests yet, but I tested it locally

Copy link

vercel bot commented Jan 18, 2024

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 Jan 25, 2024 3:58pm

Copy link
Contributor Author

stephane-airbyte commented Jan 18, 2024

Copy link
Contributor

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.

@click.command(cls=DaggerPipelineCommand, short_help="Upgrade CDK version")
@click.argument("target-cdk-version", type=str, default=latest_cdk_version)
@click.argument("target-cdk-version", type=str, default="latest")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

now, "latest" has different meaning for python vs java CDK. Therefore, I'm just passing the "latest" string and will resolve it later

@@ -55,17 +60,77 @@ async def _run(self) -> StepResult:
exc_info=e,
)

def update_cdk_version(self, og_setup_py_content: str) -> str:
async def upgrade_cdk_version_for_java_connector(self, og_connector_dir) -> StepResult:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is new, and handling java only

raise ValueError("Could not find airbyte-cdk dependency in build.gradle")

if self.new_version == "latest":
version_file_content = await self.context.get_repo_file(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

java "latest" transaltion

raise ValueError("Could not find airbyte-cdk dependency in setup.py")

if self.new_version == "latest":
"""
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is lifted from the original latest_cdk_version that was in commands.py

@stephane-airbyte stephane-airbyte force-pushed the stephane/01-17-add_the_ability_to_upgrade_CDK_for_java_connectors branch from ec13a23 to 6ad2ade Compare January 18, 2024 00:54
@octavia-squidington-iii octavia-squidington-iii removed the area/connectors Connector related issues label Jan 18, 2024
@stephane-airbyte stephane-airbyte force-pushed the stephane/01-17-add_the_ability_to_upgrade_CDK_for_java_connectors branch 2 times, most recently from 2f86adf to 6eb4d64 Compare January 18, 2024 01:29
airbyte_cdk_dependency = re.search(
r"airbyte-cdk(?P<extra>\[[a-zA-Z0-9-]*\])?(?P<version>[<>=!~]+[0-9]*\.[0-9]*\.[0-9]*)?", og_setup_py_content
r"airbyte-cdk(?P<extra>\[[a-zA-Z0-9-]*\])?(?P<version>[<>=!~]+[0-9]*(?:\.[0-9]*)?(?:\.[0-9]*)?)?", setup_py_content
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 old regexp would not match airbyte-cdk~=0.11, or airbyte-cdk~=1

@stephane-airbyte stephane-airbyte force-pushed the stephane/01-17-add_the_ability_to_upgrade_CDK_for_java_connectors branch 4 times, most recently from 4ac0432 to 5873c2c Compare January 18, 2024 19:41
@stephane-airbyte stephane-airbyte marked this pull request as ready for review January 18, 2024 19:43
@stephane-airbyte stephane-airbyte requested a review from a team January 18, 2024 19:43
@stephane-airbyte stephane-airbyte force-pushed the stephane/01-17-add_the_ability_to_upgrade_CDK_for_java_connectors branch from 73aca55 to 7e4a67e Compare January 18, 2024 20:51
Copy link
Contributor

@alafanechere alafanechere left a comment

Choose a reason for hiding this comment

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

I really appreciate the effort to keep a language agnostic command, thanks!

I added minor suggestions, approving to not be blocking, but please consider them.

updated_setup_py = self.update_cdk_version(setup_py_content)
updated_connector_dir = og_connector_dir.with_new_file("setup.py", updated_setup_py)
og_connector_dir = await context.get_connector_dir()
if self.context.connector.language == ConnectorLanguage.PYTHON or self.context.connector.language == ConnectorLanguage.LOW_CODE:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion:
if self.context.connector.language in [ConnectorLanguage.PYTHON, ConnectorLanguage.LOW_CODE]

og_connector_dir = await context.get_connector_dir()
if self.context.connector.language == ConnectorLanguage.PYTHON or self.context.connector.language == ConnectorLanguage.LOW_CODE:
updated_connector_dir = await self.upgrade_cdk_version_for_python_connector(og_connector_dir)
elif self.context.connector.language == ConnectorLanguage.JAVA:
Copy link
Contributor

Choose a reason for hiding this comment

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

To check if something matches an enum value please use is instead of ==.
It's equivalent but I think its recommended by our linter and I find it more pythonic.
elif self.context.connector.language is ConnectorLanguage.JAVA

return StepResult(
self,
StepStatus.FAILURE,
f"Can't upgrade the CDK for connector {self.context.connector.technical_name} of written in {self.context.connector.language}",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
f"Can't upgrade the CDK for connector {self.context.connector.technical_name} of written in {self.context.connector.language}",
f"No CDK found connector {self.context.connector.technical_name} written in {self.context.connector.language}",

Comment on lines 117 to 121
cdk_pypi_url = "https://pypi.org/pypi/airbyte-cdk/json"
response = requests.get(cdk_pypi_url)
response.raise_for_status()
package_info = response.json()
new_version = package_info["info"]["version"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we keep this logic in a separate function? Maybe in a new cdk module under pipelines/helpers/connectors/cdk.py

I'd also find it useful to store your logic to get the latest Java cdk version in there.

Copy link
Contributor

@alafanechere alafanechere left a comment

Choose a reason for hiding this comment

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

Requesting a review from @flash1293 as he's the original contributor to this command and uses it in the python cdk release flox.

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

I didn't get to add that to the CDK release pipeline yet, so changes are inconsequential. Makes total sense to extend this for the Java CDK as well!

@stephane-airbyte stephane-airbyte force-pushed the stephane/01-17-add_the_ability_to_upgrade_CDK_for_java_connectors branch from 7e4a67e to 0df2723 Compare January 25, 2024 04:42
@stephane-airbyte stephane-airbyte force-pushed the stephane/01-17-add_the_ability_to_upgrade_CDK_for_java_connectors branch from 0df2723 to 64e5b0a Compare January 25, 2024 04:45
@alafanechere alafanechere force-pushed the stephane/01-17-add_the_ability_to_upgrade_CDK_for_java_connectors branch from 64e5b0a to 0345e5f Compare January 25, 2024 11:01
@stephane-airbyte stephane-airbyte merged commit 6c4a75d into master Jan 25, 2024
24 checks passed
@stephane-airbyte stephane-airbyte deleted the stephane/01-17-add_the_ability_to_upgrade_CDK_for_java_connectors branch January 25, 2024 16:10
Copy link
Contributor Author

Merge activity

jatinyadav-cc pushed a commit to ollionorg/datapipes-airbyte that referenced this pull request Feb 21, 2024
We already had the ability to update the CDK version for python connectors. I'm just adding the same thing for java connectors.

It required some minor refactoring. I haven't added any tests yet, but I tested it locally
jatinyadav-cc pushed a commit to ollionorg/datapipes-airbyte that referenced this pull request Feb 26, 2024
We already had the ability to update the CDK version for python connectors. I'm just adding the same thing for java connectors.

It required some minor refactoring. I haven't added any tests yet, but I tested it locally
jatinyadav-cc pushed a commit to ollionorg/datapipes-airbyte that referenced this pull request Feb 26, 2024
We already had the ability to update the CDK version for python connectors. I'm just adding the same thing for java connectors.

It required some minor refactoring. I haven't added any tests yet, but I tested it locally
jatinyadav-cc pushed a commit to ollionorg/datapipes-airbyte that referenced this pull request Feb 26, 2024
We already had the ability to update the CDK version for python connectors. I'm just adding the same thing for java connectors.

It required some minor refactoring. I haven't added any tests yet, but I tested it locally
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants