nextflow icon indicating copy to clipboard operation
nextflow copied to clipboard

Separate CLI from runtime

Open bentsherman opened this issue 7 months ago โ€ข 8 comments

This PR splits the nextflow module into two modules:

  • nextflow: contains only the Launcher and CLI classes
  • nf-runtime: contains everything (i.e. the "runtime")

Benefits:

  • Improves build time, editing CLI code doesn't rebuild the entire project
  • Removes some circular dependencies, making the code easier to read/understand
  • Library consumers like platform or plugins can just depend on the runtime and not the CLI
  • Makes it easier to implement a CLI v2 in the future

I left ConfigBuilder in the CLI module for now because it is a tangled mess. In a follow-up PR I would like to separate the "core" ConfigBuilder from the extra CLI logic (e.g. ConfigCliAdapter)

Note to self: could also keep nextflow as it is and move the CLI code into a separate module e.g. nextflow-cli.

bentsherman avatar Apr 14 '25 14:04 bentsherman

Deploy Preview for nextflow-docs-staging canceled.

Name Link
Latest commit 43053fb70bc98cf7d9da69e438d411a58a9a5d7d
Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/686e700078338e0008cc8729

netlify[bot] avatar Apr 14 '25 14:04 netlify[bot]

Due to the nature of this PR, I will keep it updated via rebase instead of merge commits so that the changes are as clear as possible.

bentsherman avatar Apr 14 '25 14:04 bentsherman

oh mamma mia ๐Ÿ˜†

pditommaso avatar Apr 14 '25 18:04 pditommaso

Your k8s plugin inspired me ๐Ÿ˜„

bentsherman avatar Apr 14 '25 18:04 bentsherman

I feared that ๐Ÿ˜†

pditommaso avatar Apr 14 '25 18:04 pditommaso

Jokes aside, it might be good to do the actual code changes in a separate PR so that the nf-runtime part is as clean as possible

The nf-runtime refactor was just the easiest way to reveal the circular dependencies

bentsherman avatar Apr 14 '25 18:04 bentsherman

I'll review post 25.04

pditommaso avatar Apr 14 '25 18:04 pditommaso

Refactored so that the CLI code is in a new module nf-cli-v1. Made the PR considerably smaller

Note the following plugins depend explicitly on the CLI code because they add CLI commands:

  • nf-console
  • nf-k8s
  • nf-tower
  • nf-wave

Might be possible to remove this dependency by moving some interfaces into the core runtime, but not a big deal either way

bentsherman avatar Apr 17 '25 01:04 bentsherman

I refactored the nf-lineage module to depend on nextflow and be required by nf-cli-v1. This removes the need for the LinCommand interface as the lineage command can simply use LinCommandImpl directly.

Couldn't quite do this for nf-k8s because the K8sDriverLauncher uses CmdRun, so that's a pretty hard dependency on the CLI v1. We could make nf-k8s a module instead of a plugin, but then it would be included at build-time instead of runtime.

bentsherman avatar Jun 18 '25 21:06 bentsherman

Did I break anything? I see some tests failing. Also trying locally I get

ยป ./launch.sh run hello

 N E X T F L O W   ~  version 25.06.0-edge

NOTE: Your local project version looks outdated - a different revision is available in the remote repository [2ce0b0e294]
Launching `https://github.com/nextflow-io/hello` [backstabbing_ride] DSL2 - revision: afff16a9b4 [master]

ERROR ~ No such variable: session

pditommaso avatar Jul 08 '25 17:07 pditommaso

Did I break anything? I see some tests failing. Also trying locally I get

Actually that's my fault, looks like a regression from #6257 . I will submit a separate fix

bentsherman avatar Jul 08 '25 19:07 bentsherman

Found some possible solutions for decoupling nf-k8s, nf-tower, and nf-wave from CLI v1. See top comment for details.

bentsherman avatar Jul 08 '25 20:07 bentsherman