-
Notifications
You must be signed in to change notification settings - Fork 350
fix(cli): fix dimos --help (both bad imports and speed)
#1571
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
412e759
fix(cli): speed up `dimos --help` by extracting lightweight type aliases
jeff-hykin afc58ca
fix: move type aliases to their respective packages
jeff-hykin 0113d87
test: add CLI startup speed regression test
jeff-hykin 4deeec6
CI code cleanup
jeff-hykin c84cf95
merge: resolve conflicts with dev
jeff-hykin 61f8588
fix: exclude .venv and other non-source dirs from doclinks file index
jeff-hykin 75c0515
Revert "fix: exclude .venv and other non-source dirs from doclinks fi…
jeff-hykin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Copyright 2026 Dimensional Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from typing import Literal, TypeAlias | ||
|
|
||
| NavigationStrategy: TypeAlias = Literal["simple", "mixed"] |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from typing import Literal | ||
|
|
||
| VlModelName = Literal["qwen", "moondream"] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # Copyright 2025-2026 Dimensional Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Guard against import-time regressions in the CLI entrypoint. | ||
|
|
||
| `dimos --help` should never pull in heavy ML/viz libraries. If it does, | ||
| startup time balloons from <2s to >5s, which is a terrible UX. | ||
| """ | ||
|
|
||
| import subprocess | ||
| import sys | ||
| import time | ||
|
|
||
| # CI runners are slower — give generous headroom but still catch gross regressions. | ||
| HELP_TIMEOUT_SECONDS = 8 | ||
|
|
||
|
|
||
| def test_help_does_not_import_heavy_deps() -> None: | ||
| """GlobalConfig import must not drag in matplotlib, torch, or scipy.""" | ||
| result = subprocess.run( | ||
| [ | ||
| sys.executable, | ||
| "-c", | ||
| ( | ||
| "import sys; " | ||
| "from dimos.core.global_config import GlobalConfig; " | ||
| "bad = [m for m in ('matplotlib', 'torch', 'scipy') if m in sys.modules]; " | ||
| "assert not bad, f'Heavy deps imported: {bad}'" | ||
| ), | ||
| ], | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=30, | ||
| ) | ||
| assert result.returncode == 0, f"Heavy deps leaked into GlobalConfig import:\n{result.stderr}" | ||
|
|
||
|
|
||
| def test_help_startup_time() -> None: | ||
| """`dimos --help` must finish in under {HELP_TIMEOUT_SECONDS}s.""" | ||
| start = time.monotonic() | ||
| result = subprocess.run( | ||
| [sys.executable, "-m", "dimos.robot.cli.dimos", "--help"], | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=HELP_TIMEOUT_SECONDS + 5, # hard kill safety margin | ||
| ) | ||
| elapsed = time.monotonic() - start | ||
| assert result.returncode == 0, f"dimos --help failed:\n{result.stderr}" | ||
| assert elapsed < HELP_TIMEOUT_SECONDS, ( | ||
| f"dimos --help took {elapsed:.1f}s (limit: {HELP_TIMEOUT_SECONDS}s). " | ||
| f"Check for heavy imports in the CLI entrypoint or GlobalConfig." | ||
| ) | ||
Oops, something went wrong.
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.
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.
Unused
pytestimportpytestis imported on this line but never used in the module — nopytest.mark,pytest.raises,pytest.fixture, etc. appear anywhere. This will trigger linter warnings (e.g.F401in flake8/ruff).