Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(cli): defer graph initialization - #436

Open
deepujain wants to merge 8 commits into
NVIDIA:mainfrom
deepujain:fix/435-lazy-graph
Open

fix(cli): defer graph initialization#436
deepujain wants to merge 8 commits into
NVIDIA:mainfrom
deepujain:fix/435-lazy-graph

Conversation

@deepujain

@deepujain deepujain commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Defer loading the compiled workflow graph until a caller first uses graph.
  • Keep CLI help and version paths independent of analyzer discovery, so they return without missing-credential warnings.
  • Preserve the existing graph.invoke / graph.ainvoke interface through a thread-safe lightweight proxy.
  • Add subprocess regression coverage that clears provider credentials and verifies --help stays quiet.

Validation

  • uv run pytest tests/unit/test_cli.py -q - 102 passed.
  • uv run pytest -m 'not integration and not provider' tests/ -q - 2,856 passed, 13 skipped, 38 deselected, 4 xfailed.
  • uv run ruff check src tests - passed.
  • uv run ruff format --check src tests - 194 files already formatted.
  • uv run skillspector scan tests/fixtures/safe_skill --no-llm --format json - completed successfully with a 100% complete SAFE report; first graph use still emitted unavailable-analyzer warnings.
  • uv run skillspector --help - returned clean help without analyzer warnings; observed startup fell from roughly 17 seconds to roughly 1.3 seconds in the same worktree.
  • git diff --check - passed.

Risk

  • Low-to-medium: graph creation moves from package/CLI import time to first use, but the compiled graph implementation and scan behavior are unchanged.
  • The proxy uses a lock and double-check so concurrent first callers compile the graph once.
  • Direct imports from skillspector.graph retain their existing eager behavior; the documented package export and CLI use the lazy proxy.

Fixes #435

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[SkillSpector Review]

Help now avoids eager analyzer initialization, but the lazy load makes the documented package-level graph API import-order dependent: after the first load, later imports receive the submodule rather than an invokable graph. Please preserve a stable export and cover the post-load re-import case. All required checks are green.

Comment thread src/skillspector/graph_proxy.py
@deepujain

Copy link
Copy Markdown
Contributor Author

Addressed the import-order regression with the package-level lazy export and test, then fixed the current-head Ruff finding. The lint-fix CI run is now pending.

@deepujain

Copy link
Copy Markdown
Contributor Author

The rerun exposed two Ruff format-only changes already on this PR head. I applied the repository-pinned formatter output, verified Ruff check/format plus syntax checks locally, and pushed the follow-up; CI is rerunning.

deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 1, 2026
Add regression test for the lazy package export requested in NVIDIA#436 review.

Signed-off-by: Deepak Jain <[email protected]>
@deepujain

Copy link
Copy Markdown
Contributor Author

Added tests/unit/test_graph_proxy.py covering post-load re-import stability (rng1995 review). Pushed 3e6cdbf; CI rerunning.

deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 1, 2026
deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 2, 2026
Use patch.dict and importlib cache invalidation so the lazy-graph unit test
does not load the compiled workflow when other tests already imported
skillspector.graph. Replaces the unsigned follow-up on NVIDIA#436.

