Skip to content

feat!: compiled CWL names steps as written - #541

Merged
vjaganat90 merged 7 commits into
PolusAI:masterfrom
vjaganat90:feat/authored-cwl-names
Oct 21, 2026
Merged

vjaganat90 merged 7 commits into
PolusAI:masterfrom
vjaganat90:feat/authored-cwl-names

Conversation

@vjaganat90

@vjaganat90 vjaganat90 commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

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:

  1. Names. The compiled CWL uses the names you wrote, not names the compiler generated.
  2. Files. The compiled files sit in one flat directory, depend only on files their authors wrote, not on where Sophios happened to copy a tool, and carry nothing of Sophios's own.
  3. Running. sophios --run_local and Python Workflow.run() both run the document that compile() 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.wic from the docs: touch, then append, then cat. Today it compiles to:

steps:
- id: greeting__step__1__touch
  in:
    filename:
      source: greeting__step__1__touch___filename
  run: greeting__step__1__touch/touch.cwl
- id: greeting__step__2__append
  in:
    file:
      source: greeting__step__1__touch/file
  run: greeting__step__2__append/append.cwl

With this PR:

steps:
- id: touch
  in:
    filename:
      source: touch~filename
  run: greeting~touch.cwl
- id: append
  in:
    file:
      source: touch/file
  run: greeting~append.cwl

The same names also appear in the runner's messages, the job file and output_<workflow>.json. The rules:

  • A step keeps its id. A call to make_greeting.wic becomes the step make_greeting, without .wic.
  • A repeated id gets @ and its position on every copy, the first one included.
    • Two append steps at positions 2 and 3 become append@2 and append@3.
    • The number is the n that .wic (n, id) addressing already uses.
    • A step id is also numbered when it equals a workflow input or output name, or matches another id except for case. CWL keeps steps, inputs and outputs in one namespace, and on a case-insensitive filesystem the two files would be one file.
  • A name Sophios has to make joins step and port with ~.
    • The workflow input that feeds touch's filename is touch~filename.
    • One level down, inside the call make_greeting, it is make_greeting~touch~file.
  • A written name may only use [A-Za-z0-9_.-], and may not start with ..
    • A .wic that breaks this gets the new wic045 at the offending line. In Python it is a ValueError.
    • This rule keeps ~ and @ free, so a made name can never collide with a written one.
    • It also makes every name safe as a file name and as a run: path.

Why ~: . reads as Python attribute access and breaks $(inputs.x). > is not a URI character, so -> breaks cwltool's --print-dot and --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:

  • The reader that recognised a hand-written <workflow>__step__<n>__<id> in a .wic, for example in outputSource:.
    • Such a name is now just a name that matches no step. Without a type: it is wic036.
    • Write the step's id instead, or (n, id) when the id repeats.
    • The corpus's last uses are in mm-workflows, and add --generate_config flag #268 there moves them.
  • AuthoredNamesFilter and autogenerated/<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:

autogenerated/
  greeting.cwl
  greeting_inputs.yml
  greeting.names.json
  greeting__step__1__touch/touch.cwl
  greeting__step__2__append/append.cwl
  greeting__step__3__cat/cat.cwl

After:

autogenerated/
  greeting.cwl
  greeting_inputs.yml
  greeting~append.cwl
  greeting~cat.cwl
  greeting~touch.cwl

The layout:

  • The process each step runs is written beside the root as <root>~<address>.cwl. A step inside a subworkflow is written as nested~make_greeting~touch.cwl.
  • Every run: is therefore a plain sibling file name.
  • Two workflows compiled into one base path never share a file.
  • A tool that three steps run is written three times, once per step.
  • Only the root gets a job file. The empty <tool>_inputs.yml beside each tool is no longer written; nothing was ever bound to a tool directly.
  • Real-time analyses use the same layout under realtime/<workflow>/.

What used to depend on where a file landed:

  • Tools that refer to files beside them. Copying such a tool into autogenerated/ broke every relative $include, $import, or relative location/path (such as a default:).
    • Now cwltool packs such a tool when it is written: an include becomes its text, an import its content, and a location an absolute file:// URI.
    • Data, scripts and images stay where they are.
    • If cwltool cannot read a reference, the compile reports it at the step that runs the tool (wic013). Before, the run failed partway through.
    • This replaces the special case that rewrote a dockerFile $include path.
  • Relative paths in a .wic default:.
    • A relative File or Directory there is now resolved against the .wic's own directory and written absolute.
    • Before, it was written as-is and then read relative to wherever the runner loaded the compiled CWL from.
    • In Python, a relative StepInput(default=...) is resolved against the working directory, the same way a bound value is.
  • The EDAM ontology entry Sophios added to every root's $schemas. That entry is deleted.
    • The problem arose when a .wic or an embedded tool already listed an EDAM_dev.owl from somewhere else, such as GitHub main or a local copy on an offline cluster.
    • The root then depended on two files with the same basename, and cwltool failed after the steps had already run: Conflicting basename in listing or secondaryFiles, 'EDAM_dev.owl' used by both ....
    • $schemas now holds only what authors wrote.

Sophios's own metadata. Every root also carried a sophios:lang_version key under a sophios prefix, and an edam prefix, 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 has CompiledWorkflow.lang_version; edam is declared only where a format says edam:.

3. Running: you run what you compiled

Python run()

  • Before, 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.
  • Now the command line and run() share one function, run_setup.prepare.
  • run() runs exactly the document compile() returns. If the workflow declares outputs, only those come back; to read one step's output, name it as a workflow output.

