Skip to content

perf(components): regenerate container configs once per top-level install/update#4276

Closed
pinin4fjords wants to merge 3 commits into
nf-core:devfrom
pinin4fjords:pinin4fjords/install-perf
Closed

perf(components): regenerate container configs once per top-level install/update#4276
pinin4fjords wants to merge 3 commits into
nf-core:devfrom
pinin4fjords:pinin4fjords/install-perf

Conversation

@pinin4fjords
Copy link
Copy Markdown
Member

@pinin4fjords pinin4fjords commented May 11, 2026

Improvement

nf-core modules/subworkflows install and update were re-running nextflow inspect (via try_generate_container_configs) once for every transitive module dependency rather than once per command. Each call is JVM startup plus pipeline parse (~17 s).

Move the call out of the recursive path:

  • nf_core/components/install.py: gate on not silent. Recursive installs pass silent=True. Also runs at the end of top-level subworkflow installs, which previously skipped regeneration entirely because of the component_type == "modules" guard.
  • nf_core/components/update.py: hoist out of the per-component loop to after it. Skip when --save-diff is set (no changes applied to the working tree).

Behaviour notes (worth flagging in review)

  • Top-level subworkflows install/update now regenerates container configs. Previously skipped entirely because of component_type == "modules". Aligns with the original intent of Command to generate pipeline container config files #3955.
  • --save-diff updates explicitly do not regenerate (dry run).
  • nf-core modules install/update: behaviour unchanged.

Measured impact

nf-core/rnaseq pr-1680, warm cache:

Command Before After
subworkflows install --force bam_dedup_umi 5m 27s 39s
subworkflows update --update-deps --no-preview bam_dedup_umi 4m 4s 44s
Repeating Could not find meta.yml warning lines 36 2

Tests

  • tests/subworkflows/test_install.py::test_subworkflows_install_regenerates_container_configs_once — subworkflow with multiple module deps, regen exactly once.
  • tests/subworkflows/test_update.py::test_subworkflow_update_regenerates_container_configs_once--update-deps cascade, regen exactly once.
  • tests/subworkflows/test_update.py::test_subworkflow_update_save_diff_skips_container_configs--save-diff dry run, regen zero times.
  • tests/modules/test_install.py::test_modules_install_regenerates_container_configs_once — top-level module install regression, regen exactly once.

Validation requested

  • CI passes (existing install/update tests).
  • Behaviour check confirmed: nf-core subworkflows install <X> now regenerates container configs at the top level (previously skipped).
  • Behaviour check confirmed: nf-core modules install <X> still regenerates exactly once (unchanged).
  • Behaviour check confirmed: nf-core ... update --save-diff <X> does not regenerate.

…tall/update

`install` and `update` were re-running `nextflow inspect` (via
`try_generate_container_configs`) once for every transitive module
dependency instead of once per command. Each call is JVM startup plus
pipeline parse (~17 s), so a subworkflow with 18 module deps spent
~5 minutes in container-config regeneration alone.

- `install.py`: gate the call on `not silent`. Recursive installs from
  `install_included_components` pass `silent=True`. Also fixes top-level
  subworkflow installs, which previously skipped regeneration entirely
  because of the `component_type == "modules"` guard.
- `update.py`: hoist the call out of the per-component loop to after
  it, and skip when `--save-diff` is in effect (no changes are applied
  to the working tree).

Measured against nf-core/rnaseq `pr-1680`, warm cache:

  subworkflows install --force bam_dedup_umi               5m27s → 39s
  subworkflows update --update-deps --no-preview ...       4m 4s → 44s
  Repeating "Could not find meta.yml" warning lines           36 → 2

Two new tests mock `try_generate_container_configs` and assert it is
invoked exactly once for an install/update that touches multiple module
dependencies.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.27%. Comparing base (b6af91a) to head (750507b).

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

pinin4fjords and others added 2 commits May 11, 2026 11:40
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Add a regression test for `nf-core modules install`: regen runs once
  for a single top-level module install.
- Add a regression test for `--save-diff`: regen must be skipped during
  a dry-run update so the pipeline's containers_*.config files don't
  drift while the user is still reviewing the patch.
- Shorten the in-source comments at the two call sites.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pinin4fjords pinin4fjords marked this pull request as ready for review May 11, 2026 10:55
@pinin4fjords pinin4fjords requested a review from mashehu May 11, 2026 10:58
@pinin4fjords
Copy link
Copy Markdown
Member Author

Closing in favour of #4277, which removes the nextflow inspect and check_nextflow_version subprocess calls from try_generate_container_configs entirely (regex-based parsing instead). That fully subsumes the perf win this PR was after — the 18× recursive call no longer matters once each call is essentially free.

Leaving the tests and PR body here for reference in case any of the regression assertions (top-level subworkflow install/update regenerates configs once; --save-diff skips regen) are worth lifting into #4277 or a follow-up.

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