Skip to content

feat(sites): run a workflow on a machine of your own over ssh - #588

Open
vjaganat90 wants to merge 3 commits into
PolusAI:masterfrom
vjaganat90:feat/sites-machine
Open

vjaganat90 wants to merge 3 commits into
PolusAI:masterfrom
vjaganat90:feat/sites-machine

Conversation

@vjaganat90

@vjaganat90 vjaganat90 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

What
The second of four PRs for Sites (design_docs/sites-design.md): sophios.sites.Machine, a computer of your own you can ssh to, macOS or Linux, such as a workstation or a cloud instance. An EC2 instance works from here on.

from sophios.sites import Machine

ec2 = Machine('my-ec2', root='/data/cp', bin='/opt/conda/envs/run/bin')   # a Host in ~/.ssh/config
diagnostics = ec2.check(workflow)          # every problem submit would hit, at once; writes nothing
run = ec2.submit(workflow)                 # CWL, which a site runs with Toil; prints the id, the settings, the outputs
run = ec2.submit(workflow, runner=Toil('--maxJobs', '8', '--clean', 'onSuccess'))   # the runner as a value
status = run.wait()                        # Ctrl-C stops following; the run goes on
later = ec2.attach(run.id)                 # from any computer: repr(run) is this line
  • The transport. Every call is the user's own ssh -T -o BatchMode=yes -o RemoteCommand=none -o ConnectTimeout=20 -o ServerAliveInterval=15 -o ServerAliveCountMax=3 <host> "bash -l -c '<guard>'", with the script on its input, run only when its sha256 matches. The guard prints the hash before it runs the script, so what a login profile prints is never read as the script's output. Tests replace ssh <host> with a local bash, and nothing else.
  • check compiles and lowers here, through the target table (the new _workflow_runtime.lowered_for_site), reading relative paths against root and refusing .., ~, $ and real-time analyses. It calls the backend's write into a temporary folder and its needs, then asks the site everything in one call: its platform, every input path, <bin>/<program> and its version, the container engine when a step runs in a container, whether <root>/sophios can be written and outdir is free. It returns every problem at once and writes nothing on either side. Under Toil it notes each step whose tool declares no memory (wic066), which Toil gives 4 GiB there and refuses to start on a machine with less.
  • submit raises check's errors with nothing written. Otherwise it prints the id, the runner, how many steps run at once and the outputs folder, each with its source, and in one call that ignores hang-ups it makes <root>/sophios/runs/<id> and the outdir (each only if new), writes job.sh, run.json and the backend's files, and starts the leader with set -m; nohup bash -l job.sh &.
  • job.sh is the design's Appendix A in its machine form: the claim with $$, the EXIT and TERM traps, Toil's scratch removed as the run's --clean says, exit written last, and the backend's launch run from bin with what a machine adds (ON_A_MACHINE: --batchSystem single_machine and Appendix A's flags for Toil; no flag for Nextflow). For Nextflow the site appends executor { queueSize = <max_parallel> } to the run's copy of nextflow.config, the one configuration the backend has Nextflow read, from one function, the one place a site sets anything of Nextflow's (decisions 18 and 25).
  • Run has id, status, wait, outputs, logs and cancel, and a repr that is the attach line. Its states follow Appendix B on a machine, with ps -ww -o args= -p <pid> read before exit. A run's end is its backend's own outcome over the run's files, read once.
  • Every target of targets.TARGETS runs on a machine, with the one runner a site runs it with: toil-cwl-runner for cwl, with single_machine, and Nextflow for nextflow, with the local executor. check and submit take target= and runner= as Workflow.run does (decision 27): the runner as a value, for the flags a site takes from it, Toil('--maxJobs', '8', '--clean', 'onSuccess') or Nextflow('-qs', '8'); another runner, another flag or a setting of the value's own is a ValueError. No site runs cwltool (decision 22). A Nextflow process with a container needs container_engine='docker'; otherwise check refuses it by name (wic065). A test walks targets.TARGETS, so a target added there cannot silently miss a machine.
  • Codes, kind machine, each explained by sophios --explain and listed in docs/error_codes.md: new wic062 (the site cannot be reached or used, or Sophios runs on Windows itself, where making a Machine is refused), wic063 (the runner bin lacks, that does not run there, or that is older than a site runs), wic064 (an id that names no run), wic065 (a Nextflow container without Docker), and wic066 (a note: a Toil step that declares no memory). wic015, wic016, wic021 and api008 are reused, their explanations widened to name a site.
  • What S2 found while it was built is recorded in design_docs/sites-design.md §17, in the design: commit:
    • set -m instead of setsid, which macOS lacks;
    • the traps placed right after the claim;
    • Toil's scratch folders made before Toil starts;
    • the guard's hash printed before the script runs;
    • minimum runner versions (Toil 9.5.0, Nextflow 26.04.2);
    • Toil's single_machine refusing a step that asks for more memory than the machine has, so the memory note applies on a machine too;
    • a run still unclaimed 10 minutes after its submit claimed none on a machine too;
    • the codes added and reused;
    • a Machine refused on Windows itself;
    • decision 18's exception to the Nextflow design's non-goal landing here, with the first PR that sets a Nextflow setting, in the run's configuration (decision 25);
    • one known limit: a StepInput(default=...) File is made absolute against the local working directory.

What changes for callers
Nothing for a local run, on the command line or in the Python API. What is new: sophios.sites, which sophios.api.python neither exports nor knows; the codes wic062 to wic066; and wider explanations for wic015, wic016, wic021 and api008. Inside the package: preflight._written_path is now public as written_path, so a site reads input paths as the pre-flight does; targets.for_run takes a PurePath; and _workflow_runtime.lowered_for_site lowers a workflow for a site, through _lowered_for_run, which now takes the folder relative paths are read against.

Why
The goal is decision 1: develop and test on a workstation, then run the same workflow on a cloud VM or a cluster as yourself, changing about one line, with nothing of Sophios installed there. This PR is the machine half. Slurm follows in S3 (the CWL runners) and S4 (Nextflow).

Verified

  • 2026-11-24, a race in status on Linux, found by CI on feat(sites): run Nextflow on a Slurm cluster #590 and fixed here.

  • 2026-11-24, decision 27 (owner): a site takes the runner value, and from it only the flags a site knows. It replaces decision 26.

    • check and submit take target= and runner= as Workflow.run does; max_parallel= and clean= are gone. runner=Toil('--maxJobs', '8', '--clean', 'onSuccess'), runner=Nextflow('-qs', '8'); None is the runner with no flags, so submit(workflow) and submit(workflow, target='nextflow') read as before.
    • One function, _settings, reads the value, and one table, _FLAGS, names the flags a site takes from each runner and the setting each gives: how many steps run at once (--maxJobs, -qs; 64 when not given) and when Toil's scratch is removed (--clean). The site gives each where the runner reads it, Toil's command line or Nextflow's configuration, as before; no flag of the value is passed on as written, and each value is a count or one of three names, so none is free text.
    • Refused with a ValueError before anything is compiled: a runner that is not the site's for the target (Cwltool(...), a name as text), a value with a setting of its own (the engine is the site's container_engine=, the others act on this machine), any other flag, a flag with no value, and a value it cannot have.
    • Left out on purpose: passing other flags through. A flag a site does not know could move the run out of its folder or off its scheduler; taking one more is a row of the table.
    • The run's record keeps max_parallel and clean, each with the flag that gave it (--maxJobs, -qs, --clean) or "Sophios's default".
    • Tests, no new one: the cases of the refusal test are the new refusals, and the walk over targets.TARGETS gives each runner as a value and reads what it asks in job.sh, in the capacity Nextflow's log gives its executor and in run.json. Ten mutations of _settings and of what reaches the runner, each caught.
    • sites.py passes 750 lines here, so it carries the too-many-lines exemption feat(sites): run a workflow on a Slurm cluster, with the CWL runners #589 already has, until feat(sites): run Nextflow on a Slurm cluster #590 makes it a package.
    • The design (decision 27, §4, §5, §9, §10, Appendix A) and docs/sites.md ("Runner flags") say the same.
    • Checked: mypy over all files, lint-imports (8 contracts kept) and pylint on sophios.sites and its tests are clean at the top of the chain, where 603 tests are collected. tests/core/test_sites.py with Nextflow 26.10.5 passed at each PR on its own: 60 cases at feat(sites): run a workflow on a machine of your own over ssh #588, 82 at feat(sites): run a workflow on a Slurm cluster, with the CWL runners #589, 83 at feat(sites): run Nextflow on a Slurm cluster #590; after those runs feat(sites): run a workflow on a machine of your own over ssh #588 only moved the walk's runner values to a constant (its two tests run again) and feat(sites): run a workflow on a Slurm cluster, with the CWL runners #589 only reworded a comment. The whole lanes are CI's.
  • 2026-11-23, review (darkclad): two fixes, folded into the feature commit, and the design corrected in the design commit.

    • attach takes every id submit prints. A run id starts with its workflow's name, which may start with _ or -, and the id's own pattern refused those. The id is now checked against the pattern of a name (lang.names.WRITTEN_NAME), so there is one rule. An id is only ever used quoted, in a path under <root>/sophios/runs/.
    • run.log is opened to be added to by the call that starts the leader (>>), as job.sh opens it for the runner and as Slurm's --open-mode=append opens it. Opened with >, what the leader said after the runner (an error of its trap's chmod or rm) was written over the runner's lines.
    • Tests, each failed before its fix: the run id no run has now starts with -, in three cases of an existing test; one new test runs the real leader script with a runner of its own that removes its scratch, and reads run.log (before the fix the trap's line had replaced the runner's).
    • The design, which refactor: a backend describes a run, and the machine acts #587 merged with these: the nohup line with >>; <bin>/<name> where three places said <bin>/<program> (a site runs the runner's name, §6); request.run.outdir where §6.1 said request.outdir; and the sample line of §3 says "at most 64 at once", as submit prints it.
    • Checked at the top of the chain: mypy over all files, lint-imports (8 contracts kept) and pylint on sophios.sites and its tests clean; 596 tests collected; tests/core/test_sites.py with Nextflow 26.10.5: 76 passed. At this PR's own tip, before the fold: its 52 cases without Nextflow passed. The whole lanes are CI's.
  • 2026-11-23, refactor: a backend describes a run, and the machine acts #587 merged; rebased onto master 9c0b56e1, whose tree is the tree of the refactor: a backend describes a run, and the machine acts #587 head this chain sat on (c84b7e61), so each PR's tip has the content it had: a replay with no conflict, and nothing run again. git range-diff shows the 9 commits unchanged.

  • 2026-11-23, feat(compute): run a workflow on the compute service with Nextflow #597 merged; rebased onto master d553d7a8, whose tree is the tree of the feat(compute): run a workflow on the compute service with Nextflow #597 head this chain sat on (81995735), so each PR's tip has the content it had: a replay with no conflict, and nothing run again. git range-diff shows the 11 commits unchanged.

  • 2026-11-23, feat(compute): run a workflow on the compute service with Nextflow #597 moved to the front of the chain (owner: let the sites review happen independently). The order is now feat(compute): run a workflow on the compute service with Nextflow #597, refactor: a backend describes a run, and the machine acts #587, feat(sites): run a workflow on a machine of your own over ssh #588, feat(sites): run a workflow on a Slurm cluster, with the CWL runners #589, feat(sites): run Nextflow on a Slurm cluster #590, with feat(compute): run a workflow on the compute service with Nextflow #597 on master (4b11628d). feat(compute): run a workflow on the compute service with Nextflow #597 takes wic061, so the sites' codes are one up: this PR's are wic062 to wic066, in the code, the tests, the pages, the design and the commit messages. The text above says them as they are now; the entries below keep the numbers of their day. The sentences about Docker (wic065's explanation and message, two docstrings and the paragraph of docs/sites.md) are written here as feat(compute): run a workflow on the compute service with Nextflow #597 used to rewrite them: Docker only is the need of the pipeline compile() writes, which a site runs. The chain's new top is its old top with the codes renumbered, byte for byte, but for three things: where wic061 sits in the code table and in the provocations, now in the order of the numbers, and feat(compute): run a workflow on the compute service with Nextflow #597's test fix. Checked at this PR's tip, before feat(compute): run a workflow on the compute service with Nextflow #597's test fix beneath it: mypy (239 files) clean, every test module imports (572 tests), the census of codes passed, and test_compute.py, test_backends.py, test_diagnostics.py, test_ci_coverage.py and test_entry_points.py with test_sites.py: 116 passed. The whole lanes are CI's.

  • 2026-11-23, rebased onto master (4b11628d), seven commits on from 252d37a2: master deletes the python_script step with its code wic014, and says why the warning refactor: a backend describes a run, and the machine acts #587 drops is filtered. No conflict in this PR: git range-diff shows its commits as the patches they were, with two lines of context that are now master's (the Compile row of docs/checks-and-errors.md, which reads wic011–wic013, and the imports of tests/core/provocations.py). Checked at the chain's top (481a8a04), not by the lanes, which CI runs: mypy as the pre-commit hook runs it, clean; every test module imports (595 tests collected); nothing in the chain names what master deleted.

  • 2026-11-20, rebased onto refactor: a backend describes a run, and the machine acts #587's new tip (8689def3), which adds the fix that drops schema-salad's previously defined warning wherever CWL is loaded. A replay with no conflict: git range-diff shows each of this PR's commits as the patch it was.

  • 2026-11-18, on master (252d37a2): the site's flags are set where the run is placed. _prepare gives the runner the machine's flags and makes the request once; _job(request, clean, folders) launches the request as it is given, where it took max_parallel and wrapped the request again, twice. RunSettings takes the run's outdir under Nextflow too, whose launch does not read it, where a branch gave it ''. The runner is still built without flags first: the backend and the check need a runner value before the one call whose answer, on Slurm, the flags need, so one statement gives it the site's flags once the run is placed. No change of behaviour, measured at this PR's tip against the tip before: over 4000 generated runs (each target, the engines, clean, max_parallel, values a site takes and values it refuses), the scripts a site sends, which carry every file of the run, its diagnostics and what submit prints are the same bytes. The property that reads Toil's line back through Toil's parser builds its runner with the table's flags and asserts what it did; the walk now asserts --maxJobs 64 in job.sh, which holds the flags reaching the launch from _prepare. Mutation at the chain's top: 9 rules broken one at a time, each caught. tests/core/test_sites.py here: 52 passed.

  • 2026-11-18, rebased onto feat(lang): write a tool in .wic #609 as rewritten (603c2194). feat(lang): write a tool in .wic #609 moved three times during the day (aef7ab98, 681d54c6, 603c2194) and the chain's 15 commits were replayed onto each. Three conflicts in all: two in feat(compute): run a workflow on the compute service with Nextflow #597 (the runtime adapter's imports, where feat(lang): write a tool in .wic #609 dropped lang.tool; the Compile row of the layer table in docs/checks-and-errors.md, which is feat(lang): write a tool in .wic #609's with wic067 at its end) and one in feat(sites): run a workflow on a machine of your own over ssh #588 (the provocations table, where feat(lang): write a tool in .wic #609 removed the INVALID_NAME entry the hunk sat beside). git range-diff shows no other change to any commit than the codes. What was run locally, and where: at aef7ab98, the whole chain was gated once at feat(compute): run a workflow on the compute service with Nextflow #597's tip as master's lanes run (mypy 251 files, lint-imports 8 contracts kept, pre-commit, autopep8, pylint 9.95 as feat(lang): write a tool in .wic #609's tip, the chain adding the two too-many-lines messages of feat(compute): run a workflow on the compute service with Nextflow #597; test_entry_points.py with test_ci_coverage.py 12 passed; the census of codes 4 passed; the package job's selection 465 passed, 8 skipped; the Nextflow Runtime step 32 passed), with six failures, each reproduced on feat(lang): write a tool in .wic #609's head alone: the five known on this Mac (macOS wc padding, four cases; Python 3.14's PurePath.as_uri() deprecation, one) and one Hypothesis draw of test_a_scatter_records_what_cwl_defines_for_its_method whose captured text passes the 64 KiB loadContents takes. At 681d54c6 and 603c2194 each commit passed its pre-commit hooks, mypy among them, and nothing else was run locally: CI is the gate for this head.

  • feat(lang): write a tool in .wic #609 now assigns wic058 to wic060, so every code of this chain moved up by two: wic061 to wic065 in feat(sites): run a workflow on a machine of your own over ssh #588, wic066 in feat(sites): run a workflow on a Slurm cluster, with the CWL runners #589, wic067 in feat(compute): run a workflow on the compute service with Nextflow #597, in the code, the docs, the tests, the design and the commit messages. The numbers in the entries below are the ones the codes have now. The mutation of 2026-11-17 was run again at the chain's top on aef7ab98: 12 of 12 caught.

  • 2026-11-17, rebased onto feat(lang): write a tool in .wic #609 (b7ff2244), which carries fix(plugins): read a tool when a step runs it #608 and the tool documents. The whole chain was gated once at feat(compute): run a workflow on the compute service with Nextflow #597's tip, which contains this PR (CI runs each PR on its own), as master's lanes run: mypy (251 files), lint-imports (8 contracts kept), pre-commit run from feat(lang): write a tool in .wic #609's tip to the top (22 hooks), autopep8, pylint src/ examples/**/*.py tests/ (9.96, feat(lang): write a tool in .wic #609's tip 9.95; the chain adds two messages to feat(lang): write a tool in .wic #609's, both too-many-lines and both in feat(compute): run a workflow on the compute service with Nextflow #597: _workflow_runtime.py at 763 lines and compute.py at 751) and make html, whose pages are written, the code table listing wic057 to wic067 and the contents the Sites page, and whose one warning is intersphinx's inventory fetch, which this network's proxy refuses and the docs Makefile now makes an error, on feat(lang): write a tool in .wic #609's tip alike; test_entry_points.py with test_ci_coverage.py 12 passed; the census of codes (test_lang_parser.py and its three siblings, -m skip_pypi_ci) 4 passed; the package job's selection (-m "not skip_pypi_ci and not nextflow and not cwl_corpus") 502 passed, 8 skipped; Lint And Test's Nextflow Runtime step with Nextflow 26.10.5 33 passed. Five cases fail on this Mac at this tip and at feat(lang): write a tool in .wic #609's alike: [commands] and [nested] of test_an_example_runs_under_cwltool_as_stated and of test_an_example_workflow_runs_under_nextflow_as_stated (macOS wc pads its count), and test_cookbook.py::test_every_pair_compiles_alike_from_both_surfaces_and_as_stated, which stops on Python 3.14's deprecation of PurePath.as_uri() in master's lang/cwl.py. The gate ran on feat(lang): write a tool in .wic #609 at 0801d5bc; feat(lang): write a tool in .wic #609 was then rebased onto master as b7ff2244 with the same tree, and the chain replayed onto it, changing one line of the design.

  • feat(lang): write a tool in .wic #609 assigned wic058 (a tool document Sophios cannot read), so every code of this chain moved up by one again: wic061 to wic065 in feat(sites): run a workflow on a machine of your own over ssh #588, wic066 in feat(sites): run a workflow on a Slurm cluster, with the CWL runners #589, wic067 in feat(compute): run a workflow on the compute service with Nextflow #597, in the code, the docs, the tests, the design and the commit messages.

  • Decision 26 (owner, 2026-11-17): a site takes no runner=. Replaced by decision 27 (2026-11-24), above. Since decision 22 a site runs each target with one runner, so the runner follows from target=. Locally feat(run): runner values on run(), and one run for both doors #600 made the runner a value, run(runner=Toil(...)); a site taking that value would take settings that are this machine's and flags that compete with the ones the site sets. So check and submit take target= alone. What went: the parameter, the refusal of cwltool before anything is compiled, that half of wic062, its sentence in sophios --explain and in the docs, and the walk's refusal rows; the walk is over targets.TARGETS. The run's record still names its runner, with a site's runner for <target> as where it comes from.

  • What else changed here, with no change of behaviour. The site reads the container engine from its runner value: a CWL runner takes the site's and Nextflow's is Docker, so the refusal of a container (wic064) is "the runner's engine is not the site's", and the engine a check probes and the Singularity caches a job sets follow the runner's, where three places asked whether the runner was Nextflow. lowered_for_site lowers through _lowered_for_run, the function run() and check() lower with: it takes the folder relative paths are read against, the working directory by default, and gives a CWL runner the one document compile() returns, which was written three times. The runner is still built without flags and given the site's once Slurm has placed the run: the flags need the answer of the check that needs the runner. check and submit type target= as wic_types.TargetName, as feat(lang): write a tool in .wic #609 now types every target=.

  • Mutation at the chain's top: 12 rules of what this change and the rebase moved, broken one at a time, each caught, once four that no test held, before this change or after, were given one. The tests' working directory is no longer the site's root, and holds no data, so every path they read is read against root. The table of refused options has a target no table has. The table of check's problems has a Nextflow container on a site whose Docker answers, which is not refused. The walk asserts the Singularity caches for Toil on Slurm (feat(sites): run a workflow on a Slurm cluster, with the CWL runners #589) and none for Nextflow (feat(sites): run Nextflow on a Slurm cluster #590).

  • 2026-11-16, rebased onto refactor: one statement for each fact, in docs, tests and the Nextflow target #605 (05d2533a), which sits on master with feat(run): runner values on run(), and one run for both doors #600's runner values. The whole chain was gated once at feat(compute): run a workflow on the compute service with Nextflow #597's tip, which contains this PR (CI runs each PR on its own), as master's lanes run: mypy (247 files), lint-imports (8 contracts kept), pre-commit run from refactor: one statement for each fact, in docs, tests and the Nextflow target #605's tip to the top (22 hooks), autopep8, pylint src/ examples/**/*.py tests/ (9.95) and make html (its code table lists wic057 to wic067, its contents the Sites page); test_entry_points.py with test_ci_coverage.py 12 passed; the census of codes (test_lang_parser.py and its three siblings, -m skip_pypi_ci) 4 passed; the package job's selection (-m "not skip_pypi_ci and not nextflow and not cwl_corpus") 440 passed, 8 skipped; Lint And Test's Nextflow Runtime step with Nextflow 26.10.5 33 passed. Five cases fail on this Mac at this tip and at refactor: one statement for each fact, in docs, tests and the Nextflow target #605's alike: [commands] and [nested] of test_an_example_runs_under_cwltool_as_stated and of test_an_example_workflow_runs_under_nextflow_as_stated (macOS wc pads its count), and test_cookbook.py::test_every_pair_compiles_alike_from_both_surfaces_and_as_stated, which stops on Python 3.14's deprecation of PurePath.as_uri() in master's lang/cwl.py.

  • Master assigned wic057 meanwhile (a tool cwltool refuses), so every code of this chain moved up by one: wic061 to wic065 in feat(sites): run a workflow on a machine of your own over ssh #588, wic066 in feat(sites): run a workflow on a Slurm cluster, with the CWL runners #589, wic067 in feat(compute): run a workflow on the compute service with Nextflow #597. Each is declared as master now declares a code, with its explanation in the enum; docs/error_codes.md is built from them. The page joins the contents once, in docs/toctrees.inc.

  • What the rebase changed here: the site builds its runner as a value (runners.build, with the site's container_engine) and hands the backend a RunSettings, where it filled a request's loose fields; it reads the runner's name where it read the backend's program. runner= still takes a name on a site. lowered_for_site reads paths against root with targets.for_run, master's replacement for run_setup.absolute_view, and a step's tool is master's wic_types.Tool. Master dropped WINDOWS_EXCLUDED, so this PR adds no entry to it.

  • Mutation of the lines the port rewrote found three rules no test held, before the rebase or after: the run's outdir reaching the runner, a site being sent the one document compile() returns, and the site's container engine reaching the runner. The walk now asserts the first two here and the third in feat(sites): run a workflow on a Slurm cluster, with the CWL runners #589, where Slurm's singularity tells it from the default; each mutant is caught.

  • 2026-11-13, after feat: one table of targets, and nf-s codes for Nextflow refusals #586 and fix: an output directory is a Directory literal #598 merged, rebased onto master 123ab482, the whole chain was gated once at feat(sites): run Nextflow on a Slurm cluster #590's tip, which contains this PR (CI runs each PR on its own), as master's lanes run: mypy (249 files), lint-imports (7 contracts kept), pre-commit run --from-ref 123ab482 --to-ref HEAD over every file the chain changes, autopep8 and pylint src/ examples/**/*.py tests/ as Lint And Test runs them (9.94; the two messages it gave on lines the rebase wrote were then fixed in refactor: a backend describes a run, and the machine acts #587's code commit, a comment and a docstring's wrap, and checked again), and make html with no warning but intersphinx's two inventory fetches, which this network's proxy refuses; test_entry_points.py with test_ci_coverage.py 16 passed; the package job (python -m pytest -m "not skip_pypi_ci and not nextflow and not cwl_corpus") 413 passed, 8 skipped; Lint And Test's Nextflow Runtime step with Nextflow 26.10.5 (pytest tests/core/nextflow tests/core/test_sites.py -m "nextflow and not nextflow_corpus") 31 passed, the walk's runs on a machine and on Slurm among them. Each of the two failed the same two cases, which fail on master here too: test_an_example_runs_under_cwltool_as_stated and test_an_example_workflow_runs_under_nextflow_as_stated, [commands] and [nested], whose wc count macOS pads and GNU's does not (CI runs Ubuntu). --collect-only shows the walk's machine-nextflow and slurm-nextflow cases collected by the Nextflow Runtime step and the weekly Python matrix, and by no lane without Nextflow. The counts below are this PR's own, from before these changes, under Nextflow 26.04.2; those of the nextflow lane were measured there, before feat: one table of targets, and nf-s codes for Nextflow refusals #586 removed it.

  • The rebase's conflicts with master: the site's job values come from runtime_inputs.runner_job_inputs, fix: an output directory is a Directory literal #598's replacement for normalize_artifact_job_inputs, with the view's output targets; the check that a Machine is refused on Windows itself is a site case of master's one Windows test, test_each_door_says_to_run_in_wsl; and Lint And Test's Nextflow Runtime step, which selects the tests marked nextflow, gets tests/core/test_sites.py in its one command instead of a second command.

  • mypy (263 files), lint-imports (7 contracts kept), pylint on src/ and the changed tests (no new message), and autopep8 --exit-code --diff --max-line-length 120 on the changed files: all clean. No .sh file is added.

  • Each lane that collects a changed test file, run as its workflow runs it:

    • the release lane (python -m pytest -m "not skip_pypi_ci and not nextflow" -k "not test_cwl_docker_extract"): 2858 passed, 20 skipped, 1 xfailed;
    • the Nextflow runtime tests with Nextflow 26.04.2, in the nextflow lane's conformance step, which this PR then made name tests/core/test_sites.py too: 82 passed. That lane is now Lint And Test's Nextflow Runtime step, which selects the tests marked nextflow; this PR adds tests/core/test_sites.py to its one command, so the Nextflow row of the walk over runners.RUNNERS runs there, and the rest of the file in the package job;
    • lint_and_test's environment-dependent step, which fires every code's provocation: 120 passed;
    • test_ci_coverage.py with test_entry_points.py: 17 passed;
    • test_run_on_windows.py, which skips off Windows.
  • tests/core/test_sites.py runs in the package job in about 60 s locally, all against a local bash for ssh and the real Toil. They cover:

    • the states over every life a run's folder can have;
    • quoting, checked by printing generated strings back through the real bash and the guard;
    • a login profile that prints, and one that eats its input;
    • Toil's argv read back by Toil's own parser;
    • the EXIT trap for each runner, clean and exit status;
    • check reporting every problem at once and writing nothing;
    • refused settings and options;
    • whether a step declares memory, compared with cwltool's own lookup (which Toil asks) over every placement of a ResourceRequirement (384 cases, under a second);
    • the walk over targets.TARGETS;
    • a run that fails, one cancelled, and a held job that finds the run claimed.

    The provocations of the site codes go through the same local bash. On the Windows leg, where Sophios makes no site, only wic061 fires, and test_run_on_windows.py checks that a Machine is refused.

  • The code commit adds 393 test lines against 838 in src/. Each commit passes its lanes on its own.

  • Mutation checks:

    • Before this round, the first build's check caught 34 of 35 mutants; the one left only rewords a wic062 message.
    • 10 of 10 mutants of what this round added were caught: the memory note dropped or given under every runner; cwltool's precedence broken three ways; ramMax ignored; the runner judge, the Docker-only refusal, attach's unknown run and an ssh that cannot run each disarmed.
    • Asking the site's questions in another order still passes, since the provocations no longer depend on that order.
    • Removing the Windows refusal fails the Windows test. This was checked with sys.platform set to win32; the test itself runs on the Windows leg.

@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 PR's own three commits (55be7c1..585e02f, on top of #587), mainly sites.py and the lowered_for_site / _lowered_for_run change. The transport guard, the claim and traps in job.sh, decide against Appendix B, the _PUT offsets that status reads run.log with, and cancel's process-group kill all hold up as written, and moving inline_artifact_runs into _lowered_for_run leaves the local run's document unchanged. CI is green. I did not run the suite: a Machine is refused on Windows.

Two small points inline, neither blocking.

Comment thread src/sophios/sites.py Outdated
_HOST: Final = re.compile(r'[A-Za-z0-9_][A-Za-z0-9_.@:-]*')
_FOLDER: Final = re.compile(r'/[A-Za-z0-9/._+-]*')
_NAME: Final = re.compile(r'[A-Za-z0-9_][A-Za-z0-9_./+-]*')
_RUN_ID: Final = re.compile(r'[A-Za-z0-9][A-Za-z0-9_.-]*')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A run id starts with the workflow's name, and check_written_name accepts a name that starts with _ or - (WRITTEN_NAME is [A-Za-z0-9_-][A-Za-z0-9_.-]*). _RUN_ID requires a letter or digit first. So Workflow(steps, '_align') submits fine and prints Machine(...).attach('_align-20261123T...-...'), and that line then raises ValueError: ... is not a run id. That is the one line submit says follows the run from anywhere. Letting _RUN_ID start with [A-Za-z0-9_-] fixes it; every use of the id is quoted and sits under <root>/sophios/runs/, so a leading - is never read as an option.

@vjaganat90 vjaganat90 Nov 24, 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 in ac3240e1. attach checks the id against WRITTEN_NAME, the pattern of a workflow's name, and the id's own pattern is gone, so the two cannot drift apart. The id no run has, in test_a_script_runs_there_only_as_it_was_sent, now starts with -; its three cases raised the ValueError before the change.

Comment thread src/sophios/sites.py Outdated
for path in files} - {'.'})),
*(f'printf %s {_q(text)} > {_q(f"{run}/{path}")}' for path, text in files.items()),
f'cd {_q(run)}', 'set -m',
f'nohup bash -l {_q(f"{run}/job.sh")} > {_q(f"{run}/run.log")} 2>&1 < /dev/null &'])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

