feat(pipeline-run): fall back to file stem for a nameless submit spec#33
feat(pipeline-run): fall back to file stem for a nameless submit spec#33Silin144 wants to merge 1 commit into
Conversation
A file-based submit whose spec omits a usable top-level `name` is now resolved to the source-file stem before submit-time validation runs, rather than being rejected outright. This restores the long-standing downstream behavior where `submit my_pipeline.yaml` runs under the name `my_pipeline` when the spec itself declares no name. The fallback is applied at the single shared submit chokepoint (`PipelineRunManager.prepare_submit_payload_from_spec`) and in the higher-level `PipelineRunner.prepare_pipeline_for_run` (which validates first in the full run lifecycle), via a small shared helper `_resolve_fallback_pipeline_name`. A declared non-empty `name` always wins; only the genuinely-nameless case is filled, so specs that are malformed for any other reason (missing/!object `implementation`, etc.) still fail validation exactly as before. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| if not isinstance(pipeline_spec, dict): | ||
| return pipeline_spec | ||
| name = pipeline_spec.get("name") | ||
| if isinstance(name, str) and name: |
There was a problem hiding this comment.
(AI-assisted) [nit] A whitespace-only declared name skips the fallback. isinstance(name, str) and name treats " " as a valid declared name, so a blank-ish name is kept and the file-stem fallback isn't applied. Matches the literal "non-empty" contract, but a whitespace-only name arguably should also fall back to the stem (name.strip()). Trivial.
Volv-G
left a comment
There was a problem hiding this comment.
(AI-assisted) Correct resolve-then-validate approach — injects the file-stem fallback into the spec and keeps validation strict rather than loosening the schema. Verified the shared _resolve_fallback_pipeline_name on PipelineRunManager is reached from both submit paths (PipelineRunner inherits it), and declared-name-wins vs stem-fallback are both tested end-to-end. One trivial nit inline (whitespace-only name). LGTM.
What
Relaxes OSS submit-time validation so a pipeline spec with no declared
namefalls back to the pipeline file stem instead of hard-failing withname must be a non-empty string. A declared, non-emptynamealways wins; only the genuinely-nameless case is filled.This restores the long-standing tangle-deploy behaviour (submitting
my_pipeline.yamlwith nonameproduces a run namedmy_pipeline) after submit-time validation was consolidated upstream (#28/#30).Approach — resolve-then-validate
Rather than loosening the schema (which would let genuinely-invalid specs through), the fallback name is resolved into the spec first, and then the fully-resolved spec is validated. Everything else stays strict.
A single shared helper does the resolution:
It is wired into both submit code paths so OSS CLI and downstream (tangle-deploy) submits behave identically:
PipelineRunner.prepare_pipeline_for_run(pipeline_runner.py) — validates first in the run lifecycle; passes the hook-resolvedpipeline_name(which already honours anyinitial_pipeline_nameoverride) so it can't reject a nameless-but-otherwise-valid spec before path 2.PipelineRunManager.prepare_submit_payload_from_spec(pipeline_run_manager.py) — the shared submit chokepoint; resolves afterapply_run_name_template, before validation.The run name flows from the spec's
name(root_task.componentRef.spec.name), so injectingnameinto the spec is the correct mechanism — the resulting run is named after the stem.Worked example
my_pipeline.yaml:tangle pipeline-runs submit my_pipeline.yaml --no-hydrate→ submitted specname="my_pipeline"(file stem). If the file instead declaresname: Demo Pipeline, the run is namedDemo Pipeline(declared name wins over theconfigstem).Changes
pipeline_run_manager.py— shared_resolve_fallback_pipeline_namehelper + resolve step in the submit chokepoint.pipeline_runner.py— resolve step before first-path validation.tests/test_pipeline_runs_cli.py— two tests: stem fallback when nameless, and declared-name-wins-over-stem.Testing
ruffclean.🤖 Generated with Claude Code