--no_provenance

  • It now drops the runner's --provenance. In Python, pass run_args_dict={'no_provenance': 'yes'}.
  • Before, the flag was accepted and ignored.

--quiet

  • Before, it rewrote the compiled CWL to add stdout: <tool>.out and stderr: <tool>.err to each tool, and the run deleted those files. So --quiet changed the compiled CWL, and a quiet failure left nothing to read.
  • Now --quiet only 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

  • Inputs files written for an earlier compile: greeting__step__1__touch___filename becomes touch~filename.
  • Keys read from output_<workflow>.json: they change the same way.
  • Scripts that open a tool file by its old path: <generated step id>/<tool>.cwl becomes <workflow>~<step>.cwl.
  • A .wic that names a step as <workflow>__step__<n>__<id>: write the id, or (n, id).
  • A step, port or workflow name outside [A-Za-z0-9_.-]: rename it (wic045).
  • --cwl_inline_subworkflows: it names a dissolved call's steps <call>~<step>.
  • A when: on a subworkflow call that reads a made name: write it in brackets, $(inputs["touch~filename"]), because ~ is not allowed in inputs.<name>.

Known gaps

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.

  1. 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).
  2. feat(lang): refuse names outside [A-Za-z0-9_.-]: wic045 (lang/names.py, lang/parser.py) and the Python ValueError.
  3. fix: CWL depends only on its authors' files: no EDAM $schemas, no sophios key or prefix, edam only where a format uses it, and .wic defaults resolved (ir/locations.py, ir/lower.py, ir/emit.py).
  4. fix: copied tools keep their relative files: packing at emission (utils_cwl.py, compiler.py) and wic013.
  5. feat: run executes exactly what compile writes: run_setup.py, _workflow_runtime.py, main.py, and --no_provenance.
  6. fix: --quiet leaves the compiled CWL alone: deletes the capture plugins.py added at compile time.
  7. 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_pdb and download_smiles_ligand_db off the old spelling. Until it merges, CI checks out mm-workflows at refs/pull/268/head wherever it used main: the branch-dispatch fallbacks and the weekly, macOS and benchmark lanes. Once it merges, they go back to main.

@vjaganat90
vjaganat90 force-pushed the feat/authored-cwl-names branch 8 times, most recently from 59601c2 to e2ddd7c Compare October 20, 2026 15:42

@darkclad darkclad left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/sophios/utils_cwl.py Outdated

_register_extensions()
try:
loading = cwltool.context.LoadingContext({'fetcher_constructor': _Serving})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@vjaganat90 vjaganat90 Oct 20, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/sophios/run_setup.py
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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@vjaganat90

vjaganat90 commented Oct 20, 2026 •

Copy link
Copy Markdown
Member Author

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.

@vjaganat90

Copy link
Copy Markdown
Member Author

I folded one more fix into commit 3 (fix: CWL depends only on its authors' files): the compiled CWL no longer carries Sophios's own sophios:lang_version key and sophios prefix, and declares edam only where a format says edam:. It is the same cleanup as the deleted EDAM $schemas: nothing in the CWL that no author wrote. The compile still prints the version, and Python still has CompiledWorkflow.lang_version.

The --docker_remove_entrypoints fix is #542, stacked on this one; it also covers images under hints and tools embedded in an inlined document. NovagenResearch/mm-workflows#268 now groups the src/vis viewer by the new ~ names.

@darkclad darkclad left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/sophios/ir/emit.py Outdated

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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_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.

@vjaganat90 vjaganat90 Oct 20, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread docs/dev/language_spec.md Outdated
`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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@vjaganat90 vjaganat90 Oct 20, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/core/test_lang_version.py Outdated
assert ANNOTATION_KEY not in compiled.cwl_workflow


@pytest.mark.skip_pypi_ci

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: @pytest.mark.skip_pypi_ci is now applied twice to test_a_pinned_file_reports_its_version_and_writes_plain_cwl.

@vjaganat90 vjaganat90 Oct 20, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, the duplicate mark is removed.

Fixed in 53e0496.

@vjaganat90

vjaganat90 commented Oct 20, 2026 •

Copy link
Copy Markdown
Member Author

Thanks. The File-default case is fixed: edam is now bound when a format appears in a port default or a step-input default:, with tests for both. The spec no longer names the deleted test, and the duplicated mark is gone. I folded the fixes into the commits they belong to.

Fixed in 53e0496 and 9f9ffeb.

@vjaganat90
vjaganat90 force-pushed the feat/authored-cwl-names branch from 93fadfe to 875a0be Compare October 20, 2026 19:22

@darkclad darkclad left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:.

@vjaganat90
vjaganat90 force-pushed the feat/authored-cwl-names branch from 875a0be to 9f9ffeb Compare October 20, 2026 20:01
@vjaganat90

Copy link
Copy Markdown
Member Author

Thanks. Both pages now list a File in an input's or a step input's default: in the edam rule.

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.
@vjaganat90
vjaganat90 force-pushed the feat/authored-cwl-names branch from 9f9ffeb to 11deb67 Compare October 21, 2026 14:48
@vjaganat90
vjaganat90 merged commit 859c738 into PolusAI:master Oct 21, 2026
3 checks passed
@vjaganat90
vjaganat90 deleted the feat/authored-cwl-names branch October 21, 2026 15:28
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.

2 participants