run.log is opened twice with different modes: here with > (truncate, no append), and in job.sh with >> around the runner. The outer descriptor keeps its own offset, so anything job.sh writes outside the braces after the runner started (a module load message, an error from the EXIT trap's chmod/rm/mv, a set -u failure) lands at that stale offset and overwrites the runner's output. A login profile that prints is enough to put that offset past zero. Reproduced with a three-line script: profile says hi / runner lines appended / one later stderr line gave profile says hi, trap: rm failed, NNER LINE 2. status reads run.log from the byte count it already holds, so the overwritten bytes are also never shown again by wait(). Opening it with >> here fixes both.

@vjaganat90 vjaganat90 Nov 24, 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 in ac3240e1: the leader is started with >>, as job.sh opens run.log for the runner and as the Slurm header's --open-mode=append does in #589. test_run_log_is_only_added_to_whoever_writes_it runs the real leader script with a runner of its own that removes its scratch, so the trap's chmod speaks after the runner; before the change its line had replaced the runner's, as in your reproduction. The design's line (§7) says >> too.

@vjaganat90
vjaganat90 force-pushed the feat/sites-machine branch 4 times, most recently from a7449df to c41e7a0 Compare November 24, 2026 03:27
S2 builds Machine and Run, and records in sites-design.md §17 what it found:
macOS has no setsid, so the leader takes a process group of its own with
`set -m`; the traps follow the claim at once; Toil's scratch folders are
made before Toil starts, which refuses a --workDir that does not exist; the
guard prints the hash before the script, so a login profile's output is
never read as the script's; the runner versions a site takes; Toil's
single_machine refuses a step that asks for more memory than the machine
has, so check() notes each Toil step that declares no memory on a machine
too, wic066; a run unclaimed ten minutes after its submit is claimed `none`
on a machine too; the codes S2 adds and reuses; a Machine is refused when it
is made on Windows itself; and the known limit of a StepInput default's
path.

Decision 18's exception to the Nextflow design's non-goal lands here, with
the first PR that runs a pipeline on a site and sets one of its settings:
executor.queueSize, in a block the site appends to the run's copy of the
generated nextflow.config (decision 25).

Decision 27 (2026-11-24, the owner's) replaces 26: check() and submit()
take the runner as a value, as Workflow.run does, and a site takes from it
only the flags of one table, Toil's --maxJobs and --clean and Nextflow's
-qs; max_parallel= and clean= are gone.
Vasu Jaganath added 2 commits November 24, 2026 02:07
sophios.sites.Machine(host, root=, bin=) runs a workflow on a computer you
can ssh to, macOS or Linux, as yourself. check() compiles and lowers here
as run() does, by the one function both call, with relative paths read
against root, and judges in one call there each input the backend's needs
names, the runner in bin and its version, the container engine, and the
folders it writes; it writes nothing. A site runs each target with one
runner, toil-cwl-runner for cwl and nextflow for nextflow, so target=
names it, and runner= takes it as a value, as Workflow.run does, for the
flags a site takes from it: Toil's --maxJobs and --clean, Nextflow's -qs.
One function reads the value: another runner, a setting of the value's own
or any other flag is a ValueError, since a site sets every other flag
itself and its engine is its container_engine=. The run's runner is built
with the site's container engine, which the site reads back from it. Under Toil
it notes each step whose tool declares no memory, which Toil gives 4 GiB
there and refuses to start on a machine with less. submit() copies the run's
files into <root>/sophios/runs/<id> and starts job.sh, which claims the run
with its pid, runs the backend's launch from bin with a machine's flags
(Toil's single_machine), and records how it ended. Nextflow takes no flags
of the site's: how many tasks run at once is executor.queueSize, in a block
the site appends to the run's copy of nextflow.config, the one configuration the
backend has Nextflow read. Run follows the run as RunHandle does, with id
and a repr that attaches; its end is the backend's own outcome over what
the run left.

Every call is the user's ssh with the script on its input, run only when
its sha256 matches. On Windows itself a Machine is refused when it is made.
The new codes are wic062 to wic066, of kind machine, wic066 a note;
wic015, wic016, wic021 and api008 cover what they already mean.

tests/core/test_sites.py runs in the package job (about 60 s), with a local
bash for ssh and the real Toil; its Nextflow row runs in Lint And Test's
Nextflow Runtime step, which now names the file (about 15 s), and reads the
capacity Nextflow's log gives its executor. The walk gives each runner as a
value, and reads what it asks in the job, in that capacity and in the run's
record. The site codes' provocations go
through the same local bash; the Windows leg checks that a Machine is
refused there.
docs/sites.md opens with the sites design's first message, then says how
to make a Machine and reach it, which runner runs each target and how (a
Toil step that declares no memory gets 4 GiB there), what check and
submit do, how a run is followed and where its folder is, what cleanup
leaves, and what each code means. It sits under Run and manage, and the
pages that list the kinds of code, api008 and the run path name a site.
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