Repository navigation
feat: one table of targets, and nf-s codes for Nextflow refusals - #586
Conversation
865a345 to
27bd91c
Compare
a2d5a20 to
97732f9
Compare
4772910 to
ca958f2
Compare
darkclad
left a comment
There was a problem hiding this comment.
Reviewed the five commits above #585. The target table, the coded refusals and the Python API changes behave as the description says: --target nextflow on a refused workflow prints coded errors on stderr, exits 1 and writes no error_*.txt; --diagnostics json carries "kind": "target"; --explain nf-s010 works; check(target="nextflow") returns the refusals while compile() and run() raise NotLowered; and an unknown target is reported before anything compiles. tests/core shows no new failures against #585's head (Nextflow and Docker runtime tests not exercised here), and pylint improves on the base.
One blocker: mypy fails on this branch (inline). The lint lane did not run on this PR, so CI has not caught it.
| from sophios.runtime_inputs import normalize_artifact_job_inputs | ||
| from sophios.utils_nf import local_locations_as_paths | ||
|
|
||
| ModelT_co = TypeVar('ModelT_co', covariant=True) |
There was a problem hiding this comment.
mypy (2.3.1, the project config) fails here: run_setup.py:53: error: Cannot use a covariant type variable as a parameter [misc], at model: ModelT_co in the frozen dataclass Lowered. #585's head is clean, and CI's lint lane runs bare mypy, so this would fail it. An invariant TypeVar (TypeVar('ModelT')) clears it, and every changed source file passes with that one change, since every caller uses Lowered[Any] or the exact model type.
There was a problem hiding this comment.
You're right. A covariant TypeVar can't be used as a parameter type, and the frozen dataclass Lowered has model as a field. I switched to an invariant ModelT. mypy over src/, examples/ and tests/ is now clean, and the fast core tests pass.
Fixed in c237465.
|
Thanks for the review. The one blocker, the Fixed in c237465. |
darkclad
left a comment
There was a problem hiding this comment.
The mypy fix in c237465 is the invariant TypeVar, and with it mypy is clean over the changed files.
One thing left: this branch still sits on #585's old head (ff4d0c4), and #585 has since been rewritten (now 1e01d2b). Replaying this PR's own commits onto the new #585 conflicts in src/sophios/utils_nf.py at _refusal, and the conflict is semantic, not textual. The new #585 adds _unbound_output_findings (a workflow output relaying a nested input nothing binds, with cases in rejected/calls.yaml), and it returns plain-string findings. This PR makes every finding a _Finding with a code, so once restacked, that refusal needs an nf-s code (an existing one such as nf-s016, or a new one), an error_codes.md row, and codes: on its cases. Otherwise it is the one uncoded refusal, which the description says no longer exists.
We pick a target in hand-written branches at each entry point, and a Nextflow refusal is the one problem we report without a code. This sets out one table of targets that every entry point reads, and the nf-sNNN codes that make each refusal an ordinary diagnostic.
Each reason a Nextflow refusal has gets a rejected case naming its code, and we pin what D promises: refusals print as ordinary diagnostics from the CLI and Python, check() returns them, --explain knows nf-s codes, an unknown target is one message, and the table, --target and the Literal agree. They fail until D lands.
Every reason the Nextflow target refuses a workflow gets an nf-sNNN code of a new kind, target, carried from the lowering, the support table and the model's checks into each refusal, which now prints as any Sophios error. The catch-alls that turned any ValueError into an uncoded refusal go, so a crash is reported as one.
Every entry point finds its target in sophios.targets, which holds each target's lowering, writing and runners, so an unknown target is one message and the run path lowers once. CWL answers the same contract as Nextflow; the command line and check() report refusals as diagnostics.
The field table shows the code each rejected field is refused with, the limits point at the nf-s list, and check() is described as returning the target's refusals.
mypy rejects a covariant TypeVar as a parameter of the frozen dataclass. Every caller uses Lowered[Any] or the exact model type, so invariance fits.
c237465 to
e7d48d3
Compare
|
On this branch the refusal you mention is already coded. |
darkclad
left a comment
There was a problem hiding this comment.
LGTM. The rebase onto master carries the unbound relayed-input refusal as nf-s025 with its case coded, mypy is clean, and tests/core shows no new failures.
Stacked on #585 (
feat/checks-before-writing). Merge that first; this PR's own changes are the commits above it.What
One table of targets,
sophios.targets, read by every entry point: the command line (--target,--check,--run_local,--generate_run_script, the raw-CWL pass-through),Workflow.compile,run,start,run_asyncandcheck, andrun_local. Each row holds the target's contract (what it refuses, how it lowers and writes, whether it takes plain CWL as is) and its runners. An unknown target is reported from one place, before anything compiles.--targetand the Python API'starget: Literal["cwl", "nextflow"]are unchanged, and one test keeps the table's names, theLiteraland--target's choices equal.CWL answers the same contract as Nextflow: it refuses nothing, and its lowering is today's emitter, unchanged.
Every Nextflow refusal has a code,
nf-s001tonf-s055("Nextflow support"):docs/error_codes.mdthatsophios --explain nf-s010prints;target: nothing is wrong with the workflow, this target cannot run it yet, so the fix names the construct to change, or--target cwl. Three are kinddocument: a source that names no step or port, a path reference, and invalid CWL;wic012, an explicit null for a required input, andwic056, awhenthat cannot give a boolean, which stays a note on CWL;A refusal is an ordinary diagnostic. For
sophios --yaml refused.wic --target nextflow, a step whosewhenis$(inputs.message < "27"):Failed to generate Nextflow artifacts. See error_refused.txt., and the refusal is only in that file, written to the working directory whatever--basepathsays;--diagnostics jsonprints it as one object with"kind": "target"and the fix. From Python,Workflow.check(target="nextflow")returns the refusals among the other diagnostics;compile(),run()andstart()raiseNotLowered, whose text is the same diagnostic lines.A run lowers once: the backend's
preparetakes the lowered model.What changes for callers
error_<stem>.txtis written only for a crash, as for the CWL target.Workflow.check(target="nextflow")returns refusals instead of raising.Refusalgains itscode, andNotLoweredno longer takes a target name or prints a "capability analysis failed" header. All three are new since 0.7.0.--target nextflow --allow_raw_cwl plain.cwlsays on stderr that the file is compiled as a Sophios document, which it already did silently.Deleted
ValueErrorraised while lowering for Nextflow into an uncoded refusal. They gave a refusal no code and hid a bug as a refusal. Every path they covered is now a coded refusal checked before the pipeline model is built, through the same predicate the model's own validation uses where both check one thing; a bounded property generates tool and workflow shapes and holds the lowering to three outcomes: a pipeline, a coded refusal, or a compile error. An error nobody foresaw now goes to the crash handler, as anywhere else in Sophios.backends.BACKENDSand the hand-written target branches inmain.py,run_local.py,api/python/workflow.pyandapi/python/_workflow_runtime.py: the table replaces them.Emitted CWL and every generated Nextflow file are byte-identical over the docs examples, the test cases and both corpora, and every workflow refused before is still refused, now with a code. CI does not check either, so I did.
Why
Nextflow was chosen by hand-written branches and explained its refusals in its own uncoded layout; a target is first class when it is chosen, checked and explained the way every target is, whatever it supports.