Skip to content

fix: read a packed CWL tool through its main, and an inputs file's output-target Directory as a name - #530

Merged
vjaganat90 merged 6 commits into
PolusAI:masterfrom
vjaganat90:fix/small-fixes-0.7.0
Oct 13, 2026
Merged

vjaganat90 merged 6 commits into
PolusAI:masterfrom
vjaganat90:fix/small-fixes-0.7.0

Conversation

@vjaganat90

@vjaganat90 vjaganat90 commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Stacked on #529 (ci/runs-name-what-they-test). Merge that first; this PR's own changes are the commits above it.

What

  • A packed CWL tool used as a step is read through its main. One function picks main from a $graph wherever a tool file is loaded: the search paths, run: beside the document, Step(clt_path=...) and Step.from_cwl_document. The step's ports are main's, and the emitted CWL validates in cwltool. A $graph with no main is wic013, naming the processes it holds. The packed-Workflow refusal is unchanged.
  • An output-target Directory written in an inputs file as CWL writes a Directory ({class: Directory, location: result.outDir}) is the name of the directory the step creates. It was made absolute before it was read as one, so the run stopped with "cannot use an absolute location" for a path nobody wrote, and the pre-flight then looked for it as a missing input. The inputs file is now read as the runner reads it before either, as values bound in Python already were.
  • A step's scatter is written as a list in the emitted CWL, whichever spelling the .wic uses (scatter: p and scatter: [p] mean the same in CWL). The Python API already wrote the list, so Workflow.from_wic and the file now compile alike without a scatter rule in the comparison.
  • The Ctrl-C exit test is skipped on Windows, where no POSIX process-group SIGINT exists. docs/build_pdf.py checks sys.platform, which mypy narrows on Windows.
  • Read the Docs builds again: .readthedocs.yaml moves from ubuntu-20.04, which Read the Docs removed on 2026-06-01, to ubuntu-24.04 and Python 3.12, and fails on a warning as the CI docs build does. docs/requirements.txt takes Sphinx 7.2 or newer, because the API page uses :no-index:; the old sphinx==6.1.* pin rejected it.

Why
A packed tool is valid CWL, but it compiled to a step with no ports and failed later in cwltool. An inputs file could not name an output directory the way CWL writes one. The Windows items failed only off CI's Windows selection. Every Read the Docs build since June failed, so latest still showed May's docs.

@vjaganat90
vjaganat90 force-pushed the fix/small-fixes-0.7.0 branch 3 times, most recently from 06d3b7a to 39dbf1d Compare October 11, 2026 05:51
@vjaganat90 vjaganat90 changed the title fix: read a packed CWL tool through its main; keep two POSIX-only checks off Windows fix: read a packed CWL tool through its main, and an inputs file's output-target Directory as a name Oct 11, 2026
@vjaganat90
vjaganat90 force-pushed the fix/small-fixes-0.7.0 branch 4 times, most recently from c1dc182 to 94af05c Compare October 13, 2026 15:50

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

Reviewed the five commits above #529 (cca269c6..94af05c2), diffed against #529's head 42c496c1.

The inputs-file Directory fix, the scatter-as-list change, the Windows skips and the Read the Docs move all read right. All 37 new and touched tests pass in WSL (-k "output_target or packed or ctrl_c or scatter"), including test_a_packed_tool_step_validates_in_cwltool.

One blocker inline: a packed tool whose ports are written the way a CWL packer writes them (list form, id: '#main/text') still compiles to a step with no ports, through all four load points.

Comment thread src/sophios/utils_cwl.py Outdated
'CWL runs a packed document through its main, so name the process to run main, '
'or unpack it into a file of its own')
shared = {key: cwl[key] for key in ('cwlVersion', '$namespaces', '$schemas') if key in cwl}
return {**shared, **{key: value for key, value in main.items() if key != 'id'}}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This drops main's own id but keeps its ports' ids. A packer writes those as #main/<port> in list form (cwltool --pack echo.cwl writes inputs: [{id: '#main/text', ...}]). With $graph: [{id: '#main', class: CommandLineTool, inputs: [{id: '#main/text', type: string, ...}], outputs: [{id: '#main/out', type: stdout}]}], binding text fails with wic028 "binds 'text', which its resolved process does not declare" via run: packed.cwl, the search paths, Step(clt_path=...) and Step.from_cwl_document. On the Python side step.inputs still lists text, because cwl_utils shortens the ids, so only the compile fails. The tests' _PACKED_TOOL uses map-form ports with bare names, which a packer never writes. Stripping the main/ prefix (with or without the leading #) from port ids here, and adding a list-form #main/... case to both _PACKED_TOOL fixtures, would cover it.

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. I only dropped main's own id, so list-form ports written as #main/<port> kept their prefix and the step bound no ports. tool_process now strips the # and main/ prefix from list-form input and output ids of a packed main. Since that is where the document is loaded, all four load points get it. Both _PACKED_TOOL fixtures now use list-form #main/... ports, and they fail without the fix.

