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

airbyte-ci: implement migrate-to-poetry connectors command #35583

Conversation

alafanechere
Copy link
Contributor

@alafanechere alafanechere commented Feb 23, 2024

What

Closes https://github.com/airbytehq/airbyte-internal-issues/issues/2903
This PR adds a migrate-to-poetry command to airbyte-ci connectors command group.
It was used to migrate our certified connectors to poetry

How

The pipeline is composed of the following steps:

  1. Check if the connector is a migration candidate: must use our base image and must not already be migrated
  2. Generate a pyproject.toml and a poetry.lock file according to the dependencies declared in setup.py. We pin main dependencies to the version used in the previous connector version via a pip freeze
  3. Delete the setup.py
  4. Build the poetry based connector version
  5. Run a regression test to confirm the main dependencies version match between the previous connector version and the poetry managed one.
  6. Revert changes if any step in the process failed

****N.B.: This code is not in its cleanest form as the migration was mainly an ad-hoc process, we can improve it if this command gets adopted by the community to migrate community connectors to poetry.

Copy link

vercel bot commented Feb 23, 2024

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

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
airbyte-docs ⬜️ Ignored (Inspect) Visit Preview Mar 20, 2024 7:23am

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @alafanechere and the rest of your teammates on Graphite Graphite

@alafanechere alafanechere force-pushed the augustin/02-06-airbyte-ci_migrate_python_connectors_to_poetry branch from 6a3feb8 to 7bd4dc2 Compare February 23, 2024 12:56
@alafanechere alafanechere marked this pull request as ready for review February 23, 2024 12:57
@alafanechere alafanechere requested a review from a team as a code owner February 23, 2024 12:57
@alafanechere alafanechere force-pushed the augustin/02-06-airbyte-ci_migrate_python_connectors_to_poetry branch from 7bd4dc2 to a4f2992 Compare February 23, 2024 17:31
Copy link
Contributor

@natikgadzhi natikgadzhi left a comment

Choose a reason for hiding this comment

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

LGTM!

I have a couple of connectors on my mind who could try and test it out.

Copy link
Contributor

@girarda girarda left a comment

Choose a reason for hiding this comment

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

looks great! Only request is for surfacing what the migration entails and potentially revisiting the content of connectors' README file

@@ -0,0 +1,91 @@
# {{ connector.name.title()}} source connector
Copy link
Contributor

Choose a reason for hiding this comment

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

should we move this doc to a centralized file since the instructions should be the same for most (all?) API source connectors in the repo?

We could instead have a single markdown file in our docs and just point to it from the connector's readme

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@girarda are you thinking about creating a symlink to a static README file which would serve all connectors? Why not!

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking about a simpler template that just has a link to the actual doc, but a symlink is a good idea


context: ConnectorContext

title = "Check if the connector is a candidate for migration to poetry."
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a high level description of what it takes for a connector to be a candidate? Can we either point to it from this file or add a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add a comment 👍

def get_package_info(self, package_info: str) -> dict:
package_info_dict = {}
for line in package_info.splitlines():
if ":" not in line:
Copy link
Contributor

Choose a reason for hiding this comment

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

what edge case is this catching? can you add a comment? a log might also be useful in case we do find a package without ":"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's to ignore locally installed packages - I'll add a comment. All these parsing logics are very clumsy, sorry

extras = extras.split(",")
if name in latest_dependencies_for_hard_pin:
version = f"=={latest_dependencies_for_hard_pin[name]}"
elif "~=" in deps:
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a comment on this block? maybe more generally, it would be helpful to surface what the migration to poetry entails either in-code in in a readme

)


class RegressionTest(Step):
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be worth documenting what is being tested

@natikgadzhi
Copy link
Contributor

@alafanechere let's get this merged and shipped when you have a moment, just for my sanity and clarity of what's in progress.

@alafanechere alafanechere force-pushed the augustin/02-06-airbyte-ci_migrate_python_connectors_to_poetry branch from a4f2992 to 95e1a77 Compare March 20, 2024 07:23
@alafanechere alafanechere enabled auto-merge (squash) March 20, 2024 07:24
@alafanechere alafanechere merged commit b7d8102 into master Mar 20, 2024
30 checks passed
@alafanechere alafanechere deleted the augustin/02-06-airbyte-ci_migrate_python_connectors_to_poetry branch March 20, 2024 07:41
@artem1205
Copy link
Collaborator

@alafanechere,
I tried to use this command and got this error:

 File "pipelines/airbyte_ci/connectors/migrate_to_poetry/pipeline.py", line 454, in run_connector_migration_to_poetry_pipeline
    step=AddChangelogEntry(
  File "pipelines/airbyte_ci/connectors/bump_version/pipeline.py", line 51, in __init__
    self.pull_request_number = int(pull_request_number)
ValueError: invalid literal for int() with base 10: 'TBD'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants