Skip to content

Conversation

@joverlee521
Copy link

@joverlee521 joverlee521 commented Sep 26, 2025

Description of proposed changes

The goal of the repo is to present the simplest version of a phylogenetic workflow so I have kept the top level Snakefile and kept the original behavior where the input files are hard-coded in the workflow and cannot be modified via config parameters.

Requires Nextstrain CLI 10.4.0 with support for the workflow name to path mapping to be able to run with

nextstrain setup zika-tutorial@nextstrain-run-support
nextstrain run zika-tutorial@nextstrain-run-support phylogenetic /tmp/zika-tutorial

Related issue(s)

Resolves #18

@tsibley
Copy link
Contributor

tsibley commented Sep 26, 2025

Since the Snakefile is in the top level directory, use . as the workflow name for nextstrain run:

That is a very weird name for a workflow, esp. a workflow we admit is "the simplest version of a phylogenetic workflow" (emphasis mine).

How about we use this opportunity to implement workflow name → directory mapping in nextstrain-pathogen.yaml? e.g. something like:

workflows:
  phylogenetic:
    path: .

which would allow:

nextstrain run zika-tutorial@nextstrain-run-support phylogenetic /tmp/zika-tutorial

Or, alternatively, we could move everything into phylogenetic/ and call it a day for now.

@tsibley
Copy link
Contributor

tsibley commented Sep 26, 2025

How about we use this opportunity to implement workflow name → directory mapping in nextstrain-pathogen.yaml?

If we want this, it's pretty easy to support:

diff --git a/nextstrain/cli/pathogens.py b/nextstrain/cli/pathogens.py
index 5dd0172..411c574 100644
--- a/nextstrain/cli/pathogens.py
+++ b/nextstrain/cli/pathogens.py
@@ -342,8 +342,19 @@ def compatible_workflows(self, feature: str) -> Dict[str, Dict]:
         }
 
 
-    def workflow_path(self, workflow: str) -> Path:
-        return self.path / workflow
+    def workflow_registration(self, workflow_name: str) -> Optional[dict]:
+        if (info := self.registered_workflows().get(workflow_name)) and not isinstance(info, dict):
+            debug(f"pathogen registration.workflows[{workflow_name!r}] is not a dict (got a {type(info).__name__})")
+            return None
+        return info
+
+
+    def workflow_path(self, workflow_name: str) -> Path:
+        if (info := self.workflow_registration(workflow_name)) and (workflow_path := info.get("path")):
+            return self.path / workflow_path
+
+        debug(f"pathogen registration does not specify path for workflow {workflow_name!r}; using name as path")
+        return self.path / workflow_name
 
 
     def setup(self, dry_run: bool = False, force: bool = False) -> SetupStatus:
@@ -747,6 +758,7 @@ def __init__(self, path: str):
 
     registered_workflows = PathogenVersion.registered_workflows
     compatible_workflows = PathogenVersion.compatible_workflows
+    workflow_registration = PathogenVersion.workflow_registration
     workflow_path = PathogenVersion.workflow_path
 
     def __str__(self) -> str:

@tsibley
Copy link
Contributor

tsibley commented Sep 26, 2025

(There's some safeguards we'd want to add, like ensuring the registration-provided path is relative and does not specify a location outside the containing dir.)

@joverlee521
Copy link
Author

That is a very weird name for a workflow, esp. a workflow we admit is "the simplest version of a phylogenetic workflow" (emphasis mine).

Hah, definitely agree! I wasn't happy with the . workflow name hence the draft PR.

How about we use this opportunity to implement workflow name → directory mapping in nextstrain-pathogen.yaml

+1 for workflow name to directory mapping to solve this weirdness.

tsibley added a commit to nextstrain/cli that referenced this pull request Sep 30, 2025
This decoupling of workflow names from paths was always expected and
intended to be possible, and now it is.

Related-to: <nextstrain/zika-tutorial#19>
Related-to: <nextstrain/public#1>
tsibley added a commit to nextstrain/cli that referenced this pull request Sep 30, 2025
This decoupling of workflow names from paths was always expected and
intended to be possible, and now it is.

Related-to: <nextstrain/zika-tutorial#19>
Related-to: <nextstrain/public#1>
@tsibley
Copy link
Contributor

tsibley commented Oct 14, 2025

The release of Nextstrain CLI 10.4.0 yesterday adds support for the workflow name → path mapping.

@joverlee521 joverlee521 force-pushed the nextstrain-run-support branch from e93e1a6 to 6a17025 Compare October 14, 2025 20:38
@joverlee521 joverlee521 marked this pull request as ready for review October 14, 2025 20:38
Keeping the original behavior where the input files are hard-coded in the 
workflow and cannot be modified via config parameters. 

Requires Nextstrain CLI 10.4.0 with support for the workflow name to path 
mapping to be able to run with 

```
nextstrain run zika-tutorial phylogenetic <analysis-dir>
```
@joverlee521 joverlee521 force-pushed the nextstrain-run-support branch from 6a17025 to 4895151 Compare October 14, 2025 21:08
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.

Add support for nextstrain run

3 participants