Skip to content

Commit

Permalink
Merge pull request #140 from nextstrain/auto-deploy-dated-private-builds
Browse files Browse the repository at this point in the history
Automatically deploy dated builds to nextflu-private group
  • Loading branch information
huddlej authored Jan 12, 2024
2 parents 8971a2c + 66ffc66 commit 316fad4
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 27 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/run-nextflu-private-builds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ jobs:
--memory 72gib \
--env AWS_ACCESS_KEY_ID \
--env AWS_SECRET_ACCESS_KEY \
--env NEXTSTRAIN_USERNAME \
--env NEXTSTRAIN_PASSWORD \
. \
all \
deploy_all \
all_counts_of_recent_tips_by_clade \
-p \
--configfile profiles/nextflu-private.yaml
8 changes: 4 additions & 4 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ include: "workflow/snakemake_rules/fitness.smk"

include: "workflow/snakemake_rules/report.smk"

if "custom_rules" in config:
for rule_file in config["custom_rules"]:
include: rule_file

def _get_build_outputs():
outputs = []
for build_name, build_params in config["builds"].items():
Expand All @@ -60,6 +56,10 @@ def _get_build_outputs():

return outputs

if "custom_rules" in config:
for rule_file in config["custom_rules"]:
include: rule_file

rule all:
input:
_get_build_outputs()
4 changes: 4 additions & 0 deletions profiles/nextflu-private.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ custom_rules:
- workflow/snakemake_rules/download_from_s3.smk
- profiles/nextflu-private/antigenic_distances.smk
- profiles/nextflu-private/report.smk
- profiles/nextflu-private/deploy.smk

# URL for auto-deploying builds
deploy_url: https://nextstrain.org/groups/nextflu-private/

fasta_fields:
- strain
Expand Down
26 changes: 4 additions & 22 deletions profiles/nextflu-private/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,10 @@
# Monthly reports on seasonal influenza evolution

## Build trees
## Build and deploy trees

[Run the nextflu-private build with the GitHub Action](https://github.com/nextstrain/seasonal-flu/actions/workflows/run-nextflu-private-builds.yaml).
Use the build summary for the job to track the progress of the builds on AWS Batch and download the final builds.
If trees look reasonable, rename them to match the current date (or the date corresponding to when the data were updated).

``` bash
export DATE=2022-10-03
cd auspice/

for file in {h1n1pdm,h3n2,vic}*
do
mv ${file} "flu_seasonal_${DATE}_${file}"
done
```

Upload the files to the Nextstrain group.

``` bash
nextstrain remote upload \
https://nextstrain.org/groups/nextflu-private/ \
*.json
```
[Run the nextflu-private builds with the GitHub Action](https://github.com/nextstrain/seasonal-flu/actions/workflows/run-nextflu-private-builds.yaml).
The workflow automatically deploys dated Auspice JSONs to [the nextflu-private group](https://nextstrain.org/groups/nextflu-private/) (e.g., https://nextstrain.org/groups/nextflu-private/flu/seasonal/2024-01-08/h3n2/2y/ha).
View the GitHub Action summary for details about how to download the build artifacts from AWS Batch.

## Prepare a report

Expand Down
30 changes: 30 additions & 0 deletions profiles/nextflu-private/deploy.smk
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
This part of the workflow handles automatic deployments of nextflu-private builds.
"""

rule all_private:
input:
jsons=_get_build_outputs(),
output:
json_dir=directory("auspice_renamed"),
params:
build_date=datetime.date.today().strftime("%Y-%m-%d"),
shell:
"""
mkdir -p {output.json_dir};
for file in {input.jsons}
do
ln ${{file}} {output.json_dir}/"flu_seasonal_{params.build_date}_`basename ${{file}}`"
done
"""

rule deploy_all:
input:
json_dir=directory("auspice_renamed"),
params:
deploy_url = config["deploy_url"]
shell:
"""
nextstrain login --no-prompt;
nextstrain remote upload {params.deploy_url} {input.json_dir}/*.json
"""

0 comments on commit 316fad4

Please sign in to comment.