diff --git a/README.md b/README.md index 6767f95..f2f811a 100644 --- a/README.md +++ b/README.md @@ -914,6 +914,30 @@ _select: Task IDs default from the left-hand variable name at the call site, converted to title case. If there is no simple left-hand variable, or if you want a stable explicit label, call `.named("Task Id")` before invoking the task. Use `.bind(...)` to pre-fill task arguments and `.with_annotations({...})` to add per-task annotations. +##### Default task annotations + +`@pipeline(task_annotations=...)` sets default annotations for every task in that pipeline's body. Pass a mapping, or a function of the pipeline's resolved `cfg` when values differ per environment: + +```python +@pipeline( + "Daily", + config="config.yaml", + task_annotations=lambda cfg: {"example.com/account": cfg.service_account}, +) +def daily(cfg=None) -> None: + extract = load() # the defaults + train = fit.with_annotations({"example.com/gpu": "a100"})() # the defaults plus its own key + subpipeline(report).with_task_annotations( + {"example.com/account": cfg.service_account} + )(wait_for=train) +``` + +- A function makes the config file a required compile-time input, as a `cfg` parameter does. +- A task's own annotations, from `.with_annotations(...)` or a typed helper such as `.with_position(...)`, win per key; the other defaults stay. +- Defaults do not reach a `subpipeline` boundary task or the tasks inside a child. `subpipeline(child).with_task_annotations({...})` pushes a mapping into every task of the child's subtree, except `subpipeline` boundary tasks. It takes a mapping of scalars, not a function: compute values from the parent's `cfg`. +- Precedence, lowest first: the child's own `task_annotations`, an outer call site, a nearer call site, the task's own annotations. +- Call-site defaults are part of the child's compile identity: calls pushing different defaults compile the child into separate sidecars, and identical calls share one. + ##### Root pipeline annotations `@pipeline(annotations={...})` writes the compiled pipeline's root `metadata.annotations` block. A caller that compiles programmatically can supply the block instead — typically from its own per-environment config file, so the values do not have to be hard-coded in source: diff --git a/packages/tangle-cli/src/tangle_cli/__init__.py b/packages/tangle-cli/src/tangle_cli/__init__.py index 336051e..57ada0e 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.35" + __version__ = "0.1.36" __all__ = ["TangleDynamicDiscoveryClient", "__version__"] diff --git a/packages/tangle-cli/src/tangle_cli/pipeline_compiler.py b/packages/tangle-cli/src/tangle_cli/pipeline_compiler.py index 4ae1451..3714bfd 100644 --- a/packages/tangle-cli/src/tangle_cli/pipeline_compiler.py +++ b/packages/tangle-cli/src/tangle_cli/pipeline_compiler.py @@ -706,7 +706,7 @@ def _resolve_cfg_for_pipeline( missing config all still raise. """ cfg_path = _resolve_cfg_path_in_dir(pipeline_fn, base_dir) - uses_cfg = _pipeline_accepts_cfg(pipeline_fn) + uses_cfg = _pipeline_reads_cfg(pipeline_fn) should_load_config = uses_cfg or pipeline_fn.propagate_config if should_load_config: _assert_config_output_path_is_separate( @@ -722,7 +722,13 @@ def _resolve_cfg_for_pipeline( overrides, coerce=is_root, pipeline_fn=pipeline_fn, - usage="cfg" if uses_cfg else "propagate_config", + usage=( + "cfg" + if _pipeline_accepts_cfg(pipeline_fn) + else "task_annotations" + if uses_cfg + else "propagate_config" + ), allow_override_only=allow_override_only, suggest_override_only=implicit_root_config, ) @@ -774,6 +780,7 @@ def _compile_pipeline_fn( precomputed_key: PipelineCompileKey | None = None, layout_policy: _LayoutPolicy = _NO_LAYOUT, occurrence_path: tuple[str, ...] = (), + inherited_task_annotations: Mapping[str, Any] | None = None, ) -> SubgraphArtifact: """Trace + emit ``pipeline_fn`` into an in-memory :class:`SubgraphArtifact`. @@ -831,7 +838,12 @@ def _compile_pipeline_fn( # legitimate RUNTIME template placeholders the no-template-delimiter # output guard must skip for THIS artifact's body. with _temp_sys_path(base_dir): - builder = trace_pipeline(pipeline_fn, cfg=cfg, inputs={}) + builder = trace_pipeline( + pipeline_fn, + cfg=cfg, + inputs={}, + inherited_task_annotations=inherited_task_annotations, + ) # Caller-supplied root annotations: ROOT ONLY (a child keeps exactly what # its own ``@pipeline`` declared), merged PER KEY with the caller winning # on collision, before emit so they pass the same emit-time guards as @@ -994,6 +1006,7 @@ def _compile_pipeline_fn( parent_propagate_config=pipeline_fn.propagate_config, layout_carry=layout_policy.carry, occurrence_path=occurrence_path, + inherited_task_annotations=inherited_task_annotations or {}, ) finally: ctx.active_stack.pop() @@ -1022,6 +1035,7 @@ def _process_subpipeline_children( parent_propagate_config: bool, layout_carry: Layout | None = None, occurrence_path: tuple[str, ...] = (), + inherited_task_annotations: Mapping[str, Any], ) -> None: """Compile each ``subpipeline(child)(...)`` recorded during ``builder``'s trace and rewrite the parent task's ``componentRef`` to a pure @@ -1085,7 +1099,7 @@ def _process_subpipeline_children( # ``_select``/``_env``). child_doc: CfgDocument | None = None child_identity: str | None = None - if (_pipeline_accepts_cfg(child_fn) or child_fn.propagate_config) and child_cfg_path.exists(): + if (_pipeline_reads_cfg(child_fn) or child_fn.propagate_config) and child_cfg_path.exists(): child_doc = read_cfg_document(child_cfg_path) child_identity = _config_identity(child_doc) if ctx.broadcast_stack or sub_ref.config_overrides: @@ -1121,6 +1135,7 @@ def _process_subpipeline_children( else: effective = {} + child_task_annotations = {**inherited_task_annotations, **sub_ref.task_annotations} child_key = _compile_key_for( child_fn, child_cfg_path, @@ -1128,6 +1143,7 @@ def _process_subpipeline_children( fingerprint_context=f"on subpipeline task {task_id!r} -> child pipeline {child_fn.name!r}", ambient_context=ambient_passthrough or None, config_identity=child_identity, + task_annotations=child_task_annotations, ) # Cycle detection (covers self-reference). active_stack holds the @@ -1198,6 +1214,7 @@ def _process_subpipeline_children( precomputed_key=child_key, layout_policy=child_policy, occurrence_path=(*occurrence_path, task_id), + inherited_task_annotations=child_task_annotations, ) finally: if pushed_edge_override: @@ -1428,6 +1445,7 @@ def _compile_key_for( fingerprint_context: str | None = None, ambient_context: Mapping[str, Any] | None = None, config_identity: str | None = None, + task_annotations: Mapping[str, Any] | None = None, ) -> PipelineCompileKey: """Build the canonical :class:`PipelineCompileKey` for ``pipeline_fn``. @@ -1462,13 +1480,16 @@ def _compile_key_for( see :func:`_config_identity`) -> the same envelope plus ``"\x00config"``, so different environment selections get distinct keys while identical resolved configs keep identical keys. + * **``task_annotations``** (defaults pushed in by ancestor + ``.with_task_annotations`` call sites) -> the same envelope plus + ``"\x00task_annotations"``. """ src = _pipeline_source_path(pipeline_fn) if src is not None: source_canon = canonical_repo_path(src) else: source_canon = f"" - if ambient_context or config_identity is not None: + if ambient_context or config_identity is not None or task_annotations: # Reserved keys (NUL-prefixed) can never be real config keys, so an # envelope never collides with an effective-only fingerprint over the # same keys (e.g. effective={x:1},ambient={} vs effective={x:1},ambient={y:2}). @@ -1477,6 +1498,8 @@ def _compile_key_for( envelope["\x00ambient"] = dict(sorted(ambient_context.items())) if config_identity is not None: envelope["\x00config"] = config_identity + if task_annotations: + envelope["\x00task_annotations"] = dict(task_annotations) fingerprint_input: Mapping[str, Any] = envelope else: # Byte-identical to today's key: the default-isolation guarantee. @@ -2982,6 +3005,12 @@ def _pipeline_source_path(pipeline_fn: PipelineFn) -> Path | None: return resolved +def _pipeline_reads_cfg(pipeline_fn: PipelineFn) -> bool: + """Whether compile-time config is observable: a ``cfg`` parameter or a + ``task_annotations`` function.""" + return _pipeline_accepts_cfg(pipeline_fn) or callable(pipeline_fn.task_annotations) + + def _pipeline_accepts_cfg(pipeline_fn: PipelineFn) -> bool: """Return whether the pipeline function has a real ``cfg`` parameter. @@ -3100,6 +3129,12 @@ def _load_cfg_and_raw( "descendant subpipelines. Create the file, remove `config=`, " "or disable propagate_config if there is no config to broadcast." ) + elif usage == "task_annotations": + reason = ( + "has a task_annotations function, so " + f"{source} is required as a compile-time input. Create the file, " + "or pass task_annotations a mapping instead." + ) else: reason = ( "has a `cfg` parameter, so " diff --git a/packages/tangle-cli/src/tangle_cli/python_pipeline/pipeline.py b/packages/tangle-cli/src/tangle_cli/python_pipeline/pipeline.py index 1e70eff..1b3b587 100644 --- a/packages/tangle-cli/src/tangle_cli/python_pipeline/pipeline.py +++ b/packages/tangle-cli/src/tangle_cli/python_pipeline/pipeline.py @@ -9,6 +9,7 @@ from __future__ import annotations import inspect +from collections.abc import Mapping from dataclasses import dataclass, field from pathlib import Path from typing import Any, Callable @@ -45,7 +46,7 @@ class PipelineFn: # ``metadata.labels`` — a separate block from annotations, and typed # ``str -> str`` by both schemas. labels: dict[str, str] = field(default_factory=dict) - task_annotations: dict[str, Any] = field(default_factory=dict) + task_annotations: Mapping[str, Any] | Callable[[Any], Mapping[str, Any]] = field(default_factory=dict) caller_dir: Path | None = None # Convention for the single Out[T] slot's name. Defaults to the PoC # canonical sentinel ``wait_for_output``; overridable via @@ -147,7 +148,7 @@ def pipeline( config: str | None = None, annotations: dict[str, Any] | None = None, labels: dict[str, str] | None = None, - task_annotations: dict[str, Any] | None = None, + task_annotations: Mapping[str, Any] | Callable[[Any], Mapping[str, Any]] | None = None, flow_direction: str | None = None, output_name: str = "wait_for_output", propagate_config: bool = False, @@ -176,10 +177,12 @@ def pipeline( ``editor.flow-direction`` root annotation (``"left-to-right"`` / ``"top-to-bottom"``). Sugar over ``annotations``; applied last, so it wins on that key. - task_annotations: Per-task default annotations applied to every - task in the pipeline. Accepted for API completeness but not - wired through in MVP — the PoC sets per-task annotations - explicitly via ``.with_annotations``. + task_annotations: Default annotations for every task in this + pipeline's body: a mapping, or a function of the pipeline's + resolved ``cfg`` returning one. A task's own annotations win per + key. ``subpipeline`` boundary tasks and the tasks inside a child + are not covered; push defaults into a child with + ``subpipeline(child).with_task_annotations(...)``. output_name: Name for the single ``Out[T]`` output slot. Defaults to ``wait_for_output`` (matches the PoC). propagate_config: Broadcasts this pipeline's own config.yaml deep @@ -215,7 +218,7 @@ def decorator(fn: Callable[..., Any]) -> PipelineFn: config_path=config, annotations=merged_annotations, labels=checked_labels, - task_annotations=dict(task_annotations or {}), + task_annotations=task_annotations or {}, caller_dir=caller_dir, output_name=output_name, propagate_config=propagate_config, diff --git a/packages/tangle-cli/src/tangle_cli/python_pipeline/subpipeline.py b/packages/tangle-cli/src/tangle_cli/python_pipeline/subpipeline.py index 2345754..1eb0d4d 100644 --- a/packages/tangle-cli/src/tangle_cli/python_pipeline/subpipeline.py +++ b/packages/tangle-cli/src/tangle_cli/python_pipeline/subpipeline.py @@ -13,7 +13,8 @@ ``subpipeline(child)`` returns a :class:`SubpipelineRef` — a task-like handle that mirrors :class:`tangle_cli.python_pipeline.ref.CallableRef` ergonomics (``.bind`` / ``.named`` / ``.with_annotations`` and call-site -kwargs). Calling the handle inside an active ``@pipeline`` trace records +kwargs), plus ``.with_task_annotations`` for defaults that reach the tasks +inside the child. Calling the handle inside an active ``@pipeline`` trace records ONE parent task (never the child's internals) and returns a :class:`tangle_cli.python_pipeline.placeholders.TaskOutputProxy`. Tangle only supports conditional execution and execution options for container-component @@ -33,6 +34,7 @@ from __future__ import annotations +from collections.abc import Mapping from dataclasses import dataclass, field, replace from typing import TYPE_CHECKING, Any @@ -69,6 +71,7 @@ class SubpipelineRef: task_id_hint: str | None = None annotations: dict[str, str] | None = None config_overrides: dict[str, Any] = field(default_factory=dict) + task_annotations: dict[str, Any] = field(default_factory=dict) # ------------------------------------------------------------------ # Builders — all return a fresh SubpipelineRef (immutable composition) @@ -92,6 +95,24 @@ def with_annotations(self, ann: dict[str, Any]) -> "SubpipelineRef": merged[k] = v # type: ignore[assignment] return replace(self, annotations=merged) + def with_task_annotations(self, ann: Mapping[str, Any]) -> "SubpipelineRef": + """Default annotations for every task in the child's subtree except + boundary tasks; nearer call sites and a task's own annotations win. + Scalar mapping only: it is part of the child's compile key.""" + if not isinstance(ann, Mapping): + raise CompileError( + "subpipeline(...).with_task_annotations() takes a mapping, got " + f"{type(ann).__name__}. Compute values from the parent's cfg, e.g. " + ".with_task_annotations({'key': cfg.value})." + ) + for key, value in ann.items(): + if not (value is None or isinstance(value, (str, int, float, bool))): + raise CompileError( + f"subpipeline(...).with_task_annotations() value for {key!r} must be " + f"a string or another scalar, got {type(value).__name__}." + ) + return replace(self, task_annotations={**self.task_annotations, **ann}) + def with_position( self, x: float, @@ -253,7 +274,8 @@ def subpipeline(child: "PipelineFn") -> SubpipelineRef: Returns: A :class:`SubpipelineRef` supporting ``.bind`` / ``.named`` / - ``.with_annotations`` and trace-time ``__call__``. + ``.with_annotations`` / ``.with_task_annotations`` and trace-time + ``__call__``. Raises: CompileError: if ``child`` is not a :class:`PipelineFn` (e.g. a diff --git a/packages/tangle-cli/src/tangle_cli/python_pipeline/trace.py b/packages/tangle-cli/src/tangle_cli/python_pipeline/trace.py index c97027c..db5b30e 100644 --- a/packages/tangle-cli/src/tangle_cli/python_pipeline/trace.py +++ b/packages/tangle-cli/src/tangle_cli/python_pipeline/trace.py @@ -29,6 +29,7 @@ import inspect import textwrap import typing +from collections.abc import Mapping from contextvars import ContextVar from typing import TYPE_CHECKING, Any @@ -217,11 +218,17 @@ def trace_pipeline( pipeline_fn: "PipelineFn", cfg: Any, inputs: dict[str, Any] | None = None, + *, + inherited_task_annotations: Mapping[str, Any] | None = None, ) -> GraphBuilder: """Trace ``pipeline_fn`` against ``cfg`` (+ optional runtime ``inputs``). Returns the populated :class:`GraphBuilder` ready for emit. + Every task except a ``subpipeline`` boundary task gets the pipeline's own + ``task_annotations``, overlaid by ``inherited_task_annotations`` (pushed in + by ancestor call sites), overlaid by the task's own annotations. + The function's parameters are inspected: - ``cfg`` (no ``In`` annotation, named exactly ``cfg``) → bound to the loaded :class:`Cfg` object. @@ -309,6 +316,13 @@ def trace_pipeline( finally: _BUILDER.reset(token) + defaults = {**_own_task_annotations(pipeline_fn, cfg), **(inherited_task_annotations or {})} + if defaults: + boundary_task_ids = {task_id for task_id, _ref in builder.task_refs_for_subpipelines} + for node in builder.tasks: + if node.task_id not in boundary_task_ids: + node.annotations = {**defaults, **(node.annotations or {})} + # Capture the declared output(s). ``get_type_hints`` returns the # resolved return annotation under the ``return`` key. Two shapes: # * single ``-> Out[T]`` -> one output (legacy path, unchanged); @@ -344,6 +358,17 @@ def trace_pipeline( return builder +def _own_task_annotations(pipeline_fn: "PipelineFn", cfg: Any) -> dict[str, Any]: + declared = pipeline_fn.task_annotations + resolved = declared(cfg) if callable(declared) else declared + if not isinstance(resolved, Mapping): + raise CompileError( + f"@pipeline({pipeline_fn.name!r}) task_annotations must be a mapping or a " + f"function of cfg returning one, got {type(resolved).__name__}." + ) + return dict(resolved) + + def _trace_multi_output( builder: GraphBuilder, pipeline_fn: "PipelineFn", diff --git a/pyproject.toml b/pyproject.toml index 7f2890e..b32cbe6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "tangle-cli" -version = "0.1.35" +version = "0.1.36" 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 a8bc38d..3ff4f5e 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.35" in metadata + assert "Version: 0.1.36" 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/tests/test_task_annotation_defaults.py b/tests/test_task_annotation_defaults.py new file mode 100644 index 0000000..b634cbe --- /dev/null +++ b/tests/test_task_annotation_defaults.py @@ -0,0 +1,194 @@ +"""Default task annotations: ``@pipeline(task_annotations=...)`` and +``subpipeline(child).with_task_annotations(...)``.""" + +from __future__ import annotations + +import textwrap +from pathlib import Path + +import pytest +import yaml + +from tangle_cli.pipeline_compiler import compile_pipeline +from tangle_cli.python_pipeline import pipeline, subpipeline +from tangle_cli.python_pipeline.errors import CompileError + +_HEADER = """\ +from tangle_cli.python_pipeline import pipeline, ref, subpipeline + +op = ref(name="op") +""" + + +def _compile(tmp_path: Path, body: str, *, config: str | None = None, overrides=None) -> Path: + src = tmp_path / "src" + src.mkdir() + (src / "pipeline.py").write_text(_HEADER + textwrap.dedent(body), encoding="utf-8") + if config is not None: + (src / "config.yaml").write_text(config, encoding="utf-8") + out = tmp_path / "out" / "compiled.yaml" + compile_pipeline(src / "pipeline.py", out, overrides, pipeline_name="Root") + return out + + +def _tasks(path: Path) -> dict: + return yaml.safe_load(path.read_text(encoding="utf-8"))["implementation"]["graph"]["tasks"] + + +def _annotations(path: Path, task_id: str) -> dict | None: + return _tasks(path)[task_id].get("annotations") + + +def _child(parent: Path, task_id: str) -> Path: + url = _tasks(parent)[task_id]["componentRef"]["url"] + return (parent.parent / url.removeprefix("file://")).resolve() + + +def test_pipeline_defaults_reach_its_own_tasks_and_a_task_wins_per_key(tmp_path): + out = _compile( + tmp_path, + """ + @pipeline("Child") + def child(): + op.named("Child Task")() + + @pipeline("Root", task_annotations={"team": "root", "tier": "default"}) + def root(): + op.named("Plain")() + op.with_annotations({"tier": "task", "extra": "task"}).named("Annotated")() + subpipeline(child).named("Run Child")() + """, + ) + + assert _annotations(out, "Plain") == {"team": "root", "tier": "default"} + assert _annotations(out, "Annotated") == {"team": "root", "tier": "task", "extra": "task"} + assert _annotations(out, "Run Child") is None + assert _annotations(_child(out, "Run Child"), "Child Task") is None + + +def test_a_defaults_function_reads_the_resolved_config_without_a_cfg_parameter(tmp_path): + out = _compile( + tmp_path, + """ + @pipeline( + "Root", + config="config.yaml", + task_annotations=lambda cfg: {"account": cfg.service_account}, + ) + def root(): + op.named("Task")() + """, + config="service_account: base@example.com\n", + overrides={"service_account": "override@example.com"}, + ) + + assert _annotations(out, "Task") == {"account": "override@example.com"} + + +def test_call_site_defaults_reach_the_whole_subtree_and_the_nearest_wins(tmp_path): + out = _compile( + tmp_path, + """ + @pipeline("Grandchild") + def grandchild(): + op.named("GC Plain")() + op.with_annotations({"k": "task"}).named("GC Annotated")() + + @pipeline("Child", task_annotations={"k": "child-own", "own": "child-own"}) + def child(): + op.named("Child Task")() + subpipeline(grandchild).with_task_annotations({"k": "child-call"}).named("Run GC")() + + @pipeline("Root") + def root(): + subpipeline(child).with_task_annotations({"k": "root-call", "r": "root-call"}).named( + "Run Child" + )() + """, + ) + child = _child(out, "Run Child") + grandchild = _child(child, "Run GC") + + assert _annotations(out, "Run Child") is None + assert _annotations(child, "Child Task") == {"k": "root-call", "own": "child-own", "r": "root-call"} + assert _annotations(child, "Run GC") is None + assert _annotations(grandchild, "GC Plain") == {"k": "child-call", "r": "root-call"} + assert _annotations(grandchild, "GC Annotated") == {"k": "task", "r": "root-call"} + + +def test_a_child_shares_a_sidecar_only_with_calls_pushing_the_same_defaults(tmp_path): + out = _compile( + tmp_path, + """ + @pipeline("Child") + def child(): + op.named("Child Task")() + + @pipeline("Root") + def root(): + subpipeline(child).with_task_annotations({"env": "a"}).named("A")() + subpipeline(child).with_task_annotations({"env": "b"}).named("B")() + subpipeline(child).with_task_annotations({"env": "a"}).named("A Again")() + """, + ) + + assert _child(out, "A") == _child(out, "A Again") + assert _child(out, "A") != _child(out, "B") + assert _annotations(_child(out, "A"), "Child Task") == {"env": "a"} + assert _annotations(_child(out, "B"), "Child Task") == {"env": "b"} + + +def test_descendants_of_a_shared_child_split_by_the_defaults_pushed_above_them(tmp_path): + out = _compile( + tmp_path, + """ + @pipeline("Grandchild") + def grandchild(): + op.named("GC Task")() + + @pipeline("Child") + def child(): + subpipeline(grandchild).named("Run GC")() + + @pipeline("Root") + def root(): + subpipeline(child).with_task_annotations({"env": "a"}).named("A")() + subpipeline(child).with_task_annotations({"env": "b"}).named("B")() + """, + ) + grandchild_a = _child(_child(out, "A"), "Run GC") + grandchild_b = _child(_child(out, "B"), "Run GC") + + assert grandchild_a != grandchild_b + assert _annotations(grandchild_a, "GC Task") == {"env": "a"} + assert _annotations(grandchild_b, "GC Task") == {"env": "b"} + + +@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"): + _compile( + tmp_path, + f""" + @pipeline("Root", task_annotations={declared}) + def root(): + op.named("Task")() + """, + config="{}\n", + ) + + +@pytest.mark.parametrize( + ("ann", "message"), + [ + (lambda cfg: {"k": "v"}, "takes a mapping, got function"), + ({"k": Path("gs://bucket")}, "value for 'k' must be a string or another scalar"), + ], +) +def test_call_site_defaults_reject_what_cannot_key_a_sidecar(ann, message): + @pipeline("Child") + def child(): + pass + + with pytest.raises(CompileError, match=message): + subpipeline(child).with_task_annotations(ann) diff --git a/uv.lock b/uv.lock index 62c0be8..33320c6 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.35" +version = "0.1.36" source = { editable = "." } dependencies = [ { name = "cloud-pipelines" },