Fix slow CLI start-up - #109
Open
juhoinkinen wants to merge 2 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #109 +/- ##
==========================================
- Coverage 98.50% 97.79% -0.72%
==========================================
Files 13 13
Lines 536 543 +7
==========================================
+ Hits 528 531 +3
- Misses 8 12 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Improves CLI startup by deferring expensive backend imports until needed.
Changes:
- Adds lazy backend imports and re-exports.
- Adds a CLI startup-time regression test.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
bibra/config.py |
Loads backend classes on demand. |
bibra/backend/__init__.py |
Lazily exposes backend APIs. |
tests/test_cli.py |
Enforces a CLI help startup budget. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+16
to
+21
| def __getattr__(name: str) -> Any: | ||
| """Import and return a lazily re-exported backend name on access.""" | ||
| for module, names in _LAZY_MODULES.items(): | ||
| if name in names: | ||
| return getattr(importlib.import_module(module), name) | ||
| raise AttributeError(f"module {__name__!r} has no attribute {name!r}") |
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.
Reasons for creating this PR
Execution of the CLI "helper" commands was slow:
bibra list-projects,bibra --helpandbibra --versionall took three seconds. Such slow CLI response is not good.Link to relevant issue(s), if any
Description of the changes in this PR
Improves CLI startup by deferring expensive backend imports until needed.
Runtime of
bibra --helpdecreases from 3.14 seconds to 0.30 seconds.I hoped pytest runs would get faster too, but
so essentially no effect.
Instructions how to test this PR
Time performance before and after this using
Known problems or uncertainties in this PR
Copilot review comments on missing
__dir__method, but I'm not sure if that is a real problem.Checklist
Disclosure of AI Tool Usage
Please indicate AI use by choosing the most suitable TLP:AI category below and removing the irrelevant categories from the list. AI:ORANGE is the minimum level for merging.
Describe the AI tool(s) you used:
Zoo Code with Qwen3.8-27B