Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/tangle-cli/src/tangle_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
try:
__version__ = metadata_version("tangle-cli")
except PackageNotFoundError:
__version__ = "0.1.38"
__version__ = "0.1.39"

__all__ = ["TangleDynamicDiscoveryClient", "__version__"]
20 changes: 14 additions & 6 deletions packages/tangle-cli/src/tangle_cli/pipeline_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
)

Expand Down Expand Up @@ -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],
*,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion tests/test_packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions tests/test_task_annotation_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading