Skip to content

Build the benchmark workflow on runEach, and score the run - #3

Merged
sergiomarco25 merged 1 commit into
mainfrom
workflow-runeach-port
Nov 27, 2026
Merged

sergiomarco25 merged 1 commit into
mainfrom
workflow-runeach-port

Conversation

@sergiomarco25

Copy link
Copy Markdown
Contributor

run_benchmark was hand-written Nextflow: one process per stage, a case block choosing a method, and a shell call into target/executable/.... One invocation covered one method combination, and nothing collected the results - the metric h5ads were published and a separate script harvested them afterwards.

It is now the OpenProblems runEach / fromState / toState idiom. A state threads down the chain carrying the files produced so far and a steps list recording which component produced each, and the workflow ends in a scoring stage that writes every metric value with the chain that produced it.

Two things in the components had to change first, and neither was visible while the workflow called executables:

  • No component declared a nextflow runner, only executable. Viash cannot emit a component as a Nextflow module without one, so composing modules was not possible at all. The failure does not say so: viash ns build reports the workflow's 21 dependencies as missing.
  • No output file argument declared an example. Viash takes the extension of an auto-generated output filename from example; without one the file gets no extension, and np.save appends .npy to a path that lacks it. The component wrote ...output_image.npy while the module looked for ...output_image and reported it missing. The old workflow passed explicit paths that already carried the extension, which is why this never showed.

One invocation now runs many chains, and which ones is an argument rather than an outer bash loop. --default_methods names the baseline, one method per step, and a method that is not a default is only combined with the defaults - so each non-baseline chain differs from the baseline in exactly one step, which is what makes a difference in a metric attributable to a single choice. With the shipped defaults that is 10 chains rather than the 162 a cross-product would give.

Per-method parameters are no longer workflow arguments. The 40-argument config collapses to the method-selection lists plus the three metric arguments that depend on the antibody panel; everything else comes from the component defaults, or from --method_parameters_yaml, which can also sweep one parameter across values. --viash_engine is gone with the shell calls: the engine is now a Nextflow profile.

file_score.yaml stops requiring dataset_id, normalization_id and method_id. A metric here cannot know them - the result comes from a chain of five methods and the file a metric reads carries no record of the four steps before the last. The workflow attaches them instead, which is the only place that has them. The file now describes what metrics do write, and the six metric contracts merge it into their --output.

Verified end to end on a 512x512 crop of exemplar-001 under the native engine: 10 chains x 6 metric families = 60 score records over 82 distinct metric ids. The axes separate as they do on the full image - n_cells 239 for threshold against 293 for watershed, qc_pass_rate 1.00 / 0.91 / 0.55 across the three QC methods, and variance_explained_by_covariate_counts 0.788 for sum against 0.035 for mean. Chains differing only in normalization report identical segmentation metrics, as they must when normalization is per-cell. A separate run exercised --method_parameters_yaml: the default block reached every variant and each swept value reached its own run.

viash ns test --engine native: 21/21 SUCCESS.

Describe your changes

Checklist before requesting a review

  • I have performed a self-review of my code

  • Check the correct box. Does this PR contain:

    • Breaking changes
    • New functionality
    • Major changes
    • Minor changes
    • Bug fixes
  • Proposed changes are described in the CHANGELOG.md

  • CI Tests succeed and look good!

run_benchmark was hand-written Nextflow: one process per stage, a `case` block
choosing a method, and a shell call into `target/executable/...`. One invocation
covered one method combination, and nothing collected the results - the metric
h5ads were published and a separate script harvested them afterwards.

It is now the OpenProblems `runEach` / `fromState` / `toState` idiom. A state
threads down the chain carrying the files produced so far and a `steps` list
recording which component produced each, and the workflow ends in a scoring
stage that writes every metric value with the chain that produced it.

Two things in the components had to change first, and neither was visible while
the workflow called executables:

- No component declared a `nextflow` runner, only `executable`. Viash cannot
  emit a component as a Nextflow module without one, so composing modules was
  not possible at all. The failure does not say so: `viash ns build` reports
  the workflow's 21 dependencies as *missing*.
- No output file argument declared an `example`. Viash takes the extension of
  an auto-generated output filename from `example`; without one the file gets
  no extension, and `np.save` appends `.npy` to a path that lacks it. The
  component wrote `...output_image.npy` while the module looked for
  `...output_image` and reported it missing. The old workflow passed explicit
  paths that already carried the extension, which is why this never showed.

One invocation now runs many chains, and which ones is an argument rather than
an outer bash loop. `--default_methods` names the baseline, one method per
step, and a method that is not a default is only combined with the defaults -
so each non-baseline chain differs from the baseline in exactly one step, which
is what makes a difference in a metric attributable to a single choice. With
the shipped defaults that is 10 chains rather than the 162 a cross-product
would give.

Per-method parameters are no longer workflow arguments. The 40-argument config
collapses to the method-selection lists plus the three metric arguments that
depend on the antibody panel; everything else comes from the component
defaults, or from `--method_parameters_yaml`, which can also sweep one
parameter across values. `--viash_engine` is gone with the shell calls: the
engine is now a Nextflow profile.

`file_score.yaml` stops requiring `dataset_id`, `normalization_id` and
`method_id`. A metric here cannot know them - the result comes from a chain of
five methods and the file a metric reads carries no record of the four steps
before the last. The workflow attaches them instead, which is the only place
that has them. The file now describes what metrics do write, and the six metric
contracts merge it into their `--output`.

Verified end to end on a 512x512 crop of exemplar-001 under the native engine:
10 chains x 6 metric families = 60 score records over 82 distinct metric ids.
The axes separate as they do on the full image - `n_cells` 239 for threshold
against 293 for watershed, `qc_pass_rate` 1.00 / 0.91 / 0.55 across the three
QC methods, and `variance_explained_by_covariate_counts` 0.788 for `sum`
against 0.035 for `mean`. Chains differing only in normalization report
identical segmentation metrics, as they must when normalization is per-cell.
A separate run exercised `--method_parameters_yaml`: the `default` block
reached every variant and each swept value reached its own run.

`viash ns test --engine native`: 21/21 SUCCESS.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sergiomarco25
sergiomarco25 merged commit d282030 into main Nov 27, 2026
22 checks passed
@sergiomarco25 sergiomarco25 mentioned this pull request Nov 27, 2026
3 of 8 tasks
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.

1 participant