Skip to content

Use main.py as call graph entry point for CLI commands#53

Open
theweaklink wants to merge 5 commits into
deeplime-io:1.xfrom
theweaklink:feature/main-entry-call-graph
Open

Use main.py as call graph entry point for CLI commands#53
theweaklink wants to merge 5 commits into
deeplime-io:1.xfrom
theweaklink:feature/main-entry-call-graph

Conversation

@theweaklink

@theweaklink theweaklink commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add get_call_graph_entry_files() to centralize PyCG entry file selection for all CLI commands that perform static analysis.
  • onecode-build, onecode-extract, onecode-check, and onecode-require now analyze main.py plus only the flow scripts registered in .onecode.json (the same flows executed at runtime by main.py).
  • Stop globbing flows/**/*.py or the entire project tree, which previously caused unrelated files (.venv, unused scripts, data helpers) to be parsed.

Motivation

On Windows, when a .venv lives inside the project directory, PyCG's naive mod_dir in mod.__file__ check treated site-packages as local project code and crashed during analysis. Even without that bug, scanning every .py file under flows/ or the project root is broader than what OneCode actually runs.

Using main.py as the entry point mirrors the runtime execution model: flows are loaded from .onecode.json, not discovered by directory glob.

Test plan

  • tests/unit/utils/test_call_graph_entry.py — verifies entry files exclude flows/unused.py
  • tests/unit/cli/test_extract.py — ground-truth extraction unchanged
  • tests/unit/cli/test_build.py — ground-truth build unchanged
  • tests/unit/cli/test_check.py::test_imported_modules — same module set as before
  • tests/unit/cli/test_require.py — same requirements output as before

theweaklink and others added 5 commits June 24, 2026 14:37
Centralize entry file selection in get_call_graph_entry_files() so
onecode-build, onecode-extract, onecode-check, and onecode-require
analyze main.py plus registered flows from .onecode.json instead of
globbing all Python files under flows/ or the project root.

Co-authored-by: Cursor <[email protected]>
Resolve PyCG graph keys such as utils.xx to flows\utils.xx on Windows
so extract/build pick up OneCode elements defined in imported helper
modules under flows/.

Co-authored-by: Cursor <[email protected]>
Backslashes are not allowed inside f-string expressions before Python
3.12. Build the Windows graph key with string concatenation instead.

Co-authored-by: Cursor <[email protected]>
Do not replace dots in function namespaces when building Windows keys:
step1.run must resolve to flows\step1.run, not flows\step1\run.

Always start extraction from flows.{name}.run and let
_resolve_graph_key map to the platform-specific PyCG namespace.

Co-authored-by: Cursor <[email protected]>
On Windows, PyCG does not always analyze relative imports such as
`from .utils import xx` unless the helper module is an explicit entry
file. Collect helpers imported by registered flows and add them to
get_call_graph_entry_files() so step2 can reach flows/utils.py.

Co-authored-by: Cursor <[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.

1 participant