Signed-off-by: Deepak Jain <[email protected]>
deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 2, 2026
Restore skillspector.graph on both the imported package and sys.modules,
and tighten the regression test so the cached stub compiled graph survives
after the patched import cycle (fixes NVIDIA#436 test-unit on CI).

Signed-off-by: Deepak Jain <[email protected]>
@deepujain

Copy link
Copy Markdown
Contributor Author

Scheduled sweep: pushed f9e2fc7 fixing test-unit failure on test_package_graph_export_survives_submodule_load (restore package-level LazyGraph binding after submodule import). CI rerunning.

@deepujain

Copy link
Copy Markdown
Contributor Author

Re-review request on head e3ca50a9:

The P1 graph-export concern is addressed in graph_proxy.py: after the compiled submodule import, we restore the package-level LazyGraph on both skillspector.graph and sys.modules["skillspector"].graph.

Regression: tests/unit/test_graph_proxy.py::test_package_graph_export_survives_submodule_load reproduces the import-order failure and asserts skillspector.graph stays invokable after the submodule load path.

CI is green on this head. Please re-review when convenient.

deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 6, 2026
Add regression test for the lazy package export requested in NVIDIA#436 review.

Signed-off-by: Deepak Jain <[email protected]>
deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 6, 2026
Use patch.dict and importlib cache invalidation so the lazy-graph unit test
does not load the compiled workflow when other tests already imported
skillspector.graph. Replaces the unsigned follow-up on NVIDIA#436.

Signed-off-by: Deepak Jain <[email protected]>
deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 6, 2026
Restore skillspector.graph on both the imported package and sys.modules,
and tighten the regression test so the cached stub compiled graph survives
after the patched import cycle (fixes NVIDIA#436 test-unit on CI).

Signed-off-by: Deepak Jain <[email protected]>
deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 8, 2026
Add regression test for the lazy package export requested in NVIDIA#436 review.

Signed-off-by: Deepak Jain <[email protected]>
deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 8, 2026
Use patch.dict and importlib cache invalidation so the lazy-graph unit test
does not load the compiled workflow when other tests already imported
skillspector.graph. Replaces the unsigned follow-up on NVIDIA#436.

Signed-off-by: Deepak Jain <[email protected]>
deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 8, 2026
Restore skillspector.graph on both the imported package and sys.modules,
and tighten the regression test so the cached stub compiled graph survives
after the patched import cycle (fixes NVIDIA#436 test-unit on CI).

Signed-off-by: Deepak Jain <[email protected]>
deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 9, 2026
Add regression test for the lazy package export requested in NVIDIA#436 review.

Signed-off-by: Deepak Jain <[email protected]>
deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 9, 2026
Use patch.dict and importlib cache invalidation so the lazy-graph unit test
does not load the compiled workflow when other tests already imported
skillspector.graph. Replaces the unsigned follow-up on NVIDIA#436.

Signed-off-by: Deepak Jain <[email protected]>
deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 9, 2026
Restore skillspector.graph on both the imported package and sys.modules,
and tighten the regression test so the cached stub compiled graph survives
after the patched import cycle (fixes NVIDIA#436 test-unit on CI).

Signed-off-by: Deepak Jain <[email protected]>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[SkillSpector Review]

Reviewed current head ef294980e46612b45ded7f306343687b6379f586. The prior lazy-initialization issue is resolved: _get_compiled restores the compiled singleton to both the package attribute and sys.modules, and the CLI regression exercises the real import path. I found no remaining required change.

All hosted required checks pass and the prior thread is resolved. The branch is behind main, so it must be updated and revalidated before merging.

deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 12, 2026
Add regression test for the lazy package export requested in NVIDIA#436 review.

Signed-off-by: Deepak Jain <[email protected]>
deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 12, 2026
Use patch.dict and importlib cache invalidation so the lazy-graph unit test
does not load the compiled workflow when other tests already imported
skillspector.graph. Replaces the unsigned follow-up on NVIDIA#436.

Signed-off-by: Deepak Jain <[email protected]>
deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 12, 2026
Restore skillspector.graph on both the imported package and sys.modules,
and tighten the regression test so the cached stub compiled graph survives
after the patched import cycle (fixes NVIDIA#436 test-unit on CI).

Signed-off-by: Deepak Jain <[email protected]>
deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 12, 2026
Add regression test for the lazy package export requested in NVIDIA#436 review.

Signed-off-by: Deepak Jain <[email protected]>
deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 12, 2026
Use patch.dict and importlib cache invalidation so the lazy-graph unit test
does not load the compiled workflow when other tests already imported
skillspector.graph. Replaces the unsigned follow-up on NVIDIA#436.

Signed-off-by: Deepak Jain <[email protected]>
deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 12, 2026
Restore skillspector.graph on both the imported package and sys.modules,
and tighten the regression test so the cached stub compiled graph survives
after the patched import cycle (fixes NVIDIA#436 test-unit on CI).

Signed-off-by: Deepak Jain <[email protected]>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[SkillSpector Review]

Corrective re-review of current head 6170e12f9cd6b7479b1365507328e17451be98ed. The create-graph-first import path still replaces the documented package-level lazy graph export with the submodule. Please restore the export in this wrapper and add a regression that exercises skillspector.create_graph() before from skillspector import graph.


def create_graph() -> Any:
"""Build and return a new SkillSpector workflow graph."""
from skillspector.graph import create_graph as build_graph

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Importing this submodule overwrites the parent package's graph attribute with the skillspector.graph module. Unlike LazyGraph._get_compiled(), this wrapper never restores the lazy proxy, so when skillspector.create_graph() is the first graph access, a later from skillspector import graph can return a module without .invoke. Please restore the package export after this import/call and add a regression that calls skillspector.create_graph() before reading or invoking skillspector.graph.

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[SkillSpector Review]

Re-reviewed current head 7c8b87c76d5c8658118c9a22b6f4d2548c8cca76 after the latest main synchronization. All five PR-owned blobs are byte-identical to the prior head, so the create-graph-first blocker remains: skillspector.create_graph() can import the submodule without restoring the documented package-level lazy graph export. The prior inline comment contains the exact correction and regression request, so I have not duplicated it.

All hosted checks pass, but the required code change remains and GitHub reports mergeStateStatus=BLOCKED.

deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 12, 2026
Add regression test for the lazy package export requested in NVIDIA#436 review.

Signed-off-by: Deepak Jain <[email protected]>
deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 12, 2026
Use patch.dict and importlib cache invalidation so the lazy-graph unit test
does not load the compiled workflow when other tests already imported
skillspector.graph. Replaces the unsigned follow-up on NVIDIA#436.

Signed-off-by: Deepak Jain <[email protected]>
deepujain added a commit to deepujain/SkillSpector that referenced this pull request Sep 12, 2026
Restore skillspector.graph on both the imported package and sys.modules,
and tighten the regression test so the cached stub compiled graph survives
after the patched import cycle (fixes NVIDIA#436 test-unit on CI).

Signed-off-by: Deepak Jain <[email protected]>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[SkillSpector Review]

Re-reviewed current head ccc66c90472e352ef3e14997951574d1615c00fe after the automated branch resynchronization. All five PR-owned blobs are byte-for-byte identical to the previously reviewed changes-requested head 7c8b87c76d5c8658118c9a22b6f4d2548c8cca76.

The create-graph-first blocker remains: skillspector.create_graph() can import the submodule without restoring the documented package-level lazy graph export, so a later from skillspector import graph can return a non-invokable module. The existing inline thread contains the exact correction and regression request, so I have not duplicated it.

All hosted checks pass, but the required code change remains and GitHub reports mergeStateStatus=BLOCKED.

deepujain and others added 8 commits September 13, 2026 11:45
Preserve the package-level lazy graph export after first loading the graph and cover the import-order contract.

Signed-off-by: Deepak Jain <[email protected]>
Add regression test for the lazy package export requested in NVIDIA#436 review.

Signed-off-by: Deepak Jain <[email protected]>
Use patch.dict and importlib cache invalidation so the lazy-graph unit test
does not load the compiled workflow when other tests already imported
skillspector.graph. Replaces the unsigned follow-up on NVIDIA#436.

Signed-off-by: Deepak Jain <[email protected]>
Restore skillspector.graph on both the imported package and sys.modules,
and tighten the regression test so the cached stub compiled graph survives
after the patched import cycle (fixes NVIDIA#436 test-unit on CI).

Signed-off-by: Deepak Jain <[email protected]>
Simulate the submodule clobber and graph_proxy restore path directly so
the unit test stays stable when skillspector.graph is already loaded in
the CI session.

Signed-off-by: Deepak Jain <[email protected]>
CLI tests that monkeypatch skillspector.cli.graph.invoke leave the real bound
method on the shared LazyGraph singleton after undo, bypassing __getattr__ and
breaking graph-proxy regression tests in full CI order.

Signed-off-by: Deepak Jain <[email protected]>
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.

CLI help eagerly builds the analyzer graph and emits missing-key warnings

2 participants