Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create demo of running the workflow on a larger github-actions runner #38

Merged
merged 51 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
0ac19f1
Switch to html
kelly-sovacool Jan 25, 2023
1da2581
Ignore .zip archive
kelly-sovacool Jan 25, 2023
5cc2db1
Create an archive with the self-contained report
kelly-sovacool Jan 25, 2023
d395a98
Test chatops demo
kelly-sovacool Jan 25, 2023
a50bbe9
Merge d395a988ebd5bc708d84dfd6d969351f1f50bb46 into 242011a5065941a6d…
kelly-sovacool Jan 25, 2023
18767c5
Use logfile for archive rule
kelly-sovacool Jan 25, 2023
35642aa
🎨 Style Python & Snakemake code 🐍
github-actions[bot] Jan 25, 2023
bd9f549
🐳 Update Dockerfile
github-actions[bot] Jan 25, 2023
48a5a64
Drop non-mandatory inputs for prcomm
kelly-sovacool Jan 25, 2023
38cafc2
Merge branch 'iss-35' of https://github.com/SchlossLab/mikropml-snake…
kelly-sovacool Jan 25, 2023
2d18998
Merge 38cafc2778cdd7b884516165d3d5b30aa41237c0 into 242011a5065941a6d…
kelly-sovacool Jan 25, 2023
373cb2f
🎨 Style Python & Snakemake code 🐍
github-actions[bot] Jan 25, 2023
79dc1bc
Use a log for move_html
kelly-sovacool Jan 25, 2023
b86c837
Merge branch 'iss-35' of https://github.com/SchlossLab/mikropml-snake…
kelly-sovacool Jan 25, 2023
d36a76f
Merge b86c83756f9d5bad19f473203c06cabec5545801 into 242011a5065941a6d…
kelly-sovacool Jan 25, 2023
567551f
🎨 Style Python & Snakemake code 🐍
github-actions[bot] Jan 25, 2023
fff5e0b
Only run chatops if PR contains trigger phrase
kelly-sovacool Jan 25, 2023
ff0ae91
Merge branch 'iss-35' of https://github.com/SchlossLab/mikropml-snake…
kelly-sovacool Jan 25, 2023
25103fd
Scrap chatops idea
kelly-sovacool Jan 25, 2023
7ed75a2
Run on PR
kelly-sovacool Jan 25, 2023
860c503
Rename run-snakemake workflow
kelly-sovacool Jan 25, 2023
1f98152
Need zip cmd
kelly-sovacool Jan 25, 2023
15c39b3
Use v3 for actions/upload-artifact
kelly-sovacool Jan 25, 2023
f20bb40
Merge 15c39b3e0a7e4b7a45a04aa2f28c539a097ef5a6 into 242011a5065941a6d…
kelly-sovacool Jan 25, 2023
6978030
🎨 Style Python & Snakemake code 🐍
github-actions[bot] Jan 25, 2023
250ac0a
🐳 Update Dockerfile
github-actions[bot] Jan 25, 2023
7fea66a
Test run-snakemake on free runner for debugging
kelly-sovacool Jan 25, 2023
928db6e
Merge branch 'iss-35' of https://github.com/SchlossLab/mikropml-snake…
kelly-sovacool Jan 25, 2023
9da3da1
Merge 928db6ea287d2bf3d4c02ddbdfc528ed6b8faca8 into 242011a5065941a6d…
kelly-sovacool Jan 25, 2023
259d0af
Use singularity for running the test workflow
kelly-sovacool Jan 25, 2023
2c72f0a
Merge branch 'iss-35' of https://github.com/SchlossLab/mikropml-snake…
kelly-sovacool Jan 25, 2023
733d562
Use same flags as test run for now
kelly-sovacool Jan 25, 2023
fec5f08
Merge 733d562d4ee2e65129aeda4a3af58d91072756cb into 242011a5065941a6d…
kelly-sovacool Jan 25, 2023
b96052e
jk don't use singularity for now
kelly-sovacool Jan 25, 2023
b24415b
Merge branch 'iss-35' of https://github.com/SchlossLab/mikropml-snake…
kelly-sovacool Jan 25, 2023
35705cf
Merge b24415b6e4d4a37fb1edd9a7ec688e976145be29 into 242011a5065941a6d…
kelly-sovacool Jan 25, 2023
178963d
Trigger workflow manually w/ configfile input
kelly-sovacool Jan 25, 2023
13d0a13
Drop all-temp flag
kelly-sovacool Jan 25, 2023
8d0af7d
Merge 13d0a13a148aa29144ee906d48cb9a438f22c87d into 242011a5065941a6d…
kelly-sovacool Jan 25, 2023
292dfca
Keep figures in archive; self-contained html doesn't work
kelly-sovacool Jan 25, 2023
b18a995
Merge 292dfca79460c7db7cbbad4a2e9bf25ae873c581 into 242011a5065941a6d…
kelly-sovacool Jan 25, 2023
048f3e3
🎨 Style Python & Snakemake code 🐍
github-actions[bot] Jan 25, 2023
e966bab
Include rulegraph figure in archive
kelly-sovacool Jan 26, 2023
fce9ebc
Simplify archive inputs
kelly-sovacool Jan 26, 2023
3b6b12b
Merge branch 'iss-35' of https://github.com/SchlossLab/mikropml-snake…
kelly-sovacool Jan 26, 2023
bed2669
Merge branch 'workflow-dispatch' into iss-35
kelly-sovacool Jan 26, 2023
5df7af0
Merge bed2669ee3f76b032e3f1f667a3c188e268fc54d into 242011a5065941a6d…
kelly-sovacool Jan 26, 2023
e9c9dd2
🎨 Style Python & Snakemake code 🐍
github-actions[bot] Jan 26, 2023
1df1418
Use the runner w/ 16 cores
kelly-sovacool Jan 26, 2023
391113b
Merge branch 'iss-35' of https://github.com/SchlossLab/mikropml-snake…
kelly-sovacool Jan 26, 2023
ddd5b1d
Merge 391113b615b66ba5082b3bedae16a72296d592db into 242011a5065941a6d…
kelly-sovacool Jan 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/run-snakemake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: run-snakemake

