Repository navigation
refactor: one statement for each fact, in docs, tests and the Nextflow target - #605
Conversation
7f08f12 to
a896a2a
Compare
433df64 to
05d2533
Compare
darkclad
left a comment
There was a problem hiding this comment.
I reviewed the six commits above #604 (310cc4f0..05d2533). Removing the duplicate tables is a clear win. The spec's code table really had drifted, and the census that now reads the codes each fixture family states is sound. I checked that every file listed in _STATED is compared exactly by the test the comment names, at the lines it gives. The new help strings match the old cli-reference.md table they replace. sophios --help renders. The docs build cleanly with -W, both the site and the PDF's singlehtml (master_doc=pdf_index), and the shared toctrees.inc keeps the PDF's contents two levels deep, as before. On Windows, the 12 test files this PR touches or relies on give the same 7 failures on head and base, all environmental.
Six comments inline: pointers that now lead nowhere, the run-stop tests losing their reason check, an import branch left untested, two flag metavars, and the Sphinx floor. Three smaller notes:
test_an_ir_value_constructs_exactly_as_its_row_saysstill says construction refuses "naming the field, or the edge"._as_statednow accepts anyValueErrororTypeError, so the docstring promises more than the test checks.test_support_table.pyno longer checks the compile-time fields against design §3, butsophios_nextflow_backend.md:56still lists them by hand. Either that sentence or the check should go.- The design doc's header now restates that only
design:commits modify it, and it was rewritten indocs:commits (8d6056b,05d2533). Earlier commits ignored the rule too, so it may be time to drop it.
| `sophios.runners`. The command line, `Workflow.compile`, `check`, `run`, `start` and `run_async`, and the run path | ||
| find a target here, by the name `--target` and `target=` give it, and nowhere else | ||
| (design_docs/one-target-table-design.md §2). | ||
| (docs/dev/architecture.md). |
There was a problem hiding this comment.
docs/dev/architecture.md is unchanged by this PR. It mentions the resolved view once (Emit, step 7) and says nothing about the one target table, wic056 for a when that gives no boolean, or the lowering's three outcomes. So the pointers redirected here, and in compiler.py, ir/resolved.py, test_targets.py, test_lowering_outcomes.py and compiler/when/expected.yaml, lead to a page that doesn't state what they cite. Some citations of the deleted design also remain: nf_support.py:298 ("resolved-view design §8"), utils_nf.py:2730 (§3), and sophios_nextflow_backend.md lines 129, 145, 217 and 297. Either move the cited facts into architecture.md or drop the pointers.
There was a problem hiding this comment.
Fixed in 10fbc91: the archived design citations are gone from the backend design, nf_support.py and utils_nf.py. architecture.md itself I'm leaving as is here; it gets rewritten as a whole once the tool work lands, rather than patched section by section.
There was a problem hiding this comment.
Correction to my earlier reply: some citations of the archived design were still there, in utils_nf.py and elsewhere, and the pointers here led to a page that does not state what they cite. Both are fixed in 8738921: the pointers are dropped and the citations removed.
| **Optional outputs (approved lowering).** A `File?` or `Directory?` output is `null` when its glob matches nothing, as in CWL, and the workflow output it reaches reports that `null` as the `[]` sentinel (§6, Topology). A literal glob with no `$(self[0])` names at most one path, so its port is `optional: true` and emits nothing when nothing matches. A pattern glob, or a literal one under `$(self[0])`, must match at most one file, and CWL fails the step when a pattern matches several; the pinned Nextflow refuses an arity of `0..1`, and fails `arity: '1'` on no match even beside `optional: true`. Such a port therefore declares `arity: '0..*'`, and its workflow output takes the one file, gives `[]` for none, and stops the run naming the output when there are more. That check runs at the workflow output, so the port must reach one. An optional output reaches workflow outputs only, and a scattered process has none, since a gather would drop a null's position. Runtime proof against the pinned Nextflow shows zero, one, and two matches each ending as CWL ends. | ||
|
|
||
| **Output cardinality declaration (approved Phase 2 lowering, one supported literal).** An `outputBinding.outputEval` whose text is exactly `$(self[0])` — surrounding whitespace trimmed, no tolerance for internal variation — is recognized as a *cardinality declaration*, not as an expression: it states that the port carries one value rather than a list. It lowers to a closed capture marker on the output port, mirroring the array marker on input ports, and no `outputEval` token of any kind enters the executable model. On a required output, the marker renders as Nextflow's `glob: false, arity: '1'` options on the `path` output (an optional one declares `arity: '0..*'`; see Optional outputs above): the first makes the approved CWL literal remain literal even when it contains a Nextflow-only pattern character such as `{`, `}`, or `\`, and the second is runtime-proven against the pinned Nextflow to emit a single path value rather than a list and to fail the task when nothing matches. The reader (§4.2) reads `glob: false` beside an arity back as the same closed capture marker. | ||
| **Output cardinality declaration (approved lowering, one supported literal).** An `outputBinding.outputEval` whose text is exactly `$(self[0])` — surrounding whitespace trimmed, no tolerance for internal variation — is recognized as a *cardinality declaration*, not as an expression: it states that the port carries one value rather than a list. It lowers to a closed capture marker on the output port, mirroring the array marker on input ports, and no `outputEval` token of any kind enters the executable model. On a required output, the marker renders as Nextflow's `glob: false, arity: '1'` options on the `path` output (an optional one declares `arity: '0..*'`; see Optional outputs above): the first makes the approved CWL literal remain literal even when it contains a Nextflow-only pattern character such as `{`, `}`, or `\`, and the second is runtime-proven against the pinned Nextflow to emit a single path value rather than a list and to fail the task when nothing matches. The reader (§4.2) reads `glob: false` beside an arity back as the same closed capture marker. |
There was a problem hiding this comment.
"see Optional outputs above" points at a section this PR removed. The same trim left other dangling references:
- line 249: "an optional input's own binding, below" (Optional value bindings was removed);
- line 312: "the Phase 2 array marker";
- line 320: "the evidence appropriate to the phase" (§9 Phases is gone);
- lines 100 and 154: they send the CUDA fields and the notes to "§6, Resources and containers", which now holds only the general paragraph, since GPUs, environment variables and entrypoints were removed.
There was a problem hiding this comment.
Fixed in 939090e: the six references the trim left dangling are removed or reworded.
| raised = [line for line in logs.splitlines() if "ERROR" in line or expected["says"] in line] | ||
| assert any(expected["step"] in line for line in raised), logs | ||
| assert expected["says"] in logs + (pipeline / ".nextflow.log").read_text(encoding="utf-8"), logs | ||
| assert any(expected["step"] in line for line in logs.splitlines() if "ERROR" in line), logs |
There was a problem hiding this comment.
With says gone, the in_a_task cases check only that some ERROR line names the step, plus the cwltool leg. A task failing at that step for any other reason, such as a broken helper or a misrendered command, now passes. For entry_and_staged_input_share_a_name, where cwltool runs, nothing shows the stop is the intended one. Most of the dropped sentences were Sophios's own, not Nextflow's ("finds 0 values that are not null", "matched 2 files; it takes at most one", "entry already exists in the task directory"). Could the check keep a stable token from Sophios's own messages, such as the output or entry name, rather than dropping the reason entirely?
There was a problem hiding this comment.
Fixed in 7ab3e5f: each stop case states what the log names it stopped on, and the test checks it, so a task failing at that step for another reason no longer passes.
| assert _imported(compiled.write(tmp_path)) == compiled.nextflow_workflow | ||
|
|
||
|
|
||
| def test_a_condition_too_deep_to_render_stops_the_import_at_its_workflow( |
There was a problem hiding this comment.
This test didn't pin any wording. It checked the code and the position of the stop. It was the only test reaching the except RecursionError stop at nf_reader.py:859-860. With it removed, a coverage run of tests/core/nextflow on head leaves line 860 unexecuted, and no other test raises or patches a RecursionError there. I'd keep it.
There was a problem hiding this comment.
Right, that stop is unreached now. I'm not bringing the test back: nf_reader.py is being replaced by a new importer, and this stop goes with it.
| help='The exit codes that count as success under `--partial_failure_enable`; `0` is always one.') | ||
| cwl.add_argument('--partial_failure_success_codes_range', nargs=2, type=int, default=[0, 1], required=False, | ||
| help='Let users add custom error code range to be treated as success') | ||
| help='LOW HIGH: a range of such codes, `LOW` included and `HIGH` excluded.') |
There was a problem hiding this comment.
Now that the page is rendered from argparse, this flag appears in the table and in --help as --partial_failure_success_codes_range PARTIAL_FAILURE_SUCCESS_CODES_RANGE PARTIAL_FAILURE_SUCCESS_CODES_RANGE, while the help text starts "LOW HIGH:". The old table showed LOW HIGH. metavar=('LOW', 'HIGH') fixes both outputs. --graph_inline_depth has the same problem: its help says "depth N", but it renders as GRAPH_INLINE_DEPTH, so it needs metavar='N'. Separately, the old table's links to Partial failures, Running, Nextflow, Compiling to CWL and Checks and errors are now plain "see X" text.
There was a problem hiding this comment.
Fixed in bf1f352: the two flags name their values (LOW HIGH, and N), in --help and in the rendered table.
| def setup(app: Sphinx) -> None: | ||
| """Render each table that is held in the code into its page as Sphinx reads it.""" | ||
| app.connect('source-read', _render_tables) | ||
| if building_pdf: # the PDF's contents go one level deeper than the site's |
There was a problem hiding this comment.
The include-read event first appears in Sphinx 7.2.5. The 7.2.0 and 7.2.4 wheels don't have it, so app.connect raises an ExtensionError there. docs/requirements.txt still allows sphinx>=7.2, so the PDF build fails on 7.2.0 to 7.2.4. The floor should be 7.2.5.
There was a problem hiding this comment.
Fixed in bf1f352: docs/requirements.txt now asks for Sphinx 7.2.5.
05d2533 to
10fbc91
Compare
darkclad
left a comment
There was a problem hiding this comment.
I checked the fixes on 10fbc91a. Both flags now render as LOW HIGH and N, the Sphinx floor is 7.2.5, the dangling design-doc references and the archived-design citations in nf_support.py and utils_nf.py are gone, and the IR docstring now says what the test checks. Leaving architecture.md for its rewrite, and the nf_reader.py stop for the new importer, both make sense.
I ran the run-stop tests in WSL under Nextflow 26.04.2, which no CI job on this PR does. There are two problems with the replacement for says, inline. One case now fails every run, and on base it passes. Three of the five in_a_task cases still pass when the step fails for another reason.
Still open from the first round, and minor: sophios_nextflow_backend.md:56 lists the compile-time fields by hand, though no test checks that list any more.
| raised = [line for line in logs.splitlines() if "ERROR" in line or expected["says"] in line] | ||
| assert any(expected["step"] in line for line in raised), logs | ||
| assert expected["says"] in logs + (pipeline / ".nextflow.log").read_text(encoding="utf-8"), logs | ||
| assert any(expected["step"] in line for line in logs.splitlines() if "ERROR" in line), logs |
There was a problem hiding this comment.
optional_output_two_matches fails here every run, on this head and on 05d2533 (4 of 4 each), and passes on base 310cc4f0. Its stop is the workflow-level line Sophios workflow output 'maybe_log_o' matched 2 files; it takes at most one. That line has no ERROR, and the log has no other ERROR line naming the step. Base passed because raised also kept lines holding says, and that line names maybe_log inside maybe_log_o. Keeping the old or expected[...] in line clause, or matching the Sophios stop line itself, would restore it.
There was a problem hiding this comment.
Fixed in e4b1629: the in-task stops now name Sophios's own stop line (matched 2 files, already exists in the task directory: data), and the step check accepts that line as well as an ERROR line, so optional_output_two_matches passes again.
| assert any(expected["step"] in line for line in raised), logs | ||
| assert expected["says"] in logs + (pipeline / ".nextflow.log").read_text(encoding="utf-8"), logs | ||
| assert any(expected["step"] in line for line in logs.splitlines() if "ERROR" in line), logs | ||
| assert expected["log"] in logs, logs |
There was a problem hiding this comment.
For three of the five in_a_task cases, the token is in the log however the task fails. I mutated each tool's command to false and, for the two data cases, renamed two/data so no names clash. out.txt and found 2 then disappear, so those two still discriminate. data is still in both *_share_a_name logs, because Nextflow echoes the rendered entry check (if [ -e 'data' ] ...) under "Command executed". maybe_log_o is still there through the sophios-output ["maybe_log_o",null] record. So a task failing at those steps for another reason still passes. Tokens from Sophios's own stop text, such as already exists in the task directory and matched 2 files, would discriminate.
There was a problem hiding this comment.
Fixed in e4b1629: those three tokens are now Sophios's own stop text, which a task failing for another reason does not print. found 2 and out.txt stay, since they already discriminate.
10fbc91 to
8738921
Compare
|
The hand-written compile-time list is gone from the backend design (1149b34). Also fixed: the pointers to |
darkclad
left a comment
There was a problem hiding this comment.
I checked 87389210. The run-stop fix holds. I ran the stop tests in WSL under Nextflow 26.04.2, and all 9 cases pass, optional_output_two_matches included. I repeated the mutation from last round: each in_a_task tool's command becomes false, and the data name clash is removed. All five tokens are then absent, so each case now fails when its step stops for another reason. The docs/dev/architecture.md pointers are dropped, the hand-written compile-time list and the design:-only rule are gone from the backend design, and the Toil commit is #606's, which this branch now sits on.
One leftover, inline: some citations of the deleted resolved-view design are still there.
| what Sophios invented (edge inference, the names it makes, anchors) is | ||
| resolved before the view exists, and the view holds only the result, as | ||
| references (design_docs/resolved-view-design.md §3-§6). | ||
| references. |
There was a problem hiding this comment.
This module still cites the deleted resolved-view design by bare section number, at lines 155, 351, 493, 520 and 533 (§5), 558 (§10) and 583 (§6). These are that design's "What each construct means", "Checks before anything is written" and "Through calls". Now that this pointer to architecture.md is gone, they name no document, and the backend design's §5, §6 and §10 are other things or don't exist. utils_nf.py:2208-2209 has the same leftover: (design §5) was (design §5, §9), and both numbers were the resolved view's.
There was a problem hiding this comment.
Fixed in 5615c9b: the seven bare section numbers in ir/resolved.py and the (design §5) in utils_nf.py are gone; each sentence already states what it cited.
8738921 to
5615c9b
Compare
5615c9b to
f85eb6c
Compare
The needs_cwltool marker on each test is the one statement of which tests skip Windows; the Nextflow tests no longer read error sentences, a golden pipeline, a wall clock or Nextflow's own wording, and read the compile-time rows from the support table.
The census reads the codes each fixture family states and its test compares exactly; a callable stays only for a code no fixture states.
The step-key aliases restated Grammar's own .pattern, the tests hand-typed CWL's type and scatter names, and Nextflow's keyword list was read by nothing.
The language spec's support and code tables, the marker list, a copied example, and the Nextflow page's and design's restatements of the rendered tables and of each other go to what states them; the page lists are one file the site and the PDF share. The spec says once what a workflow means: its Sophios workflow graph.
The flag tables restated cli.py by hand; the help strings now say what the page said, and the page renders them.
Both are built; they were kept true by hand beside the code. They live in the roadmap's archives now, and the pointers go to the architecture page.
f85eb6c to
a847702
Compare
Stacked on #604 (
refactor/verified-cuts). Merge that first; this PR's own changes are the commits above it.What
validation.md, the Nextflow page's and design's restatements of the rendered tables, the hand-kept list of Windows skips, the tests' hand-typed CWL names, the parser's step-key pattern aliases, Nextflow's unread keyword list, and an example copied intowic-reference.md.sophios --helpand the page say the same thing; the PDF and the site share one list of pages; the error-code census reads the codes each fixture family states and compares exactly, and keeps a provocation only for a code no fixture states.docs/dev/architecture.md.Why
A fact stated twice drifts: the spec's code table had 47 of 117 codes and the wrong number of ranges. Docs lose 1,383 lines, tests 465, test data 115; core is level (-1), its new lines being help text that now says what the reference page said. Every corpus workflow compiles as before.