Repository navigation
chore(nextflow): rebase the backend onto master - #536
Conversation
A note tells the reader about a choice the compiler made that is not wrong; it is collected with the errors but does not count as one.
…strict makes it an error Inference picks the most recent producer and, within it, the last declared output. When another output of that producer also matched (wic042) or an earlier producer did (wic043), the choice was made without a word. Each such choice is now a note naming the alternatives and the !&/!* pin that makes it explicit; the choice itself is unchanged. The CLI prints the notes on stderr, CompiledWorkflow carries them in `diagnostics`, and --inference_strict turns them into errors.
A scatter splits a list. A scalar literal on a scattered input was wrapped into a one-element list by the same array layer that a declared array type adds, so the scatter silently ran once. It is now rejected with the fix: write a list, or drop the port from scatter:. BREAKING CHANGE: scatter: [x] with x: !ii scalar is rejected; write a list.
The edge-inference steps now say what happens between equal candidates: the choice is unchanged, wic042/wic043 name it, --inference_strict refuses it, and a !&/!* pin settles it. A scattered input's literal is a list.
A subworkflow call exposes its steps' ports under derived names that no author can write, so a note that shortened them to the last part told the reader to anchor a port the call does not declare (wic028), and listed alternatives that read the same. The note now shows each port by the path of steps down to the one that declares it, and puts the pin on that inner step; writing the pin exactly as given compiles without a note.
The pin goes on the inner steps that declare the two ports; min.wic's steep.wic/mdrun to cg.wic/grompp edge is the worked example.
Each CLI test imported sophios.main inside its body; one module-level import serves them all.
scatter_rank took it to six parameters; _coerce_type beside it already carries the same disable.
A step id may repeat, so the chosen source and an alternative could print the same text and a pin could point at either. Every step in a note, including the inner steps of a subworkflow call, now reads "step N 'id'", the way the locator already does.
…aryFiles, stdout and list forms Every synthetic port was an atom, File[] or a two-atom union, so no property ever reached a record, an enum, a SchemaDefRequirement type, secondaryFiles with loadContents, a captured stdout or cwl_utils' list forms. Five new stems cover them and the registry test names each. The validation property now creates the files a job names and the secondary files their inputs declare, since cwltool reads a file for an input with loadContents and looks for each secondary file. It leaves out `schemed`: a promoted input whose type names a SchemaDefRequirement type reaches the workflow without the requirement that defines it, which cwltool rejects. A fast test pins that gap so the exclusion goes when it closes.
A record, enum or named schema type drew any scalar, which cwltool then rejects as a job value. The literal strategy now draws a record's fields, an enum's symbols and an array's items by their own types. A reference into a structured port comes only from an `Any` input, since the compiler is unsure there and cwltool refuses every scalar source, and a `stdout` output carries a File, as the compiler reads it.
…er are pinned Sorting the scatter ports, ignoring the naming conventions, and emitting workflow inputs in arbitrary order each left every fast test green. One fast test per behaviour now fails under each of those mutants.
The tripwire asserted the compiler's invalid output, a workflow input typed by an undefined SchemaDefRequirement name, as if it were expected. I replace it with a strict xfail that runs the same cwltool validation the property uses on a `schemed` workflow: it fails today for the real reason, and turns into an error once the gap closes, so the property's exclusion goes with it.
The embedded tool's own bare type reference stops resolving to its SchemaDefRequirement once the run is inlined, in addition to the promoted input losing the requirement. The reason now says both, so a fix for one half is not mistaken for the whole gap.
The default is the compiled workflow and its job file under autogenerated/, as before.
With --allow_raw_cwl, a --yaml file that is a plain CWL workflow (cwlVersion and class: Workflow, or a packed main Workflow, and no Sophios syntax) is not parsed or compiled. --run_local and --generate_run_script give the runner that file, with --inputs_file as its job; --generate_cwl_workflow writes nothing. The flags that rewrite compiled CWL are a usage error with such a file. Every other input compiles exactly as before. Twelve CWL v1.2 conformance workflows are vendored under tests/core/data/cwl-v1.2 and run both through Sophios and through cwltool directly; the results must agree.
The flag's paragraph defined only the UnresolvedName reinterpretation that is headed for deprecation. Pass-through of a plain CWL workflow is a separate behaviour, so I say so there and note that retiring the first does not retire the second.
Apache 2.0 section 4(a) asks that redistributed files carry a copy of the License; a pointer to upstream does not.
argparse accepted any unambiguous prefix, so cwltool's --validate, passed through to the runner, was taken as Sophios' --validate_plugins and never reached cwltool.
The abbreviated-flag test sat between three blank lines above and one below, which fails the PEP8 lint step. Two on each side.
…g methods A port is bound and read through its object (step.inputs.x = ..., step.outputs.x, workflow.outputs.x = ...). The string-keyed methods let a name typed as text bypass that, so I made them private and removed add_input; WorkflowInputReference.as_type declares the input itself. BREAKING CHANGE: add_input, bind_input, get_output, bind_output, add_output are gone from the public API; use the port objects.
from_input always emitted $(inputs.<name>.basename), which is wrong for a string input. The glob is now written as the CWL expression it is; the examples and docs spell out the basename glob they emitted before, so the generated tools are unchanged. BREAKING CHANGE: write the glob as a CWL expression, e.g. glob="$(inputs.output.basename)" for a File or Directory input, glob="$(inputs.output)" for a string one.
…mport-linter contracts The api, compiler, ir and lang packages import only downward, and the public workflow and tool_builder modules never import the compiler, IR, plugins, CLI or runner directly; they reach them through the private runtime adapters.
…yped declaration The warning told users to write workflow.inputs.name = ..., which binds an inline value instead of declaring or referencing the input. It now points at workflow.inputs.name and workflow.inputs.name.as_type(...). Binding a workflow output to an input reference also passes the reference's implicit flag through, so the canonical workflow.outputs.o = workflow.inputs.x no longer warns. The changelog names as_type as the replacement for add_input.
…d names write_wic() now writes the root .wic, one .wic per nested workflow and one .cwl per distinct tool into one directory. Workflow outputs name the step as the user named it, and a step named apart from its tool carries run: <stem>.cwl, so the written document compiles under any file name and no longer provokes the generated-name warning. Workflow.yaml is the projection of that same document. Two different tools sharing a file stem are rejected, because a document names a tool by its stem. BREAKING CHANGE: write_wic()/to_wic_yaml() take no inline_subworkflows; the subtree: form is gone; a renamed step carries run: <stem>.cwl.
The property now compiles the written bundle through the file door, so a renamed step's run: resolves beside the document, and draws renamed steps. The nested arm is built but drawn off until a nested workflow's output can feed a sibling step.
I describe the bundle write_wic writes, when a step carries run:, and how the CLI finds the bundle's files; the reference drops the inline subtree: form and its exception to the parse obligation.
…rites Every step now carries run: <stem>.cwl, so the written bundle compiles from disk without the tool on a search path. A tool whose file is already in the target directory is left alone, a different file under the same stem is an error before anything is written, and the docs say that files a tool imports are not copied.
… parent output Every workflow-owned output was refused as a binding source, so a nested workflow's results could feed neither a later sibling step nor the parent's own outputs. A nested workflow's output now binds like a step's: the call step writes the anchor in its out: and the parent's outputSource names the call step. A workflow's own output feeding one of its own steps, or backing another of its outputs, is still refused, now at validation and with a message that says it is the workflow's own output rather than "not a child".
Workflow.run_async() prepares in a worker thread, awaits the runner without blocking the loop, and stops it when its task is cancelled. It refuses real-time analyses with api008. aiofiles goes with run_local_async.
We show what run() returns, how to start a run and follow it, its states, run_async from asyncio, api008, and the 0.7.0 upgrade steps.
Workflow.run() starts the run through run_local.start, so the stubs on run_local.run stopped nothing: the tests ran cwltool for real, and the no-run assertion in _missing_paths could not fail. I patch start with an ended run, as the neighbouring tests do.
1db78ed to
c351892
Compare
An untagged value that names no workflow input is one error that says what to write. The second line told users to compile anyway, contradicting --explain wic011 and the docs.
The README, the docs landing page and the package summary open with the definition: a workflow compiler, Python or .wic in, its own model and checks, CWL as today's backend. The story that justifies it follows.
Brings master into the Nextflow backend branch, compiled CWL names included. Conflicts resolved with master's side, and the backend's additions on top: - cli.py: master's parser with each option declared under the target it belongs to, plus --target and validate_target_args; --quiet and --graph_label_stepname take master's help. The parser's options (option string, default, help, choices) equal master's plus --target. - main.py: master's main()/_main(); the target check after parsing, and --target nextflow lowers and writes after compiling. - workflow.py: master's imports, __all__, compile(inference=), run(), start() and run_async() beside the compile(target=...) overloads and to_nextflow. - _workflow_runtime.py: master's imports (backends, run_local, run_setup, run_status, CompilationArtifact, absolute_paths, CwlRecord, LangStep, SophiosErrorCode) and its run path beside the Nextflow imports and nextflow_workflow/write_nextflow_workflow. - _ports.py: master's effective_source_type, which lifts a scattered source per layer and covers the branch's scattered-output rule. - docs: master replaced index.rst and python_api_reference.rst, so both are deleted; the Nextflow page sits in index.md and pdf_index.rst under Concepts, and python-api-reference.rst documents sophios.api.python.nextflow, and the workflow module's members as master lists them, run handle and run status included, with ExecutableNextflowWorkflow excluded. - build_wheel.yml, test_and_publish_pypi.yml: the package lanes deselect -m "not skip_pypi_ci and not nextflow" beside master's -k filter. - test_ci_coverage.py: the package-lane guard collects through master's batched _collect_all.
- import_nextflow wires the workflow it builds through port objects (`workflow.inputs.x.as_type(...)`, `step.inputs.x = ...`, `workflow.outputs.x = ...`): master removed add_input, add_output, bind_input and get_output. - The capability test that compiles a hand-edited document calls master's compile_source(bundle, options, testing=...), workflow_document(workflow) and _merged_known_tools(workflow); master's compiler takes no graph arguments and utils_graphs is gone. - The import test reads an input's source with source_outputs().
touch.cwl runs in docker.io/library/debian:bookworm-slim on this branch: the engine diagnostic names that image, and --docker_remove_entrypoints writes its -noentrypoint tag.
The guide includes touch.cwl, which names docker.io/library/debian:bookworm-slim on this branch; the prose and the sample log name the same image.
…low path Master has Workflow.compile(inference=) and a target-neutral --basepath. compile(target="nextflow") and to_nextflow() take the same inference=, and the Nextflow lowering connects an unbound input with the edge the CWL compile infers under the same Inference. --target nextflow writes the four files under the base path. The CLI reference lists --target and the Nextflow page names the base path.
Master spells compiled steps as written: a repeated id carries @<position>, and a made name joins step and port with '~' (touch~filename, child~inner_copy). The backend keeps its rule: characters Nextflow does not allow become '_'. - A defaulted input's parameter is made the same way, <step>~<port>, then normalized. It and the workflow inputs are normalized together, so a collision names both sources as written, not the normalized name. - Step ids that normalize alike (touch@2 and touch_2) are a capability finding naming both, before the IR's duplicate-process check. - Tests read the new names; a synthetic workflow that repeated a step id writes GATED@1 and GATED@2, as the compiler does. - docs/nextflow.md says how names derive from step ids.
… --target cwl --passthrough_flags is a CWL-only option, which --target nextflow rejects. Under --target nextflow an unknown argument is a plain usage error.
…clares
A process is named by its bare step id, so it can meet the workflow's
own name or a name Nextflow declares in every script. Nextflow then
refuses the script ('`file` is already declared'), or the script reads
the process in place of params, Channel or a class such as Math.
- A process or workflow name gains a leading '_' when every script
declares it: the members of nf-lang's ScriptDsl (file, files, print,
error, tuple, exit, env, sendMail, sleep, record, channel, log, ...)
and params and main. Ports and parameters keep these names, which
Nextflow accepts for a variable.
- The rule for names the script resolves (task, log, channel, and a
capitalized name, which Groovy reads as a class) covers process and
workflow names too.
- A workflow named like one of its steps gains a leading '_', so a
.wic whose only step shares its stem lowers and runs.
- The IR refuses a process or workflow named like a declared name and a
workflow name that is also a process name, so a hydrated model cannot
render such a script.
- docs/nextflow.md lists the escapes.
Master's step-input record lets a step input take several sources (with linkMerge or pickValue) and bind an input its tool does not declare, as when.wic and record.wic in the cookbook do. Neither has a lowering, and both failed without a named finding: a source list stopped the projection with a PortId repr, and a step-only input read by a when was reported as unbound. - Capability analysis names a step input with more than one source, at any nesting depth, before the projection joins one source per input; a projection that fails after such a finding reports it. - A step input the step's tool does not declare is a finding of its own, so lowering never reaches the when check with it. - docs/nextflow.md says both are rejected.
The compiler joins a calling step and an inner step with '~' and marks a repeated id with '@<position>'; the backend normalizes that id, and a collision names both ids as written.
…arget nextflow The pass-through that uses a plain CWL workflow as it is ran before the target was read, so under --target nextflow it asked for --generate_cwl_workflow, --check or --run_local, all of which that target refuses. The pass-through is a CWL-target mode; under --target nextflow the file is compiled and lowered like any workflow. The --allow_raw_cwl help, cli-reference and steps-and-tools say so.
…ence=) infers The parametrized inference test reads back the nextflow_workflow.json that Workflow.to_nextflow writes beside compile(target="nextflow"), so dropping inference= at either call on the to_nextflow path fails it.
Under --target nextflow the four Nextflow files go under --basepath, as cli-reference says; the argparse help says it too.
touch.cwl runs in docker.io/library/debian:bookworm-slim on this branch, so the --docker_remove_entrypoints run names that image's -noentrypoint tag.
c351892 to
c98c5e7
Compare
darkclad
left a comment
There was a problem hiding this comment.
Reviewed the merge resolution and the reconcile commits on top. The parser's options equal master's plus --target, every backend file survives (the two renamed docs carry their entries), and the naming, raw-CWL and passthrough-hint changes read correctly. The core suite on Windows matches master outside tests/core/nextflow, whose failures here are only the missing Nextflow executable; the Nextflow Backend lane covers them and passes. One small doc nit inline.
| you use Podman or Singularity, name it with `--container_engine podman` or | ||
| `--container_engine singularity`. | ||
|
|
||
| ### `error [wic037] docker could not pull docker.io/bash:4.4 (...)` |
There was a problem hiding this comment.
Nit: this branch moves touch.cwl and cat.cwl to docker.io/library/debian:bookworm-slim, and first-workflow.md now names that image. A reader who hits this error on their first workflow will see bookworm-slim here, not bash:4.4, so this heading and the sample line below could name it too.
There was a problem hiding this comment.
Fixed in 8a1d1f9: the heading and the sample line name docker.io/library/debian:bookworm-slim.
touch.cwl and cat.cwl pull docker.io/library/debian:bookworm-slim, the image first-workflow.md names, so the troubleshooting heading and sample message name it too.
What
cli.py: master's parser, with each option declared under the target it belongs to, plus--targetandvalidate_target_args. The parser's options equal master's plus--target.main.py: master'smain()/_main(). The target check runs after parsing, and--target nextflowlowers and writes after compiling.workflow.py,_workflow_runtime.py: master's imports,__all__,compile(inference=)and its run path (run(),start(),run_async()) besidecompile(target=...)andto_nextflow. Master'sbackends.py,run_local.pyandrun_status.pyare unchanged here.index.md,pdf_index.rstandpython-api-reference.rstlist the Nextflow page and module.skip_pypi_ciandnextflow.import_nextflowbuilds its workflow through port objects.touch.cwlandcat.cwlrun indocker.io/library/debian:bookworm-slimon this branch. Master's tests,docs/first-workflow.mdand the wic037 sample indocs/install.mdname that image.compile(target="nextflow", inference=),to_nextflow(inference=)and--basepathreach the Nextflow path.<step>~<port>, with characters Nextflow does not allow turned into_. Two names that become the same are a finding naming both. Names that a script or Nextflow already declares get a leading_. The design states the rule, anddocs/nextflow.mdhas a Names section.--allow_raw_cwlon a plain CWL workflow lowers under--target nextflow, and an unknown argument names--passthrough_flagsonly under--target cwl.Why
The backend branch tracks master, so master's Sophios features, including #541's names, are what the backend is built against.
Merge this with a merge commit, as #469 and #434 were: a squash would drop master from the branch's ancestry.
The mypy pre-commit hook reports errors in master's own
lang/parser.py,utils_cwl.pyandtest_python_api_inference.py. Master fails the same hook on them, so these commits skip only that hook. CI's mypy step is the check.