on:
workflow_dispatch:
inputs:
configfile:
description: "Path to the config file"
required: true
default: 'config/test.yaml'
type: string

jobs:
run-snakemake:
runs-on: ubuntu-latest-16-cores
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- uses: conda-incubator/setup-miniconda@v2
with:
python-version: 3.11
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: smk
environment-file: workflow/envs/smk.yml
- name: Run the snakemake workflow
uses: snakemake/[email protected]
with:
directory: .
snakefile: workflow/Snakefile
args: "--cores 16 --use-conda --conda-frontend mamba --conda-cleanup-pkgs cache --show-failed-logs --configfile ${{ inputs.configfile }}"
- uses: actions/upload-artifact@v3
if: failure()
with:
name: log
path: log/
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Upload archive
uses: actions/upload-artifact@v3
with:
name: workflow-results
path: workflow_*.zip
if-no-files-found: warn

2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
with:
directory: .
snakefile: workflow/Snakefile
args: "--use-conda --show-failed-logs --cores 2 --conda-cleanup-pkgs cache --all-temp --conda-frontend mamba --configfile config/test.yaml"
args: "--cores 2 --use-conda --conda-frontend mamba --conda-cleanup-pkgs cache --show-failed-logs --all-temp --configfile config/test.yaml"
# - name: Test with pytest
# run: |
# pytest --workers 2 .tests/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ __pycache__/
figures/otu*
results/otu*
report_otu*
*.zip
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM condaforge/mambaforge:latest
LABEL io.github.snakemake.containerized="true"
LABEL io.github.snakemake.conda_env_hash="a3713ec99770d7dcc2bbdbe9b79e1a9f0c798f396d49f533486fb3193730b7b3"
LABEL io.github.snakemake.conda_env_hash="d6e12a7cc311122c424028af8b7df4211faef9b3f3bc94298fd01affb1243862"

# Step 1: Retrieve conda environments

Expand Down Expand Up @@ -41,20 +41,21 @@ COPY workflow/envs/mikropml.yml /conda-envs/67570867c99c9c3db185b41548ad6071/env

