Skip to content

Add Python task conditional authoring (v0.1.8) - #49

Merged
Volv-G merged 3 commits into
masterfrom
piforge/tangle-conditionals-implementati/implement-is-enabled-conditional-45ca989
Aug 5, 2026
Merged

Add Python task conditional authoring (v0.1.8)#49
Volv-G merged 3 commits into
masterfrom
piforge/tangle-conditionals-implementati/implement-is-enabled-conditional-45ca989

Conversation

@Volv-G

@Volv-G Volv-G commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add first-class Python task metadata is_enabled=, serialized as canonical TaskSpec.isEnabled
  • support string constants, GraphInputPlaceholder, and TaskOutputProxy; normalize Python booleans to lowercase "true" / "false"
  • track task-output conditions as dependencies for validation, cycle detection, and layout
  • align runnable/dehydrated schemas with backend-supported condition forms and keep schema refreshes from reintroducing unsupported dynamicData
  • reject unsupported authoring values (including DynamicData, Raw, structured values, and None) before writing output
  • scope conditional execution to container-component tasks and document the component-input collision escape
  • add a runnable examples/python_pipeline/is_enabled_pipeline.py sample covering constant false, graph-input, and task-output conditions
  • bump tangle-cli from 0.1.7 to 0.1.8 across project metadata, runtime fallback, packaging expectations, and the lockfile

Python authoring contract

Pipeline/component inputs are not specially marked as conditions. Declare an ordinary runtime graph input and pass its placeholder through the reserved task-call metadata keyword:

@pipeline("Conditional greeting")
def conditional_greeting(enabled: In[str]) -> Out[str]:
    greeting = write_greeting(who="world", is_enabled=enabled)
    return greeting.out

This emits task metadata, not a component argument:

isEnabled:
  graphInput:
    inputName: enabled

Supported is_enabled= values are:

  • Python bool, normalized to the lowercase string "true" or "false"
  • string constants
  • ordinary In[...] graph-input placeholders
  • task outputs, for example is_enabled=gate.Output

If a component itself declares an input named is_enabled, bind that component argument separately with .bind(is_enabled=...); the bound value remains under arguments.is_enabled, while call-site is_enabled= remains task metadata. Conditional execution is container-task-only: subpipeline(...)(is_enabled=...) is rejected with guidance, while subpipeline(...).bind(is_enabled=...) remains available for a child graph input collision.

This intentionally does not add a condition alias.

Validation

  • uv run pytest -q830 passed, 4 existing NamedTuple deprecation warnings
  • focused changed tests — 24 passed
  • reviewer regression selection — 11 passed
  • git diff --check
  • uv lock --check
  • uv run pytest -q tests/test_packaging.py10 passed
  • editable CLI version checks — tangle version and tangle-cli version both reported 0.1.8
  • uv build and uv build --package tangle-api
  • release-workflow smoke coverage passed for the tangle-cli wheel/sdist entry points, tangle-api wheel/sdist integration, and the native compatibility extra
  • sample compile:
    uv run tangle sdk pipelines compile \
      examples/python_pipeline/is_enabled_pipeline.py \
      --pipeline conditional_pipeline \
      --output /tmp/tangle-is-enabled-demo/pipeline.yaml
    Result: compiled 4 tasks and wrote the pipeline plus component sidecar.
  • sample validation:
    uv run tangle sdk pipelines validate /tmp/tangle-is-enabled-demo/pipeline.yaml
    Result: Valid pipeline.

Assisted-By: devx/e2f15aca-0551-44f2-9864-894c04d43eba
@Volv-G
Volv-G requested a review from Ark-kun as a code owner August 5, 2026 22:42
Volv-G added 2 commits August 5, 2026 15:50
Assisted-By: devx/e2f15aca-0551-44f2-9864-894c04d43eba
Assisted-By: devx/e2f15aca-0551-44f2-9864-894c04d43eba
@Volv-G Volv-G changed the title Add Python task conditional authoring Add Python task conditional authoring (v0.1.8) Aug 5, 2026
@Volv-G
Volv-G merged commit 73f1f4d into master Aug 5, 2026
2 checks passed
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