Skip to content

Commit

Permalink
Merge pull request CCBR#115 from CCBR/iss-113
Browse files Browse the repository at this point in the history
test: show that sif images are cached correctly
  • Loading branch information
slsevilla authored Feb 28, 2024
2 parents 2175dc5 + 8ab1a81 commit 54099ff
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 10 deletions.
27 changes: 19 additions & 8 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Dry-run pipeline
run: |
docker run -v $PWD:/opt2 -w /opt2 snakemake/snakemake:v5.24.2 \
python ./src/renee/__main__.py run \
python src/renee/__main__.py run \
--input .tests/KO_S3.R1.fastq.gz .tests/KO_S3.R2.fastq.gz .tests/KO_S4.R1.fastq.gz .tests/KO_S4.R2.fastq.gz .tests/WT_S1.R1.fastq.gz .tests/WT_S1.R2.fastq.gz .tests/WT_S2.R1.fastq.gz .tests/WT_S2.R2.fastq.gz \
--output output \
--genome config/genomes/biowulf/hg38_30.json \
Expand All @@ -35,23 +35,34 @@ jobs:
strategy:
matrix:
python-version: ["3.11"]
snakemake-version: ["7.32.3"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- uses: mamba-org/setup-micromamba@v1
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: pip
run: |
python -m pip install --upgrade pip setuptools pytest
environment-name: test
cache-environment: true
condarc: |
channels:
- conda-forge
- bioconda
create-args: >-
python=${{ matrix.python-version }}
snakemake=${{ matrix.snakemake-version }}
setuptools
pip
pytest
- name: check CLI basics
run: |
./bin/renee --help
./bin/renee --version
shell: micromamba-shell {0}
- name: Test
run: |
python -m pytest
env:
TMPDIR: ${{ runner.temp }}
shell: micromamba-shell {0}

build-status: # https://github.com/orgs/community/discussions/4324#discussioncomment-3477871
runs-on: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion src/renee/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,6 @@ def setup(sub_args, ifiles, repo_path, output_path):
),
end="",
)
# print(json.dumps(config, indent = 4, sort_keys=True))
with open(os.path.join(output_path, "config.json"), "w") as fh:
json.dump(config, fh, indent=4, sort_keys=True)
print("Done!")
Expand Down
Empty file.
48 changes: 48 additions & 0 deletions tests/test_cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import tempfile
import json
import os.path
import subprocess

renee_run = (
"src/renee/__main__.py run "
"--mode local --runmode init --dry-run "
"--input .tests/*.fastq.gz "
"--genome config/genomes/biowulf/hg38_30.json "
)


def run_in_temp(command_str):
with tempfile.TemporaryDirectory() as tmp_dir:
outdir = os.path.join(tmp_dir, "testout")
output = subprocess.run(
f"{command_str} --output {outdir}",
capture_output=True,
shell=True,
text=True,
)
if os.path.exists(os.path.join(outdir, "config.json")):
with open(os.path.join(outdir, "config.json"), "r") as infile:
config = json.load(infile)
else:
config = None
return output, config


def test_cache_sif():
output, config = run_in_temp(f"{renee_run} --sif-cache tests/data/sifs/")
assertions = [
config["images"]["arriba"].endswith(
"tests/data/sifs/ccbr_arriba_2.0.0_v0.0.1.sif"
),
"does not exist in singularity cache" in output.stderr,
]
assert all(assertions)


def test_cache_nosif():
output, config = run_in_temp(f"{renee_run}")
assertions = [
config["images"]["arriba"] == "docker://nciccbr/ccbr_arriba_2.0.0:v0.0.1",
"The singularity command has to be available" in output.stderr,
]
assert all(assertions)
17 changes: 16 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import pytest
import subprocess
from src.renee.__main__ import exists

renee_run = (
"src/renee/__main__.py run "
"--mode local --runmode init --dry-run "
"--input .tests/*.fastq.gz "
"--genome config/genomes/biowulf/hg38_30.json "
)


def test_help():
Expand All @@ -15,3 +21,12 @@ def test_version():
"src/renee/__main__.py --version", capture_output=True, shell=True, text=True
).stdout
assert "renee v" in output


def test_run_error():
assert (
"the following arguments are required: --output"
in subprocess.run(
f"{renee_run}", capture_output=True, shell=True, text=True
).stderr
)

0 comments on commit 54099ff

Please sign in to comment.