diff --git a/CHANGELOG.md b/CHANGELOG.md index f529404..41a050c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 21a2497..d3b6995 100644 --- a/README.md +++ b/README.md @@ -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 @@ -122,7 +122,7 @@ 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 @@ -130,7 +130,7 @@ Please cite this software if you use it in a publication: @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} diff --git a/src/ccbr_tools/pipeline/cache.py b/src/ccbr_tools/pipeline/cache.py index c7afee6..9c43a49 100755 --- a/src/ccbr_tools/pipeline/cache.py +++ b/src/ccbr_tools/pipeline/cache.py @@ -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 diff --git a/src/ccbr_tools/pipeline/hpc.py b/src/ccbr_tools/pipeline/hpc.py index aa7ea55..91a0de7 100755 --- a/src/ccbr_tools/pipeline/hpc.py +++ b/src/ccbr_tools/pipeline/hpc.py @@ -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 @@ -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): """ @@ -64,7 +70,6 @@ def __init__(self): else " ccbrpipeliner" ), } - self.singularity_sif_dir = "/data/CCBR_Pipeliner/SIFs" class FRCE(Cluster): @@ -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, diff --git a/tests/test_pipeline_cache.py b/tests/test_pipeline_cache.py new file mode 100644 index 0000000..8cae4b3 --- /dev/null +++ b/tests/test_pipeline_cache.py @@ -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)) diff --git a/tests/test_hpc.py b/tests/test_pipeline_hpc.py similarity index 81% rename from tests/test_hpc.py rename to tests/test_pipeline_hpc.py index d2c7594..9e4499b 100644 --- a/tests/test_hpc.py +++ b/tests/test_pipeline_hpc.py @@ -10,6 +10,9 @@ def test_hpc_biowulf(): hpc, hpc.name == "biowulf", hpc.singularity_sif_dir == "/data/CCBR_Pipeliner/SIFs", + hpc.__repr__().startswith( + "({'name': 'biowulf'" + ), ] ) @@ -32,4 +35,4 @@ def test_hpc_none(): if __name__ == "__main__": - print(get_hpc(debug="biowulf")) + print(get_hpc(debug="biowulf").__repr__())