Skip to content

Commit 2acf5da

Browse files
heyong4725claude
andauthored
fix(ci): install template nodes into root venv before pytest (#1843)
The cli-python job's "Test Python template project" step has been failing on every main commit since #1820 ("feat(uv): per-node managed Python venvs at build + runtime", commit 6ae0fa9) -- 5+ merged commits all red, blocking the Trunk merge queue alongside the ros2-bridge regression that #1839 just resolved. Root cause ========== #1820 changed `dora build --uv` to install each node package into its own managed venv at `.dora/python-envs/<node>/` (good for deterministic per-node deps + no cross-node contamination). But the `dora new --lang python` templates generated test stubs at `tests/test_<node>.py` do: from <node>.main import main The CI step pytest invocation is `uv run pytest` from the test_python_project root, which resolves against the ambient venv (VIRTUAL_ENV set by the earlier setup-python-uv step to the repo-level .venv/). That venv has dora-rs + pyarrow + pytest + ruff but no node packages -- those are in the per-node venvs. Pre-#1820, `dora build` installed nodes into whatever venv was active, so the imports worked. Actual failure from CircleCI v1.1 API log on main HEAD (job 5882, step "Test Python template project"): FAILED listener-1/tests/test_listener_1.py::test_import_main > from listener_1.main import main E ModuleNotFoundError: No module named 'listener_1' FAILED talker-1/tests/test_talker_1.py::test_import_main > from talker_1.main import main E ModuleNotFoundError: No module named 'talker_1' FAILED talker-2/tests/test_talker_2.py::test_import_main > from talker_2.main import main E ModuleNotFoundError: No module named 'talker_2' 3 failed, 3 passed Fix === After `dora build --uv` (which sets up the per-node venvs), also install the three node packages into the active venv so `uv run pytest` at the project root can resolve their imports: uv pip install -e listener-1 -e talker-1 -e talker-2 This preserves the per-node-venv isolation that #1820 introduced (those venvs still drive `dora build` and `dora run`) while giving the test pass a venv that sees all node packages. The root venv is ephemeral and only used by this CI step, so no production contamination. Scope notes =========== * CI-only fix; the `dora new` template itself is unchanged. Users running `pytest` in their own `dora new` projects will hit the same issue, but fixing that requires a template-level change (e.g. root pyproject.toml that path-depends on each node, or a documented "for testing, also pip install -e <node>/" step in the README). That is a separate follow-up; this PR keeps scope to "unblock the merge queue." * The hardcoded node names listener-1, talker-1, talker-2 match the `dora new --lang python` template (see binaries/cli/src/template/python/mod.rs:126-130). If that template grows or shrinks the node set, this list needs to follow. A loop over `*/pyproject.toml` would be more robust but also more clever-shell; keeping the explicit list for clarity. Validation ========== Local repro is awkward (the CI step builds the whole dora CLI from source first), but the failure mode is mechanically obvious from the log and the fix is a one-line `uv pip install -e` of the same packages the build step references. CircleCI will validate on this PR. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 210bb39 commit 2acf5da

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

.circleci/config.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,17 @@ jobs:
623623
cd test_python_project
624624
dora build dataflow.yml --uv
625625
uv run ruff check .
626+
# #1820 introduced per-node managed Python venvs at
627+
# `.dora/python-envs/<node>/`, so `dora build --uv` no
628+
# longer leaves the node packages installed in the
629+
# ambient venv. The template's generated test stubs do
630+
# `from <node>.main import main` and the project root has
631+
# no top-level pyproject for `uv run pytest` to resolve
632+
# against, so the imports fail with ModuleNotFoundError.
633+
# Install each node into the active venv for the test
634+
# pass; the per-node venvs continue to drive `dora build`
635+
# / `dora run` themselves.
636+
uv pip install -e listener-1 -e talker-1 -e talker-2
626637
uv run pytest
627638
export OPERATING_MODE=SAVE
628639
dora build dataflow.yml --uv

0 commit comments

Comments
 (0)