-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: create classes for HPC options
- Loading branch information
1 parent
edc8735
commit f5c9eb6
Showing
4 changed files
with
99 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from .util import get_hpcname | ||
|
||
|
||
class Cluster: | ||
def __init__(self): | ||
self.name = None | ||
self.slurm_script = {"nxf": None, "smk": None} | ||
self.modules = {"nxf": None, "smk": None} | ||
self.singularity_sif_dir = None | ||
|
||
def __bool__(self): | ||
return bool(self.name) | ||
|
||
__nonzero__ = __bool__ | ||
|
||
|
||
class Biowulf(Cluster): | ||
def __init__(self): | ||
super().__init__() | ||
self.name = "biowulf" | ||
self.slurm_script = { | ||
"nxf": "slurm_nxf_biowulf.sh", | ||
"smk": "slurm_smk_biowulf.sh", | ||
} | ||
self.modules = { | ||
"nxf": "ccbrpipeliner nextflow", | ||
"smk": "ccbrpipeliner snakemake/7 singularity", | ||
} | ||
self.singularity_sif_dir = "/data/CCBR_Pipeliner/SIFs" | ||
|
||
|
||
class FRCE(Cluster): | ||
def __init__(self): | ||
super().__init__() | ||
self.name = "frce" | ||
self.slurm_script = {"nxf": "slurm_nxf_frce.sh", "smk": "slurm_smk_frce.sh"} | ||
self.modules = {"nxf": "nextflow", "smk": "snakemake/7 singularity"} | ||
self.singularity_sif_dir = "/mnt/projects/CCBR-Pipelines/SIFs" | ||
|
||
|
||
def get_hpc(debug=False): | ||
hpc_options = {"biowulf": Biowulf, "frce": FRCE} | ||
hpc_name = get_hpcname() if not debug else debug | ||
return hpc_options.get(hpc_name, Cluster)() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from ccbr_tools.pipeline.hpc import get_hpc | ||
|
||
|
||
def test_hpc_biowulf(): | ||
hpc = get_hpc(debug="biowulf") | ||
assert all( | ||
[ | ||
hpc, | ||
hpc.name == "biowulf", | ||
hpc.slurm_script | ||
== {"nxf": "slurm_nxf_biowulf.sh", "smk": "slurm_smk_biowulf.sh"}, | ||
hpc.singularity_sif_dir == "/data/CCBR_Pipeliner/SIFs", | ||
] | ||
) | ||
|
||
|
||
def test_hpc_frce(): | ||
hpc = get_hpc(debug="frce") | ||
assert all( | ||
[ | ||
hpc, | ||
hpc.name == "frce", | ||
hpc.slurm_script | ||
== {"nxf": "slurm_nxf_frce.sh", "smk": "slurm_smk_frce.sh"}, | ||
hpc.singularity_sif_dir == "/mnt/projects/CCBR-Pipelines/SIFs", | ||
] | ||
) | ||
|
||
|
||
def test_hpc_none(): | ||
hpc = get_hpc(debug="") | ||
assert not any([hpc, hpc.name, *hpc.slurm_script.values(), hpc.singularity_sif_dir]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from ccbr_tools.pipeline.nextflow import run | ||
from ccbr_tools.shell import exec_in_context | ||
|
||
|
||
def test_nextflow_basic(): | ||
assert "nextflow run CCBR/CHAMPAGNE" in exec_in_context( | ||
run, "CCBR/CHAMPAGNE", debug=True | ||
) |