Fixed in 171bc0c.

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.

A closer look found the first fix covered only a $graph, so I amended the commit (now f248b6d). cwltool --pack of a single tool, the case you cited, writes no $graph at all: the tool itself with id: '#main' and #main/<port> ids, which was still read as a plain tool and failed wic028. A document whose id is main or #main is now read as main too: its own id is dropped and main/ is stripped from its port ids, as for a $graph's main. Real cwltool --pack output of echo.cwl and echo_3.cwl now binds every port. The fixtures cover the single-tool form through .wic (beside the root and on the search paths), Step(clt_path=...) and Step.from_cwl_document, plus map-form ports in a $graph, and the cwltool validation test uses the single-tool form. Could you take another look?

@vjaganat90
vjaganat90 force-pushed the fix/small-fixes-0.7.0 branch from 94af05c to 171bc0c Compare October 13, 2026 16:55
@vjaganat90

Copy link
Copy Markdown
Member Author

Thanks for the review. The blocker is fixed: a packed main's list-form ports (id: '#main/text') now lose the main/ prefix when the process is read, so they compile through run: packed.cwl, the search paths, Step(clt_path=...) and Step.from_cwl_document. The packed fixtures in both test files now use that form.

Fixed in 171bc0c.

@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. fd172879 fixes the port-id blocker for both forms: a $graph's main and the single-tool id: '#main' that cwltool --pack writes. Real cwltool --pack echo.cwl output now binds every port through run: and Step(clt_path=...). The five earlier commits are unchanged by the rebase. In WSL, test_diagnostics, test_python_api_workflow, test_frontdoor, test_python_api_from_wic and test_ci_coverage pass at this head (398 passed).

Non-blocking, for later: a record-typed port's field names keep their packed id (name: '#main/rec/f'), because only port ids lose the prefix.

A .cwl file that packs its process in a $graph compiled as a tool with no
ports, so a step naming it failed with wic028, or in cwltool with the empty
step the compile wrote. A CWL runner runs a packed document through its
main, and so do we now: wherever a tool document is loaded (the search
paths, a run: path beside the document, a Step's clt_path or a document
given to Step.from_cwl_document), tool_process picks main, with the
cwlVersion, $namespaces and $schemas the packed document declares at its
top, so every reader of a tool's CWL sees one process and the file written
for the step is main alone. A $graph with no main is refused (wic013),
naming the file, the processes it holds and the fix. The Workflow refusal
no longer needs to look inside a $graph itself.
The exit-130 test relies on a POSIX process-group SIGINT, so it is skipped
on Windows like the other POSIX-only tests. build_pdf.py guarded os.killpg
with os.name, which mypy does not narrow on Windows and so reported killpg
as missing there; sys.platform is what it narrows on, with the same branch
taken on every platform.
…un to create

Written as CWL writes a Directory, {class: Directory, location: result.outDir},
it was made absolute against the inputs file before it was read as an output
target, so the run stopped with "cannot use an absolute location", a path the
user never wrote. Past that, the pre-flight looked for it as a missing input.
The inputs file is now read as the runner reads it before its paths are made
absolute and before the pre-flight checks it, as values bound in Python were.
`scatter: p` and `scatter: [p]` mean the same in CWL, but the compiler copied
the authored spelling into the emitted CWL while the Python API always writes
the list, so Workflow.from_wic of a file with `scatter: p` compiled to
different text than the file. The compiler now always writes the list, and
the from_wic comparison no longer needs a scatter rule. No corpus file writes
the single-name spelling, so no corpus CWL changes.
RTD removed the ubuntu-20.04 build image on 2026-06-01, so every build since
failed at config validation. Also move to Python 3.12 and Sphinx >= 7.2 (the
api page uses :no-index:), and fail on warnings as the CI docs build does.
A packer writes main's ports in list form with ids like #main/text, and
`cwltool --pack` of a single tool writes no $graph at all: the tool itself,
as `id: '#main'`. Only a $graph's main lost its own id, so the ports kept the
prefix and a step could not bind them (wic028), and the single-tool form was
not read as packed. Either form is now main as a file of its own: no id, and
the main/ prefix stripped from its port ids. The fixtures cover both forms,
and map-form ports in a $graph.
@vjaganat90
vjaganat90 force-pushed the fix/small-fixes-0.7.0 branch from fd17287 to a2ea6ed Compare October 13, 2026 18:38
@vjaganat90
vjaganat90 merged commit 2419b82 into PolusAI:master Oct 13, 2026
3 checks passed
@vjaganat90
vjaganat90 deleted the fix/small-fixes-0.7.0 branch October 13, 2026 18:46
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