# Conda environment:
# source: workflow/envs/smk.yml
# prefix: /conda-envs/9af38ac9af9135264be16dd13f279cd7
# prefix: /conda-envs/457b7b75191d44b96e5086432876e333
# name: smk
# channels:
# - conda-forge
# - bioconda
# dependencies:
# - snakemake=7
# - snakedeploy
RUN mkdir -p /conda-envs/9af38ac9af9135264be16dd13f279cd7
COPY workflow/envs/smk.yml /conda-envs/9af38ac9af9135264be16dd13f279cd7/environment.yaml
# - zip
RUN mkdir -p /conda-envs/457b7b75191d44b96e5086432876e333
COPY workflow/envs/smk.yml /conda-envs/457b7b75191d44b96e5086432876e333/environment.yaml

# Step 2: Generate conda environments

RUN mamba env create --prefix /conda-envs/b42323b0ffd5d034544511c9db1bdead --file /conda-envs/b42323b0ffd5d034544511c9db1bdead/environment.yaml && \
mamba env create --prefix /conda-envs/67570867c99c9c3db185b41548ad6071 --file /conda-envs/67570867c99c9c3db185b41548ad6071/environment.yaml && \
mamba env create --prefix /conda-envs/9af38ac9af9135264be16dd13f279cd7 --file /conda-envs/9af38ac9af9135264be16dd13f279cd7/environment.yaml && \
mamba env create --prefix /conda-envs/457b7b75191d44b96e5086432876e333 --file /conda-envs/457b7b75191d44b96e5086432876e333/environment.yaml && \
mamba clean --all -y
26 changes: 24 additions & 2 deletions workflow/Snakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
import os
from snakemake.utils import min_version
import sys
Expand Down Expand Up @@ -50,7 +51,7 @@ report: "report/workflow.rst"

rule targets:
input:
f"report_{dataset}.md",
f"workflow_{dataset}.zip",


rule render_report:
Expand All @@ -64,7 +65,7 @@ rule render_report:
roc_plot=rules.plot_roc_curves.output.plot,
rulegraph="figures/graphviz/rulegraph.png",
output:
doc="report_{dataset}.md",
html="report_{dataset}.html",
log:
"log/{dataset}/render_report.txt",
params:
Expand All @@ -79,3 +80,24 @@ rule render_report:
"envs/mikropml.yml"
script:
"scripts/report.Rmd"


rule archive:
input:
rules.render_report.input,
rules.render_report.output,
expand(
"results/{dataset}/{rtype}_results.csv",
dataset=dataset,
rtype=["performance", "feature-importance", "benchmarks", "sensspec"],
),
output:
"workflow_{dataset}.zip",
log:
"log/archive_{dataset}.txt",
conda:
"envs/smk.yml"
shell:
"""
zip -r {output} {input} 2> {log}
"""
1 change: 1 addition & 0 deletions workflow/envs/smk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ channels:
dependencies:
- snakemake=7
- snakedeploy
- zip
16 changes: 10 additions & 6 deletions workflow/scripts/report.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
title: "ML Results"
date: "`r Sys.Date()`"
output:
github_document:
html_preview: false
html_document:
keep_md: true
self_contained: true
theme: spacelab
---

```{r setup, include=FALSE}
Expand All @@ -14,14 +16,16 @@ schtools::set_knitr_opts()
library(knitr)
```

Machine learning algorithms used were `r snakemake@params[['ml_methods']]`.
Machine learning algorithm(s) used: `r snakemake@params[['ml_methods']]`.
Models were trained with `r snakemake@params[['nseeds']]` different random
partitions of the `r snakemake@params[['dataset']]` dataset into training and
testing sets using `r snakemake@params[['kfold']]`-fold cross validation.
See ``r snakemake@params[['config_path']]`` for the full configuration.

## Workflow

`r snakemake@input[['rulegraph']]`

```{r rulegraph, out.width = '80%'}
include_graphics(snakemake@input[['rulegraph']])
```
Expand All @@ -48,13 +52,13 @@ include_graphics(snakemake@input[['feat_plot']])

## Memory Usage & Runtime

Each model training run was given `r snakemake@params[['ncores']]` cores
for parallelization.

```{r runtime_plot, out.width='80%'}
include_graphics(snakemake@input[['bench_plot']])
```

Each model training run was given `r snakemake@params[['ncores']]` cores
for parallelization.

## Hyperparameter Performance

```{r hp_plot, out.width='80%'}
Expand Down