Repository navigation
Open
Description
This is a meta-issue for tracking work around "workflows as programs". Extracted from Q3 planning meeting notes by @genehack. Fleshed out by @tsibley.
Background
- 5 Nov 2024 lab meeting slides
- 9 Sept 2021 lab meeting slides
- Lots more in my personal notes and written up in Slack
Tooling
- Grab bag of bug fixes and improvements cli#419
- Workflows-as-programs:
nextstrain runcli#407 - entrypoint-aws-batch: Keep ../ path parts in ZIP archive members during extraction docker-base#241
- Nextstrain CLI and nextstrain.org: endpoints for pathogen resolution
- Pathogen repo usage flow cli#504
- Document what "compatible with nextstrain run" means pathogen-repo-guide#102
- Lay down the way for pathogen documentation with an example or two
- Nextstrain CLI: commands for accessing version-specific pathogen docs? (see also, see also)
-
nextstrain run: Define available workflows in thenextstrain-pathogen.yamlcli#454 - Add schema for
nextstrain-pathogen.yamlcli#466 - Write up and document design notes with additions from my Nov 2024 lab meeting
- Nextstrain CLI: better UX for orgs with their own GitHub repos, e.g.
my-org/my-pathogen(see also) -
nextstrain run: unmanaged pathogen support? cli#420 -
nextstrain update: Confusing log message when nothing was changed cli#265 - Nextstrain CLI: roll back setups/updates that fail (e.g. checks fail)? (see also, see also)
- Nextstrain CLI: removal of set up pathogens (and runtimes);
nextstrain teardown? - Nextstrain CLI: auto-cleanup of old pathogens after upgrade?
- Nextstrain CLI:
check-setupsupport for pathogens? - Bundle runtimes with pathogen repos cli#448
Pathogens
- Workflows-as-programs support measles#55
- Allow running workflow from outside of repo avian-flu#103
- Multiple inputs / overriding inputs avian-flu#112
- Update workflows to support
nextstrain runzika#85 - Add support for workflows as programs mumps#36
- Update workflows for
nextstrain runpathogen-repo-guide#93 - Support nextstrain run (with augur subsample) WNV#105
- Grab bag of various fixups nipah#17
- mpox
- work needed to allow users to run analyses separate to pathogen workflows pathogen-repo-guide#74
- Standardized composable configs pathogen-repo-guide#79
Testing
- Partner with INRB, WA DOH, and/or external ncov users to beta-test
nextstrain runand gather feedback
Metadata
Metadata
Assignees
Labels
No labels
Activity
huddlej commentedon Nov 5, 2024
One question that occurred to me during @tsibley's lab meeting on this topic today is: do we want to guarantee that users can run our Nextstrain workflows with
snakemakeinstead of withnextstrain?I was thinking about how the workflow authors need to define shared functions (like
shared/functions.smkfrom the measles PR) within and across pathogen repos and hownextstrain runcould always inject shared logic into the workflows or provide a runtime environment that guarantees those functions will be available. But that kind of approach would break the workflows with vanillasnakemake. Even if code injection is a terrible idea, it made me wonder about our long-term guarantees that Nextstrain workflows will always work with Snakemake...genehack commentedon Nov 7, 2024
Copying this (and mildly cleaning it up) from a comment I sent to @tsibley on Slack after his lab meeting:
I suspect for many current “authors” this is going to feel like more work for little-to-no return; I think one way to assuage some of that would be to try as hard as possible to make the requirements of extra “stuff” in
config.yamland the snakemake rules as minimal as possible — for example, instead of requiring helpers to do path translations, what ifnextstrain runpre-parsed the workflow config and the snakerules and automatically applied those transformations? (or attempted to and introspected the filesystem with fallbacks, etc.)I wonder if something like the mpox clade I builds, or something WA DOH is working on, wouldn’t make for a better initial implementation target — a lot (most? all?) of the benefits to doing this will be to the “external consumer” part of the experience; would make sense to do prototype runs on something where we can get feedback from somebody in that external pool as quickly as possible
tsibley commentedon Nov 7, 2024
To @huddlej and @genehack's suggestions re: adding more "magic": I think it'd be more complicating and mystifying for authors (and readers) if we use techniques like code injection or config/workflow rewriting or similar. I don't want to rule out using such "magic" techniques in the future—they may prove to be the best way to meet our eventual goals/expectations—but for now I think it would be way more complex and fragile than making clear guidelines that all file paths from the config that have defaults should be wrapped in a function call.
As @huddlej notes, adding magic also ruins the ability to run workflows directly with Snakemake, and at least for now, I think we want to preserve that ability. (Though again, I wouldn't rule it out for the future.)
To @genehack's explicit concern (and @huddlej's implicit concern, if I'm reading correct) around extra stuff to do in authoring, the extra burden for authoring new workflows doesn't feel high to me. The function-wrapped-config-values are going to be mostly copied/cribbed from existing workflows and/or our pathogen-repo-guide template. Our Snakemake best practices will include appropriate guidance as reference material.
While this does create new work to update existing workflows, that is paid once and is straightforward work to do. We also do not need to do it all at once; only as we want a pathogen's support for
nextstrain run.tsibley commentedon Nov 7, 2024
For @genehack's thoughts around initial implementations, I agree that we should consider that and try to pick from existing partners. I was thinking of INRB (see also) in addition to WA DOH. There are also many external users of ncov that could likely benefit from this work and potentially be willing and able to provide valuable feedback if we make them aware of it and how to try it out (e.g. perhaps a post on the discussion forum).
Measles was merely a convenient example for this initial "how do we actually do this" phase (the same way zika or zika-tutorial has been that in the past, though much less so in recent years).
Workflows-as-programs: `nextstrain run` and co.
Workflows-as-programs: `nextstrain run` and co.
Workflows-as-programs: `nextstrain run` and co.
Workflows-as-programs: `nextstrain run` and co.
Workflows-as-programs: `nextstrain run` and co.
Workflows-as-programs: `nextstrain run` and co.
Workflows-as-programs: `nextstrain run` and co.
Workflows-as-programs: `nextstrain run` and co.
11 remaining items
victorlin commentedon Jul 1, 2025
It's not clear to me why these two items are separate:
My understanding is that non-Nextstrain repos are also "unmanaged". This is probably a semantic thing where scoping the first issue to "local support" would clear things up. This was my assumption when writing nextstrain/cli#449.
tsibley commentedon Sep 3, 2025
Ah, so "unmanaged" in my usage here means "not obtained or updated by
nextstrain setup(andupdate, etc)."You're correct that the first issue is about
nextstrain runsupport for local pathogen repos not obtained thrunextstrain setupand thus not "managed" bynextstrain setup(andupdate, etc). Blurring the terminology though is the idea of registering names for local repo paths usingnextstrain setup, thus "managing" it in that sense. This blurring is partly why my preference is for the alternative idea of relying on local paths alone. I'll try to fix up that issue to use clearer terminology.The second issue is about providing the full
nextstrain setupand co. management for third-party pathogen repos, just like our repos enjoy.The first issue makes third-party repos more easily usable under
nextstrain run, but without the same updating support, multi-version support, etc.victorlin commentedon Sep 3, 2025
I see, makes sense now. Thanks for clarifying!
run: Resolve workflow names using pathogen registration, if available
run: Resolve workflow names using pathogen registration, if available
pathogens: Define a schema for nextstrain-pathogen.yaml and validate …
routing/schemas: Add /schemas/pathogen/v0 for nextstrain-pathogen.yaml
pathogens: Define a schema for nextstrain-pathogen.yaml and validate …
pathogens: Define a schema for nextstrain-pathogen.yaml and validate …
pathogens: Define a schema for nextstrain-pathogen.yaml and validate …
pathogens: Define a schema for nextstrain-pathogen.yaml and validate …
pathogens: Define a schema for nextstrain-pathogen.yaml and validate …
pathogens: Define a schema for nextstrain-pathogen.yaml and validate …
tsibley commentedon Nov 7, 2025
Design notes/principles for “workflows as programs”
I originally jotted these down in my personal notes and then collected them in one place a year ago (to the day!). Today, I’ve lightly revised them for clarity and am posting them here for more visibility. I think these are useful things to keep in mind when continuing work on “workflows as programs”.
We never had much of a culture of design docs—though many were certainly written and used—and so there’s not a single obvious place for this. Perhaps it should be incorporated into our overarching pages on docs.nextstrain.org, or perhaps shunted into the “design docs” folder on the shared Google Drive, or perhaps elsewhere. For now, here it remains.
The user-provided directory for inputs, outputs, etc. is the “working analysis directory” in full. This may sometimes be shortened to “analysis directory” (e.g. in conversation, in Nextstrain CLI) or “working directory” (e.g. from Snakemake’s perspective).
nextstrain buildcontinues to work and is not deprecated/phased out.nextstrain runand related workflow-level changes are higher-level wrappings around that (conceptually, if not in actuality).No passthru of arguments to Snakemake à la
nextstrain build. Instead, recapitulate or bundle/wrap options we want to expose. If you must pass arbitrary args to Snakemake, then either usenextstrain buildor invoke Snakemake yourself.Pathogen repos should be versioned (i.e. with Git tags) and keep a changelog.
No magic in workflows. Things that can be done via
nextstrain runshould be able to be done withnextstrain buildtoo, albeit with potentially greater verbosity, but without monumental effort.Workflows are addressed by names not paths. As a fallback, the name may be used to construct a path, but a workflow’s name need not correspond to the workflow’s path.
Hosting of workflows for
nextstrain setupneeds only a ZIP file and static file server (i.e. not a Git server or anything else dynamic).For our own workflows, we point at nextstrain.org and have it resolve to GitHub archive URLs, but that’s not intended to be normative.
Convention of only using the
Snakefilefilename for supported workflow entrypoints, not for imported Snakemake workflow files.Use
workflow.basedirorworkflow.current_basedir; avoidworkflow.source_path(…)(it has issues).These are not compatible with being used as a remote module, but our workflows aren’t used as remote modules. (Used as a local module is fine.)
workflow.basediris the currentSnakefile’s dir, e.g. dir of top-levelSnakefile.workflow.current_basediris the current Snakemake file’s dir, e.g.…/rules/for a…/rules/abc.smk. In the top-levelSnakefile, they’re the same.