Skip to content

Workflows as programs #1

Open
Open

Description

@genehack

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

Tooling

Pathogens

Testing

Activity

  1. huddlej commented on Nov 5, 2024

    @huddlej

    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 snakemake instead of with nextstrain?

    I was thinking about how the workflow authors need to define shared functions (like shared/functions.smk from the measles PR) within and across pathogen repos and how nextstrain run could 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 vanilla snakemake. 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...

  2. transferred this issue fromon Nov 6, 2024
  3. transferred this issue fromon Nov 6, 2024
  4. genehack commented on Nov 7, 2024

    @genehack
    ContributorAuthor

    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.yaml and the snakemake rules as minimal as possible — for example, instead of requiring helpers to do path translations, what if nextstrain run pre-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

  5. tsibley commented on Nov 7, 2024

    @tsibley
    Contributor

    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.

  6. tsibley commented on Nov 7, 2024

    @tsibley
    Contributor

    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).

  7. 11 remaining items

  8. victorlin commented on Jul 1, 2025

    @victorlin
    Member

    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.

  9. tsibley commented on Sep 3, 2025

    @tsibley
    Contributor

    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.

    Ah, so "unmanaged" in my usage here means "not obtained or updated by nextstrain setup (and update, etc)."

    You're correct that the first issue is about nextstrain run support for local pathogen repos not obtained thru nextstrain setup and thus not "managed" by nextstrain setup (and update, etc). Blurring the terminology though is the idea of registering names for local repo paths using nextstrain 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 setup and 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.

  10. victorlin commented on Sep 3, 2025

    @victorlin
    Member

    I see, makes sense now. Thanks for clarifying!

  11. tsibley commented on Nov 7, 2025

    @tsibley
    Contributor

    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 build continues to work and is not deprecated/phased out. nextstrain run and 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 use nextstrain build or 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 run should be able to be done with nextstrain build too, 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 setup needs 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 Snakefile filename for supported workflow entrypoints, not for imported Snakemake workflow files.

    • Use workflow.basedir or workflow.current_basedir; avoid workflow.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.basedir is the current Snakefile’s dir, e.g. dir of top-level Snakefile. workflow.current_basedir is the current Snakemake file’s dir, e.g. …/rules/ for a …/rules/abc.smk. In the top-level Snakefile, they’re the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions