[CLI] Make top-level Flow360 import lazy#2024
Merged
maciej-flexcompute merged 11 commits intoMay 4, 2026
Merged
Conversation
Contributor
Coverage report (flow360)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 95e2ba6. Configure here.
benflexcompute
approved these changes
May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
This PR keeps the PR1 CLI foundation lightweight by making
import flow360lazy:flow360/__init__.pyintoflow360/_api.py__getattr__without importing heavy modules during root package importflow360.version_checkattribute pathflow360.user_configsoflow360.configureno longer imports the Click CLI appThis intentionally does not include the later resource CLI commands, delete commands, logs, or mutation workflow work.
Validation
poetry run pytest tests/test_lazy_imports.py tests/test_cli.py tests/test_cli_login.py -q->20 passed in 4.16spoetry run pytest tests/test_version_check.py -q->3 passed in 0.03spoetry run:import flow360->0.008551s, withflow360._api=False,pandas=Falsepoetry run:import flow360.cli.app->0.744254s, with_api/project/folder/flow360_requestsnot importedCLI Performance Comparison
Methodology:
Flow360-pr1Flow360-pr1.5flow360executable, notpoetry runFLOW360_SUPPRESS_BETA_WARNING=1project/foldersubcommand via--help, to isolate startup/import and command-dispatch latency from network/auth latencyflow360 --helpflow360 configure --helpflow360 login --helpflow360 logout --helpflow360 show_projects --helpflow360 version --helpflow360 project --helpflow360 project info --helpflow360 project items --helpflow360 project list --helpflow360 project path --helpflow360 project tree --helpflow360 folder --helpflow360 folder get --helpflow360 folder tree --helpResult: PR1.5 is consistently faster across the full CLI help surface. Root
flow360 --helpdrops from ~2.9s to ~0.2s, and subcommands generally drop from ~2.9-3.6s to ~0.63-0.88s.Note
Medium Risk
Medium risk because it rewires
flow360package exports and lazy-loading behavior, which can cause subtle import-time/regression issues if__all__or attribute resolution diverges from prior behavior.Overview
flow360’s root package is refactored into a lazy facade: the previous eager mass-imports are moved into a newflow360/_public_namespace.py, andflow360/__init__.pynow exposes the same API via__getattr__that loads symbols on demand.__all__is now derived by parsing_public_namespace.py’s__all__viaast,__dir__is updated accordingly, and a new__init__.pyistub statically re-exports the public names for type checkers.configureis reimplemented in_public_namespaceto lazily import the CLI configure caller, and expanded tests assert that importingflow360/CLI help paths do not eagerly import heavy dependencies or CLI command modules and that stub exports match_public_namespace.__all__.Reviewed by Cursor Bugbot for commit b2048d7. Bugbot is set up for automated code reviews on this repo. Configure here.