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: Increase airbyte-ci start time from ~11s to 0.8s #31488

Merged
merged 7 commits into from
Oct 19, 2023

Conversation

bnchrch
Copy link
Contributor

@bnchrch bnchrch commented Oct 17, 2023

Problem

Python loads the kitchen sink by default and Click (our ci library) loads the entire kitchen

Solution

Introduce a lazy loading group as recommended by Click to lazily load command groups to save start up time

Before
image

After

image

Notes for reviewer

The largest noticable speed improvement is airbyte-ci --version

The slowest still will be airbyte-ci --help as it needs to load all commands just as before

and `airbyte-ci connector test should be about 3s-6s faster

closes #31253

@bnchrch bnchrch requested a review from a team October 17, 2023 01:41
@vercel
Copy link

vercel bot commented Oct 17, 2023

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 Oct 19, 2023 4:49pm

@bnchrch bnchrch removed the request for review from a team October 17, 2023 02:50
@bnchrch bnchrch marked this pull request as draft October 17, 2023 02:50
@bnchrch bnchrch requested a review from a team October 19, 2023 00:10
@bnchrch bnchrch marked this pull request as ready for review October 19, 2023 00:10
Copy link
Contributor

@erohmensing erohmensing left a comment

Choose a reason for hiding this comment

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

The slowest still will be airbyte-ci --help as it needs to load all commands just as before

Thank you for writing this because of course that's how I tried to test it 🙈

Comment on lines +115 to +121
"build": "pipelines.airbyte_ci.connectors.build_image.commands.build",
"test": "pipelines.airbyte_ci.connectors.test.commands.test",
"list": "pipelines.airbyte_ci.connectors.list.commands.list",
"publish": "pipelines.airbyte_ci.connectors.publish.commands.publish",
"bump_version": "pipelines.airbyte_ci.connectors.bump_version.commands.bump_version",
"migrate_to_base_image": "pipelines.airbyte_ci.connectors.migrate_to_base_image.commands.migrate_to_base_image",
"upgrade_base_image": "pipelines.airbyte_ci.connectors.upgrade_base_image.commands.upgrade_base_image",
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes me sad because its more things the IDE can't refactor for us 😥

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 know :(

This was a solution recommended by click itself so I went with it

Copy link
Contributor

Choose a reason for hiding this comment

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

Understandable!

Comment on lines +15 to +18
# lazy_subcommands is a map of the form:
#
# {command-name} -> {module-name}.{command-object-name}
#
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 give it a Optional[Dict[str, str]] type to help reinforce this?

Comment on lines +39 to +41
# check the result to make debugging easier
if not isinstance(cmd_object, click.BaseCommand):
raise ValueError(f"Lazy loading of {import_path} failed by returning " "a non-command object")
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

@bnchrch bnchrch merged commit 47222b7 into master Oct 19, 2023
21 checks passed
@bnchrch bnchrch deleted the bnchrch/ci/lazy-load branch October 19, 2023 17:11
ariesgun pushed a commit to ariesgun/airbyte that referenced this pull request Oct 20, 2023
…hq#31488)

Co-authored-by: bnchrch <bnchrch@users.noreply.github.com>
ariesgun pushed a commit to ariesgun/airbyte that referenced this pull request Oct 23, 2023
…hq#31488)

Co-authored-by: bnchrch <bnchrch@users.noreply.github.com>
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.

Increase airbyte-ci start up speed. (lazy import, fast entry point, etc...)
2 participants