Skip to content

Commit

Permalink
Merge pull request #22 from percyfal/fix-slurm-utils
Browse files Browse the repository at this point in the history
Update test architecture
  • Loading branch information
percyfal authored Jul 22, 2023
2 parents a0e559e + 20a72fb commit 6da0c44
Show file tree
Hide file tree
Showing 7 changed files with 271 additions and 27 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/slurm.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Test SnakemakeProfiles/slurm
env:
SNAKEMAKE_IMAGE: quay.io/biocontainers/snakemake:7.3.2--hdfd78af_0
SNAKEMAKE_IMAGE: quay.io/biocontainers/snakemake:7.30.1--hdfd78af_0
SLURM_IMAGE: giovtorres/docker-centos7-slurm:20.11.8
DOCKER_COMPOSE: tests/docker-compose.yaml

Expand All @@ -12,17 +12,21 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v3

- run: mkdir -p ~/image-cache
- name: cache-conda
uses: actions/cache@v2

- name: cache conda environment
uses: actions/cache@v3
env:
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('test-environment.yml') }}
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('conda-linux-64.lock') }}

- uses: actions/cache@v2
- name: cache images
uses: actions/cache@v3
id: cache-images
env:
CACHE_NUMBER: 0
Expand All @@ -33,10 +37,8 @@ jobs:
- name: install miniconda
uses: conda-incubator/setup-miniconda@v2
with:
mamba-version: "*"
channels: conda-forge,bioconda,default
channel-priority: true
environment-file: test-environment.yml
miniconda-version: "latest"
environment-file: conda-linux-64.lock
use-only-tar-bz2: true

- name: docker swarm init
Expand Down
225 changes: 225 additions & 0 deletions conda-linux-64.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
addopts = --keep-baked-projects -v -s
2 changes: 1 addition & 1 deletion test-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ dependencies:
- pyflakes
- snakemake
- urllib3
- cryptography <=37.0.0
- cryptography
2 changes: 1 addition & 1 deletion tests/deploystack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
DOCKER_COMPOSE=${DOCKER_COMPOSE:=docker-compose.yaml}

# Images
SNAKEMAKE_IMAGE=${SNAKEMAKE_IMAGE:=quay.io/biocontainers/snakemake:7.3.2--hdfd78af_0}
SNAKEMAKE_IMAGE=${SNAKEMAKE_IMAGE:=quay.io/biocontainers/snakemake:7.30.1--hdfd78af_0}
SLURM_IMAGE=${SLURM_IMAGE:=giovtorres/docker-centos7-slurm:20.11.8}

docker pull $SNAKEMAKE_IMAGE
Expand Down
2 changes: 1 addition & 1 deletion tests/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'
services:
snakemake:
image: quay.io/biocontainers/snakemake:7.3.2--hdfd78af_0
image: quay.io/biocontainers/snakemake:7.30.1--hdfd78af_0
hostname: slurmctl
command: /bin/bash
deploy:
Expand Down
43 changes: 29 additions & 14 deletions tests/test_cookie.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import sys
import pytest
from unittest.mock import patch


@pytest.mark.parametrize("sidecar", ["yes", "no"])
Expand All @@ -20,24 +21,38 @@ def test_bake_project(cookies, sidecar):

def test_cookiecutter(cookies, monkeypatch):
result = cookies.bake(template=str(pytest.cookie_template))
monkeypatch.syspath_prepend(str(result.project_path))
from CookieCutter import CookieCutter
assert CookieCutter.SBATCH_DEFAULTS == ""
assert CookieCutter.CLUSTER_NAME == ""
assert CookieCutter.CLUSTER_CONFIG == ""
assert CookieCutter.get_cluster_option() == ""
sys.modules.pop("CookieCutter")
assert result.exit_code == 0
assert result.exception is None

assert result.project_path.name == "slurm"
assert result.project_path.is_dir()
with patch.dict(sys.modules):
if "CookieCutter" in sys.modules:
del sys.modules["CookieCutter"]
monkeypatch.syspath_prepend(str(result.project_path))
from CookieCutter import CookieCutter
assert CookieCutter.SBATCH_DEFAULTS == ""
assert CookieCutter.CLUSTER_NAME == ""
assert CookieCutter.CLUSTER_CONFIG == ""
assert CookieCutter.get_cluster_option() == ""


def test_cookiecutter_extra_context(cookies, monkeypatch):
result = cookies.bake(template=str(pytest.cookie_template),
extra_context={"sbatch_defaults": "account=foo",
"cluster_name": "dusk",
"cluster_config": "slurm.yaml"})
monkeypatch.syspath_prepend(str(result.project_path))
from CookieCutter import CookieCutter
assert CookieCutter.SBATCH_DEFAULTS == "account=foo"
assert CookieCutter.CLUSTER_NAME == "dusk"
assert CookieCutter.CLUSTER_CONFIG == "slurm.yaml"
assert CookieCutter.get_cluster_option() == "--cluster=dusk"
sys.modules.pop("CookieCutter")
assert result.exit_code == 0
assert result.exception is None

assert result.project_path.name == "slurm"
assert result.project_path.is_dir()
with patch.dict(sys.modules):
if "CookieCutter" in sys.modules:
del sys.modules["CookieCutter"]
monkeypatch.syspath_prepend(str(result.project_path))
from CookieCutter import CookieCutter
assert CookieCutter.SBATCH_DEFAULTS == "account=foo"
assert CookieCutter.CLUSTER_NAME == "dusk"
assert CookieCutter.CLUSTER_CONFIG == "slurm.yaml"
assert CookieCutter.get_cluster_option() == "--cluster=dusk"

0 comments on commit 6da0c44

Please sign in to comment.