-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
add the ability to upgrade CDK for java connectors #34343
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @stephane-airbyte and the rest of your teammates on Graphite |
Before Merging a Connector Pull RequestWow! 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:
If the checklist is complete, but the CI check is failing,
|
@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") |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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": | ||
""" |
There was a problem hiding this comment.
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
ec13a23
to
6ad2ade
Compare
2f86adf
to
6eb4d64
Compare
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 |
There was a problem hiding this comment.
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
4ac0432
to
5873c2c
Compare
73aca55
to
7e4a67e
Compare
There was a problem hiding this 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: |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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}", |
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"] |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
There was a problem hiding this 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!
7e4a67e
to
0df2723
Compare
0df2723
to
64e5b0a
Compare
64e5b0a
to
0345e5f
Compare
…CDK_for_java_connectors
Merge activity
|
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
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
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
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