From 677f923ca043936d626b8f4da4ea5bf389f1f2f2 Mon Sep 17 00:00:00 2001 From: Volv G Date: Wed, 18 Nov 2026 19:24:15 -0800 Subject: [PATCH 1/2] Reject a child's missing config before reusing a sibling's artifact A child's `task_annotations` function contributed nothing to its compile key when the child had no config file, so its key matched an annotation-free wrapper over the same function and name. Used after that sibling, the child reused the sibling's artifact, skipping the compile that rejects the missing config, and its defaults were dropped; in the other order it raised. The missing config is now rejected while building the key, with the error the child's own compile raises, whichever sibling comes first. --- .../src/tangle_cli/pipeline_compiler.py | 20 +++++++++++----- tests/test_task_annotation_defaults.py | 24 +++++++++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/packages/tangle-cli/src/tangle_cli/pipeline_compiler.py b/packages/tangle-cli/src/tangle_cli/pipeline_compiler.py index 847a338..407d18e 100644 --- a/packages/tangle-cli/src/tangle_cli/pipeline_compiler.py +++ b/packages/tangle-cli/src/tangle_cli/pipeline_compiler.py @@ -1145,7 +1145,7 @@ def _process_subpipeline_children( config_identity=child_identity, task_annotations=child_task_annotations, own_task_annotations=_own_task_annotations_for_key( - child_fn, child_doc, effective, base_dir=child_base_dir, ctx=ctx + child_fn, child_cfg_path, child_doc, effective, base_dir=child_base_dir, ctx=ctx ), ) @@ -1526,6 +1526,7 @@ def _compile_key_for( def _own_task_annotations_for_key( pipeline_fn: PipelineFn, + cfg_path: Path, doc: CfgDocument | None, overrides: Mapping[str, Any], *, @@ -1540,15 +1541,22 @@ def _own_task_annotations_for_key( setup :func:`_compile_pipeline_fn` traces the child with (``base_dir`` recorded for the after-compile purge, shadowing modules evicted, and ``base_dir`` on ``sys.path``), so a function importing a sibling of the - child resolves it as it does in the trace. Without a config file it - contributes nothing: the child's own compile then fails on the missing - file. + child resolves it as it does in the trace. Without a config file (``doc`` + is ``None``) it raises the missing-config error the child's own compile + would, before the artifact lookup could reuse a sibling's artifact. """ if not callable(pipeline_fn.task_annotations): return _own_task_annotations(pipeline_fn, None) if doc is None: - return {} - cfg = build_cfg(doc.data, overrides=dict(overrides), coerce=False) + cfg, _raw, _identity = _load_cfg_and_raw( + cfg_path, + overrides, + coerce=False, + pipeline_fn=pipeline_fn, + usage="cfg" if _pipeline_accepts_cfg(pipeline_fn) else "task_annotations", + ) + else: + cfg = build_cfg(doc.data, overrides=dict(overrides), coerce=False) try: ctx.source_dirs.add(base_dir.resolve()) except OSError: # pragma: no cover — defensive diff --git a/tests/test_task_annotation_defaults.py b/tests/test_task_annotation_defaults.py index e9db926..c24d2e1 100644 --- a/tests/test_task_annotation_defaults.py +++ b/tests/test_task_annotation_defaults.py @@ -270,6 +270,30 @@ def root(): assert _annotations(direct, "Child Task") == {"team": "helper-child"} +@pytest.mark.parametrize("order", [("plain", "configured"), ("configured", "plain")]) +def test_a_child_defaults_function_without_a_config_fails_whichever_sibling_comes_first(tmp_path, order): + first, second = order + with pytest.raises( + CompileError, + match=r"config file not found: .*Pipeline 'Child' has a task_annotations function", + ): + _compile( + tmp_path, + f""" + def child(): + op.named("Child Task")() + + plain = pipeline("Child")(child) + configured = pipeline("Child", task_annotations=lambda cfg: {{"team": cfg.team}})(child) + + @pipeline("Root") + def root(): + subpipeline({first}).named("First")() + subpipeline({second}).named("Second")() + """, + ) + + @pytest.mark.parametrize("declared", ['"davies"', 'lambda cfg: "davies"']) def test_pipeline_defaults_that_are_not_a_mapping_fail_the_compile(tmp_path, declared): with pytest.raises(CompileError, match=r"'Root'.*must be a mapping or a function of cfg returning one, got str"): From 4910903236926003a6dcc9d62ecf7a8a55570f6f Mon Sep 17 00:00:00 2001 From: Volv G Date: Wed, 18 Nov 2026 19:24:16 -0800 Subject: [PATCH 2/2] Bump version to 0.1.39 --- packages/tangle-cli/src/tangle_cli/__init__.py | 2 +- pyproject.toml | 2 +- tests/test_packaging.py | 2 +- uv.lock | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/tangle-cli/src/tangle_cli/__init__.py b/packages/tangle-cli/src/tangle_cli/__init__.py index c3fc380..e0b18be 100644 --- a/packages/tangle-cli/src/tangle_cli/__init__.py +++ b/packages/tangle-cli/src/tangle_cli/__init__.py @@ -14,6 +14,6 @@ try: __version__ = metadata_version("tangle-cli") except PackageNotFoundError: - __version__ = "0.1.38" + __version__ = "0.1.39" __all__ = ["TangleDynamicDiscoveryClient", "__version__"] diff --git a/pyproject.toml b/pyproject.toml index 8195739..e5f85f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "tangle-cli" -version = "0.1.38" +version = "0.1.39" description = "CLI for Tangle, the open-source ML pipeline orchestration platform" readme = "README.md" authors = [ diff --git a/tests/test_packaging.py b/tests/test_packaging.py index ad45a08..cbf523c 100644 --- a/tests/test_packaging.py +++ b/tests/test_packaging.py @@ -183,7 +183,7 @@ def test_tangle_cli_wheel_supports_expert_no_deps_import_path_without_tangle_api requires_dist = [line for line in metadata.splitlines() if line.startswith("Requires-Dist: ")] assert not any(name.startswith("tangle_api/") for name in names) assert "tangle_cli/openapi/openapi.json" not in names - assert "Version: 0.1.38" in metadata + assert "Version: 0.1.39" in metadata assert "Requires-Dist: tangle-api==0.1.1" in requires_dist assert not any("extra == 'native'" in line for line in requires_dist) assert "Provides-Extra: native" in metadata diff --git a/uv.lock b/uv.lock index 6b6ac5c..0a7707b 100644 --- a/uv.lock +++ b/uv.lock @@ -2083,7 +2083,7 @@ requires-dist = [{ name = "pydantic", specifier = ">=2.0" }] [[package]] name = "tangle-cli" -version = "0.1.38" +version = "0.1.39" source = { editable = "." } dependencies = [ { name = "cloud-pipelines" },