Skip to content

Commit

Permalink
fix: lowercase SIFs dir (#23)
Browse files Browse the repository at this point in the history
* fix: lowercase SIFs dir

see CCBR/RENEE#181

* refactor: make singularity_sif_dir a dynamic property

* test: sif cache logic

* test: hpc class repr

* chore: update CHANGELOG.md

* ci: 🤖 render readme

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
kelly-sovacool and github-actions[bot] authored Dec 2, 2024
1 parent 727a622 commit 3e60ed9
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- use major & minor version for docs website subdirectories. (#15, @kelly-sovacool)
- fig bug where `nextflow.run()` did not import the correct HPC modules. (#20, @kelly-sovacool)
- fix bug in `_get_file_mtime()`. (#21, @kelly-sovacool)
- fix shared SIF cache directory spelling for biowulf. (#23, @kelly-sovacool)


## Tools 0.1.1

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import ccbr_tools.pkg_util
print(ccbr_tools.pkg_util.get_version())
```

0.1.1-dev
0.1.2-dev

## CLI Utilities

Expand Down Expand Up @@ -122,15 +122,15 @@ package and do not have any unit tests.
Please cite this software if you use it in a publication:

> Sovacool K., Koparde V., Kuhn S., Tandon M., Huse S. (2024). CCBR
> Tools: Utilities for CCBR Bioinformatics Software (version v0.1.0).
> Tools: Utilities for CCBR Bioinformatics Software (version v0.1.2).
> DOI: 10.5281/zenodo.13377166 URL: https://ccbr.github.io/Tools/
### Bibtex entry

@misc{YourReferenceHere,
author = {Sovacool, Kelly and Koparde, Vishal and Kuhn, Skyler and Tandon, Mayank and Huse, Susan},
doi = {10.5281/zenodo.13377166},
month = {8},
month = {11},
title = {CCBR Tools: Utilities for CCBR Bioinformatics Software},
url = {https://ccbr.github.io/Tools/},
year = {2024}
Expand Down
4 changes: 2 additions & 2 deletions src/ccbr_tools/pipeline/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def get_singularity_cachedir(output_dir=None, cache_dir=None):


def get_sif_cache_dir(hpc=None):
sif_dir = None
sif_dir = ""
if hpc == "biowulf":
sif_dir = "/data/CCBR_Pipeliner/SIFS"
sif_dir = "/data/CCBR_Pipeliner/SIFs"
elif hpc == "frce":
sif_dir = "/mnt/projects/CCBR-Pipelines/SIFs"
return sif_dir
Expand Down
14 changes: 9 additions & 5 deletions src/ccbr_tools/pipeline/hpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
which contains default attributes for supported clusters.
"""

from .cache import get_singularity_cachedir
from .cache import get_singularity_cachedir, get_sif_cache_dir
from ..shell import shell_run


Expand All @@ -27,16 +27,22 @@ def __init__(self):
self.env_vars = "\n".join(
(f"export SINGULARITY_CACHEDIR={get_singularity_cachedir()}",)
)
self.singularity_sif_dir = None

def __repr__(self):
return f"{self.__class__}({self.__dict__})"
dict_with_props = dict(
self.__dict__, singularity_sif_dir=self.singularity_sif_dir
)
return f"{self.__class__}({dict_with_props})"

def __bool__(self):
return bool(self.name)

__nonzero__ = __bool__

@property
def singularity_sif_dir(self):
return get_sif_cache_dir(hpc=self.name)


class Biowulf(Cluster):
"""
Expand Down Expand Up @@ -64,7 +70,6 @@ def __init__(self):
else " ccbrpipeliner"
),
}
self.singularity_sif_dir = "/data/CCBR_Pipeliner/SIFs"


class FRCE(Cluster):
Expand All @@ -82,7 +87,6 @@ def __init__(self):
super().__init__()
self.name = "frce"
self.modules = {"nxf": "nextflow", "smk": "snakemake/7 singularity"}
self.singularity_sif_dir = "/mnt/projects/CCBR-Pipelines/SIFs"
self.env_vars = "\n".join(
(
self.env_vars,
Expand Down
19 changes: 19 additions & 0 deletions tests/test_pipeline_cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from ccbr_tools.pipeline.cache import get_sif_cache_dir, get_singularity_cachedir


def test_get_sif_cache_dir():
assertions = [
"'CCBR_Pipeliner/SIFs' in get_sif_cache_dir('biowulf')",
"'CCBR-Pipelines/SIFs' in get_sif_cache_dir('frce')",
]
errors = [assertion for assertion in assertions if not eval(assertion)]
assert not errors, "errors occurred:\n{}".format("\n".join(errors))


def test_get_singularity_cachedir():
assertions = [
"get_singularity_cachedir('outdir') == 'outdir/.singularity'",
"get_singularity_cachedir('outdir', 'cache') == 'cache'",
]
errors = [assertion for assertion in assertions if not eval(assertion)]
assert not errors, "errors occurred:\n{}".format("\n".join(errors))
5 changes: 4 additions & 1 deletion tests/test_hpc.py → tests/test_pipeline_hpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ def test_hpc_biowulf():
hpc,
hpc.name == "biowulf",
hpc.singularity_sif_dir == "/data/CCBR_Pipeliner/SIFs",
hpc.__repr__().startswith(
"<class 'ccbr_tools.pipeline.hpc.Biowulf'>({'name': 'biowulf'"
),
]
)

Expand All @@ -32,4 +35,4 @@ def test_hpc_none():


if __name__ == "__main__":
print(get_hpc(debug="biowulf"))
print(get_hpc(debug="biowulf").__repr__())

0 comments on commit 3e60ed9

Please sign in to comment.