Repository navigation
feat!: compiled CWL names steps as written - #541
Conversation
59601c2 to
e2ddd7c
Compare
darkclad
left a comment
There was a problem hiding this comment.
I reviewed this commit by commit, ran tests/core on head and base (Windows), and ran the needs_cwltool tests in WSL. On Windows, every failure on head is environmental (no cwltool, no docker) and matches base, except one new test that also needs cwltool. In WSL, all cwltool-runner tests pass; the 7 toil-cwl-runner cases fail only because Docker is not running there to prepull.
The naming table, the flat <root>~<address>.cwl layout, wic045, .wic default resolution and the shared run_setup.prepare read correctly to me. Two inline notes, neither blocking: compile-time $schemas fetching during packing, and a pre-existing --docker_remove_entrypoints ordering issue that now lives in prepare.
mm-workflows#268 has the right step positions for the new spelling. Separately, mm-workflows src/vis/utils.py still parses <stem>__step__<n>__<id>. It does not raise on the new names, but the viewer's tree will no longer group outputs by step.
|
|
||
| _register_extensions() | ||
| try: | ||
| loading = cwltool.context.LoadingContext({'fetcher_constructor': _Serving}) |
There was a problem hiding this comment.
Packing a tool loads its $schemas too, so a tool with a relative $include and a remote ontology now fetches that ontology at compile time. I checked with a dockerFile: {$include: Dockerfile} tool that lists GitHub's EDAM_dev.owl: packed() took 4.1 s, and an unreachable schema host only printed Could not load extension schema warnings. On a cluster whose firewall drops packets instead of refusing them, it would wait for the connection timeout. That is the cost --skip-schemas avoids at run time (run_local.py:164).
Adding 'skip_schemas': True to this LoadingContext gave the same packed tool in my run: $schemas was kept as written and the Dockerfile was inlined, with no fetch. In mm-workflows only extract_pdbbind_refined.cwl has both a relative reference and $schemas, so few tools hit this today. Not blocking.
There was a problem hiding this comment.
Agreed. Packing loaded the tool's $schemas and fetched remote ontologies at compile time, which is the cost --skip-schemas avoids at run time. The packing LoadingContext now sets skip_schemas, so $schemas are resolved against the tool and nothing is fetched. A test pins it: packing a tool that lists a remote schema never asks the fetcher for it, and the $schemas entry is preserved.
Fixed in 6fd4aa3.
| return Prepared(artifact, plans, documents) | ||
| # The real-time analyses' images too: they run with --disable-pull. | ||
| preflight.prepare(list(documents), settings.run, jobs) | ||
| if settings.remove_entrypoints: |
There was a problem hiding this comment.
Follow-up, not from this PR: the artifact returned here has -noentrypoint tags, but the run reads <basepath>/<name>.cwl, which line 63 wrote before this rewrite. So --docker_remove_entrypoints builds the no-entrypoint images while the workflow still runs the original tags. The old main.py had the same order ("No need to re-write to disk"). For run(), the artifact is now one inlined document, and dockerPull_append_noentrypoint only reads the root's own requirements, so the embedded tools would be missed even if it were rewritten. Since prepare is now the one shared path, it seems the right place to write after the rewrite, or to rewrite before line 63.
There was a problem hiding this comment.
Fixed in #542, stacked on this PR: prepare writes the CWL again after the rename, and the rename now covers hints and every embedded tool. Digest-pinned images are left as they are.
|
Thanks for the commit-by-commit pass and the Windows/WSL runs. The compile-time $schemas fetch is fixed in this PR: packing now skips schemas, with a test. The --docker_remove_entrypoints ordering is pre-existing and needs a change to how embedded tools in the inlined artifact are rewritten, so I'm leaving it for a follow-up rather than widening this PR. The mm-workflows src/vis/utils.py still parsing step__ is in another repo; I'll handle the viewer's step grouping there separately. Fixed in 6fd4aa3. |
cf1d796 to
963391e
Compare
963391e to
cb00cfe
Compare
|
I folded one more fix into commit 3 ( The |
darkclad
left a comment
There was a problem hiding this comment.
Round 2: I range-diffed cb00cfe9 against my round-1 head e2ddd7c1 (base 082d209f unchanged). Commits 2, 5 and 6 are unchanged, and commit 7's changes are docs.
dd944218 sets skip_schemas on the packing LoadingContext, which resolves my round-1 note, and test_packing_does_not_fetch_a_tools_schemas pins it. Moving the --docker_remove_entrypoints ordering to #542 and the viewer grouping to mm-workflows#268 is fine by me.
Dropping sophios:lang_version and the sophios prefix in 07605d0f is clean: no ANNOTATION_* reader is left, flatten_subworkflows and inline_artifact_runs now carry $namespaces up and drop it when empty, and test_metadata_emitted.py checks all four forms. On Windows tests/core fails the same 70 environmental tests (no cwltool, no docker) at this head and at e2ddd7c1, with 9 more passing here.
One issue inline: binding edam only where a format says edam: misses a File default:, which cwltool then rejects at run time. Since that worked before this round, I'd like it fixed here. Two small notes on the spec and a test.
|
|
||
| The job counts because a runner reads its CURIEs against the workflow's `$namespaces`. | ||
| """ | ||
| formats = [port.declaration.format for port in (*graph.workflow_inputs, *graph.workflow_outputs) |
There was a problem hiding this comment.
_uses_edam reads format from port declarations and job Files, but not from a default:. inputs: {f: {type: File, default: {class: File, location: x.txt, format: edam:format_2330}}} and a step's !cwl {default: <same File>} both compile at this head with no $namespaces, while edam:format_2330 stays in the document. In WSL, cwltool then warns URI prefix 'edam' of 'edam:format_2330' not recognized, reads the format as file:///.../wf.cwl#f/format_2330, and fails a step whose tool wants edam:format_2330 with File has an incompatible format (permanentFail). The same workflow with edam bound succeeds, and before 07605d0f edam was always bound. Running _job_formats over each port's declaration.default and each step-input record's default would cover both. The mm-workflows .wic files I checked put their edam: formats on declarations, so nothing there hits this today.
There was a problem hiding this comment.
You're right. A File default: with an edam: format kept the CURIE but got no $namespaces. _uses_edam now also reads the formats in each port's declared default and in a step-input record's default. I added two cases to the existing parametrised test, one for an input default and one for !cwl {default: ...}. Both fail without the change.
Fixed in 53e0496.
| `test_the_sophios_namespace_prefix_is_reserved`, and in `test_emit.py` by | ||
| into subworkflows. Pinned by | ||
| `test_user_namespaces_survive_and_edam_is_edams_where_a_format_says_it`, | ||
| `test_the_sophios_prefix_is_the_authors_to_bind`, the tests of |
There was a problem hiding this comment.
test_the_sophios_prefix_is_the_authors_to_bind does not exist in this PR: test_the_sophios_namespace_prefix_is_reserved was deleted and nothing replaced it. So nothing pins that an author's own sophios binding now survives; test_metadata_emitted.py only checks the compiler adds none. Adding that test, or dropping the name here, would fix it.
There was a problem hiding this comment.
I dropped the name from the spec instead of adding the test. The compiler no longer treats sophios as special, so an author binding it is the same case as mine in test_user_namespaces_survive_and_edam_is_edams_where_a_format_says_it.
Fixed in 9f9ffeb.
| assert ANNOTATION_KEY not in compiled.cwl_workflow | ||
|
|
||
|
|
||
| @pytest.mark.skip_pypi_ci |
There was a problem hiding this comment.
Nit: @pytest.mark.skip_pypi_ci is now applied twice to test_a_pinned_file_reports_its_version_and_writes_plain_cwl.
There was a problem hiding this comment.
Fixed, the duplicate mark is removed.
Fixed in 53e0496.
|
Thanks. The File-default case is fixed: |
93fadfe to
875a0be
Compare
darkclad
left a comment
There was a problem hiding this comment.
LGTM at 875a0be2.
Range-diffed against cb00cfe9: only commits 3 and 7 changed. _uses_edam now also reads a port's declared default and a !cwl {default: ...} record, and both of my round-2 probes now bind edam. With those two added lines removed, the new input-default-format and step-input-default-format cases fail, so they pin it. The spec no longer names the missing test, and the duplicate mark is gone. On Windows tests/core fails the same 70 environmental tests (no cwltool, no docker) as at cb00cfe9, with 2 more passing.
Non-blocking: the edam rule in docs/compiling-to-cwl.md (line 324) and docs/dev/language_spec.md (line 166) still lists only ports and job Files; it could also mention a default:.
875a0be to
9f9ffeb
Compare
|
Thanks. Both pages now list a File in an input's or a step input's Fixed in 9f9ffeb. |
Steps keep their ids (a repeated or clashing one gets @<index>), derived names join with ~, and every document is written beside its root as <root>~<address>.cwl; only the root gets a job. Until mm-workflows#268 merges, CI compiles mm-workflows from it.
A step id, workflow input or output, or workflow name is refused (wic045, or ValueError in Python) when it could break a made name, a file or a run: path. A when: note now reads a call's made names as compiled.
No EDAM $schemas of our own; a relative default is resolved against its .wic, or the working directory in Python; a location is a file:// URI. Nor any metadata of our own: no sophios:lang_version key or sophios prefix, and edam only where a format says edam:.
We pack a tool that refers to files beside it with cwltool when its step is emitted, so the written copy runs wherever it lands. This replaces the Dockerfile $include prepend. Packing resolves $schemas but fetches none.
The command line and run() now share one run path, run_setup.prepare. run() runs the document compile() returns, declared outputs only, and writes its analyses as one document each. --no_provenance is honoured.
Loading a tool no longer adds stdout: <tool>.out and stderr: <tool>.err under --quiet, which sent its messages to files the run deleted. --quiet now only passes cwltool --quiet; a tool's messages print as it runs.
We document the ~ and @ names, the tree beside its root, packed tools and resolved defaults, run() running compile()'s document, what --quiet does and --no_provenance, with the upgrade notes in the CHANGELOG.
9f9ffeb to
11deb67
Compare
This PR changes what Sophios writes when it compiles a workflow to CWL, and makes every way of running a workflow run exactly that output. There are three changes:
sophios --run_localand PythonWorkflow.run()both run the document thatcompile()shows.The compiled output breaks on purpose, hence
feat!. Inputs files, output keys and scripts written against the old names need updating. The list is under What breaks, and the CHANGELOG has the full upgrade notes.1. Names: the CWL says what you wrote
Take the three-step
greeting.wicfrom the docs:touch, thenappend, thencat. Today it compiles to:With this PR:
The same names also appear in the runner's messages, the job file and
output_<workflow>.json. The rules:make_greeting.wicbecomes the stepmake_greeting, without.wic.@and its position on every copy, the first one included.appendsteps at positions 2 and 3 becomeappend@2andappend@3.nthat.wic(n, id)addressing already uses.~.touch'sfilenameistouch~filename.make_greeting, it ismake_greeting~touch~file.[A-Za-z0-9_.-], and may not start with...wicthat breaks this gets the new wic045 at the offending line. In Python it is aValueError.~and@free, so a made name can never collide with a written one.run:path.Why
~:.reads as Python attribute access and breaks$(inputs.x).>is not a URI character, so->breaks cwltool's--print-dotand--provenance. One cost: GitHub Markdown renders text between two~as strikethrough, so the docs always put these names in code spans.Deleted along with the old names:
<workflow>__step__<n>__<id>in a.wic, for example inoutputSource:.type:it is wic036.(n, id)when the id repeats.AuthoredNamesFilterandautogenerated/<workflow>.names.json. A run used to rewrite cwltool's log messages to translate the generated ids back to the written ones. The runner's messages now already use the written names, so there is nothing to translate.2. Files: one flat directory, only what authors wrote
Before:
After:
The layout:
<root>~<address>.cwl. A step inside a subworkflow is written asnested~make_greeting~touch.cwl.run:is therefore a plain sibling file name.<tool>_inputs.ymlbeside each tool is no longer written; nothing was ever bound to a tool directly.realtime/<workflow>/.What used to depend on where a file landed:
autogenerated/broke every relative$include,$import, or relativelocation/path(such as adefault:).file://URI.dockerFile$includepath..wicdefault:..wic's own directory and written absolute.StepInput(default=...)is resolved against the working directory, the same way a bound value is.$schemas. That entry is deleted..wicor an embedded tool already listed anEDAM_dev.owlfrom somewhere else, such as GitHubmainor a local copy on an offline cluster.Conflicting basename in listing or secondaryFiles, 'EDAM_dev.owl' used by both ....$schemasnow holds only what authors wrote.Sophios's own metadata. Every root also carried a
sophios:lang_versionkey under asophiosprefix, and anedamprefix, whether the workflow used them or not. No runner reads them, so they are gone. The compile still prints the language version and Python still hasCompiledWorkflow.lang_version;edamis declared only where a format saysedam:.3. Running: you run what you compiled
Python
run()Workflow.compile()returned a document with only the workflow's declared outputs.Workflow.run()ran a different document, one that exposed every step's outputs, and also wrote a file for each tool beside it. The command line prepared its runs with separate code.run()share one function,run_setup.prepare.run()runs exactly the documentcompile()returns. If the workflow declares outputs, only those come back; to read one step's output, name it as a workflow output.--no_provenance--provenance. In Python, passrun_args_dict={'no_provenance': 'yes'}.--quietstdout: <tool>.outandstderr: <tool>.errto each tool, and the run deleted those files. So--quietchanged the compiled CWL, and a quiet failure left nothing to read.--quietonly passes cwltool's--quiet, and the compiled CWL is the same with or without it. A tool's own messages print as the run goes, and a failure line names the step and its exit status.What breaks
greeting__step__1__touch___filenamebecomestouch~filename.output_<workflow>.json: they change the same way.<generated step id>/<tool>.cwlbecomes<workflow>~<step>.cwl..wicthat names a step as<workflow>__step__<n>__<id>: write the id, or(n, id).[A-Za-z0-9_.-]: rename it (wic045).--cwl_inline_subworkflows: it names a dissolved call's steps<call>~<step>.when:on a subworkflow call that reads a made name: write it in brackets,$(inputs["touch~filename"]), because~is not allowed ininputs.<name>.Known gaps
docs/running.mdsays to pass--no_provenance.Reviewing
Each commit is self-contained, and reading them in order is easier than reading the whole diff. Most of the 98 files are tests (about 2.2k added lines) and docs (about 0.6k). The source change is about +780/−600 lines across 29 files.
feat!: compiled CWL names steps as written: the names and the flat tree (ir/names.py,ir/emit.py,compiler.py,input_output.py). Deletes the old reader and the names filter. CI checks out mm-workflows from add --generate_config flag #268 there until it merges (below).feat(lang): refuse names outside [A-Za-z0-9_.-]: wic045 (lang/names.py,lang/parser.py) and the PythonValueError.fix: CWL depends only on its authors' files: no EDAM$schemas, nosophioskey or prefix,edamonly where a format uses it, and.wicdefaults resolved (ir/locations.py,ir/lower.py,ir/emit.py).fix: copied tools keep their relative files: packing at emission (utils_cwl.py,compiler.py) and wic013.feat: run executes exactly what compile writes:run_setup.py,_workflow_runtime.py,main.py, and--no_provenance.fix: --quiet leaves the compiled CWL alone: deletes the captureplugins.pyadded at compile time.docs: compiled CWL names and one-directory tree: the docs and the CHANGELOG.Merge order
This does not wait for NovagenResearch/mm-workflows#268, which moves
setup_pdbanddownload_smiles_ligand_dboff the old spelling. Until it merges, CI checks out mm-workflows atrefs/pull/268/headwherever it usedmain: the branch-dispatch fallbacks and the weekly, macOS and benchmark lanes. Once it merges, they go back tomain.