Skip to content

feat(compute): run a workflow on the compute service with Nextflow - #597

Merged
vjaganat90 merged 5 commits into
PolusAI:masterfrom
vjaganat90:feat/compute-nextflow
Nov 23, 2026
Merged

vjaganat90 merged 5 commits into
PolusAI:masterfrom
vjaganat90:feat/compute-nextflow

Conversation

@vjaganat90

@vjaganat90 vjaganat90 commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

What
Service.submit(workflow, config, target='nextflow') runs a workflow on the compute service with Nextflow: the leader one Slurm job, each task a Slurm job of its own. target='cwl', the default, runs it with Toil as before. The service must speak contract 3.1.0; one of 3.0.0 refuses a Nextflow submission in one line, before anything is sent.

from sophios.compute import Service

run = Service('ssh://services-host').submit(workflow, config, target='nextflow')
status = run.wait()
outputs = run.outputs()   # by name; each File and Directory with its class, location, path and basename
  • The service form of the pipeline (design_docs/sophios_nextflow_backend.md §4.5, in the design: commit). service_pipeline(workflow) lowers through the target table with the view compile(target='nextflow') uses, and render_nextflow(model, service=True) writes one main.nf. It differs from the default emission in three places:

    • Containers run under Singularity. A process keeps its container directive and loses the Docker bridge (beforeScript, --entrypoint). Its script runs the command after the image's runscript with SINGULARITY_NO_EVAL set, as singularity run --no-eval does, so the image's ENTRYPOINT runs first, as through CWL; where the image has no runscript, the command alone. A process that asks for GPUs gets containerOptions '--nv'.
    • A task's HOME is its task directory, CWL's rule. Nextflow runs a container without the user's home, so a tool that writes under ~ (a cache, say) would otherwise fail on a read-only file system. A tool's own EnvVarRequirement still wins.
    • Outputs are published. Once every output has completed, the entry workflow places each path in the outputs folder as Toil places a CWL run's: a path inside a folder the workflow also returns is at its place in that folder's copy, and every other path is copied once, the outputs in the order of their names, under the first free name (x, then x_2, x_3). Each output is published as one value, so -output-format json prints the outputs laid out as a CWL run's. No sophios-output line is printed.

    compile(), write() and a local run never write the service form, and the import refuses it (wic047 at the publishing helper, wic050 at a containerized script).

  • The request. A Nextflow request names its engine, its document is {'files': {'main.nf': ...}}, and its inputs are the pipeline's parameters. A File or Directory goes as the CWL object it is. An output folder, a Directory its tool stages writable and returns through a Directory output's glob (the service's own rule on CWL), given a name goes as an empty Directory literal, which the service makes empty in the run; given an absolute path it is refused (RequestRefused): only a CWL run writes in place. A CWL request names no engine, so it is the request a 3.0.0 service takes. run-request.schema.json is the service's 3.1.0 schema, byte for byte.

  • wic061. A workflow output whose name Nextflow does not keep is refused, and so is each output of a workflow that declares none: a client attaching to a run later reads its outputs by the published names. The message names the output, or the step and its port, and a name Nextflow keeps.

  • Targets by the table. target is wic_types.TargetName, an unknown one is reported by targets.target, and a workflow the Nextflow target cannot run raises NotLowered, as compile(target='nextflow') does.

  • The first commit is a fix this PR needs, and every later PR of the chain: schema-salad warns that an id is previously defined for each tool whose input and output share a name (outDir in a Polus plugin, file in the shipped append.cwl). The filter that drops the warning was installed by hand at three doors, the command line, Workflow.run() and the cwltool runner's process, and Workflow.compile() passed none of them, so a program that compiles without running here printed it, as Service.submit does. It is now installed where utils_cwl is imported, the one module that loads CWL through cwltool, so no door can miss it. cwltool's Resolved '<path>' to '<uri>', which only the runner's process says, is filtered in cwltool_main, beside rdflib's warning.

What changes for callers
One warning is no longer printed: compile(), check() and Service.submit no longer print schema-salad's previously defined warning, which run() and the command line never printed. A program that also uses schema-salad itself loses that warning from its import of Sophios's API on, where it lost it at its first run(); cwltool's Resolved line is no longer filtered in such a program, only in the runner's process. Otherwise nothing, unless target='nextflow' is passed to Service.submit, build_request or request_for. The default Nextflow emission is unchanged: 144 cases (576 files: each pipeline with its configuration, parameters and model), written with and without the four commits after the fix, while this PR sat on #590, are identical.

Deleted

  • plugins.logging_filters, its two filter classes and its three calls: the filter is installed where CWL is loaded.

Why
The compute service runs the same workflow on either engine, chosen per submission, with the same RunConfig, Run and outputs.

Verified

Before the rebase, on the same four commits:

  • Two differentials. The output-folder rule against the service's own, over about 4,000 generated tools: no disagreement. The outputs folder against Toil's, 60 workflows run on both engines (colliding names in every order, one path returned twice, scattered outputs, files and folders inside returned folders, names with spaces): every output's class, path and contents agree.
  • Mutation, thirteen mutants, each caught: no --nv; no wic067 refusal; the wic067 message with a Python line, which is not valid for a step inside a subworkflow; no runscript before the command; HOME unset; the output-folder rule without "staged writable" (two forms) and without "returned"; outputs copied in declared order; a copy for each return of one path; and a path inside a returned folder copied on its own (three forms).

Vasu Jaganath added 2 commits November 23, 2026 13:19
schema-salad warns that an id is "previously defined" where an input and an
output of one process share a name, as `outDir` does in a Polus plugin and
`file` in the shipped append.cwl. The filter that drops the warning was
installed by hand at three doors: the command line, Workflow.run() and the
cwltool runner's process. Workflow.compile() passed none of them, so a
program that compiles without running here printed the warning for every
such tool, as will a site and the compute client.

The filter is now installed where `utils_cwl` is imported, the one module
that loads CWL through cwltool, so no door can miss it; the runner's process
imports it with the compiler. cwltool's "Resolved '<path>' to '<uri>'" is
said by the runner's process alone and is filtered there, in cwltool_main,
beside rdflib's warning. `plugins.logging_filters` and its two filter
classes are gone, with their three calls.

The property that builds one tool through every door now finds no door
logging a line, with a tool whose input and output share a name among its
examples. docs/tool-builder.md no longer shows a "Resolved" line that
`python count_words.py` does not print.
…under Singularity and publishes every output

@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. Reviewed as its own four commits on top of #590 (443b0b4a..481a8a04). build_request and request_for keep a CWL request exactly as before, with no engine, so a 3.0.0 service still takes it. The Nextflow path lowers through the same target table compile(target='nextflow') uses, and the service form changes only the container directives, the task script's runscript and HOME lines, and the entry workflow's publish:/output block. The default emission is untouched. _params finds output folders the way the service does on CWL (staged writable and named by a Directory output's glob), and it refuses an absolute one before anything is sent. _cwl_objects now leaves Toil's objects as they are, because they carry a location. On Windows, test_compute.py, nextflow/test_service_form.py and test_ci_coverage.py pass. test_backends.py fails the same 4 tests at head and at #590's tip, all environmental. The Nextflow runtime and service-lane tests were not run here. One non-blocking note inline.

Comment thread src/sophios/compute.py
request = build_request(workflow, config, tool_registry=tool_registry, inference=inference)
request = build_request(workflow, config, target=target, tool_registry=tool_registry, inference=inference)
self._client.speaks()
if target == 'nextflow' and self._client.contract == '3.0.0':

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, non-blocking: this compares the full version string, so a 3.0.x patch release of the service would get past the gate. The service would then refuse engine through its schema, so the user would not get this one-line message. Comparing the minor version (for example self._client.contract.split('.')[:2] == ['3', '0']) would cover every 3.0 service.

Vasu Jaganath added 3 commits November 23, 2026 13:29
… to run

render_nextflow(workflow, service=True) writes the pipeline a compute
service runs, and service_pipeline(workflow) compiles a workflow to it:
the model, the one file, its parameters as nextflow_params.json holds
them, every path as written, and the real-time analyses it declares.
compile(), write() and a local run never write it.

A process with a container has its container directive and, when it asks
for GPUs, containerOptions '--nv'; no beforeScript and no --entrypoint.
Its script runs the command after /.singularity.d/runscript with
SINGULARITY_NO_EVAL set, as singularity run --no-eval does, and alone
where the image has no runscript.

The entry workflow publishes each workflow output as one value, the one
its record carries, once every output has completed: the pipeline places
each path in the outputs folder as Toil places a CWL run's. A path inside
a folder the workflow also returns is at its place in that folder's copy,
never copied on its own; every other path is copied once, the outputs in
the order of their names, under the first name no copy has taken, its
own, or with _2, _3 and on, and a path two outputs return copied once.
So the pipeline first copies each path no other returned path holds, and
then gives every path its place. Nextflow publishes a path outside the
work directory as it is. Nextflow's own publishing would put each file at
its path in its task directory, where two files of one name meet, one
lost or the run failed. -output-format json then prints the outputs laid
out as a CWL run's. A null leaves its channel empty, since a null never
binds one and the run would hang; Nextflow prints it as null. No
sophios-output line is printed.

A workflow output whose name Nextflow does not keep is refused (wic061),
and so is each output of a workflow that declares none, named
<step>~<port>, its message saying to declare the outputs: a client
attaching to a run later reads its outputs by the published names. The
import refuses the service form, at the publishing helper (wic047) or a
containerized script (wic050).
…orkflow on the service with Nextflow

Service.submit, build_request and request_for take target, 'cwl' by
default, as Workflow.run does, and raise Workflow.compile's ValueError for
any other. A Nextflow request names its engine, nextflow, and sends the
pipeline's service form as its one file, main.nf, and the pipeline's
parameters as its inputs, each path a location as written. A CWL request
is as it was, naming no engine, so a 3.0.0 service takes it.

An output folder, a parameter a process stages writable and a Directory
output of it names in its glob, as the service finds one in a CWL
workflow, is sent by its name as the empty Directory the service makes in
the run, and the pipeline publishes it under that name; one given an
absolute path is refused, naming the input, since only a CWL run writes
in place. A Nextflow submit to a service of contract 3.0.0 is refused in
one line before anything is sent.

Run.outputs() gives each File and Directory its class, location, path
and basename on both: each a pipeline published, its class and path,
gains its location and basename, its copy's name, from the answer alone,
so an attached run reads the same; a CWL runner's object, which has its
location, is left as it is, with what Toil adds.

The request schema is the driver's of contract 3.1.0, byte for byte.
…ow and on CWL, and their outputs agree

With SOPHIOS_NEXTFLOW_ENV naming a conda env that holds Nextflow and its
Java, the lane starts a second driver whose Toil env holds that Nextflow,
as the driver's own Nextflow lane does, with a stand-in for singularity on
the job's PATH that runs a task's command on this machine.

A containerized tool that asks for a GPU, copies the folder it reads and
./models into the output folder it stages writable, given a name, and
returns it, runs once and scattered over two names, its paths absolute
and relative to basepath. On Nextflow it runs in its container, through
the stand-in, which finds no runscript, and each task job asks Slurm for
the GPU; on CWL with real Toil, with no container and no GPU, which Toil
refuses on this machine. outputs(), and an attached run's, are the same:
names, shapes, basenames and files, each in the run's outputs folder.

A second workflow runs on both: two outputs of one file name, declared
out of the order of their names, a third returning one of those files
again, a folder returned with a file of that name in it, which an output
whose name sorts before the folder's returns too, and a tool that stages
a folder writable and returns something else. Toil and Nextflow agree on
each output's class and its path in the outputs folder, on the files
there and their text, the file in the returned folder held in the
folder's copy alone, and on how many of the user's files the tool saw in
the folder it was given.
@vjaganat90
vjaganat90 force-pushed the feat/compute-nextflow branch from 481a8a0 to 8199573 Compare November 23, 2026 18:39
@vjaganat90
vjaganat90 merged commit d553d7a into PolusAI:master Nov 23, 2026
3 checks passed
@vjaganat90
vjaganat90 deleted the feat/compute-nextflow branch November 23, 2026 19:04
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