From d5072cbcae8ad380c319bddd8085b40524ff7907 Mon Sep 17 00:00:00 2001 From: Michael Hall Date: Fri, 13 May 2022 16:02:04 +1000 Subject: [PATCH] add class for dealing with job names and logs --- README.md | 16 ++++++++-------- {{cookiecutter.profile_name}}/CookieCutter.py | 2 +- {{cookiecutter.profile_name}}/slurm_utils.py | 7 ++++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 86feb84..4f2416d 100644 --- a/README.md +++ b/README.md @@ -281,11 +281,11 @@ specified as `time="4h30m"`. Supported (case-insensitive) time units are: -- `w`: week -- `d`: day -- `h`: hour -- `m`: minute -- `s`: second +- `w`: week +- `d`: day +- `h`: hour +- `m`: minute +- `s`: second However, you may also pass the time in the [slurm format](https://slurm.schedmd.com/sbatch.html#OPT_time). @@ -323,7 +323,7 @@ from the source code root directory. Test options can be configured via the pytest configuration file `tests/pytest.ini`. Test dependencies are listed in `test-environment.yml` and can be -installed in e.g. a conda environment. +installed in e.g. a conda environment. ### Testing on a HPC running SLURM @@ -342,8 +342,8 @@ For local testing the test suite will deploy a docker stack `cookiecutter-slurm` that runs two services based on the following images: -1. [quay.io/biocontainers/snakemake](https://quay.io/repository/biocontainers/snakemake?tab=tags) -2. [giovtorres/docker-centos7-slurm](https://github.com/giovtorres/docker-centos7-slurm) +1. [quay.io/biocontainers/snakemake](https://quay.io/repository/biocontainers/snakemake?tab=tags) +2. [giovtorres/docker-centos7-slurm](https://github.com/giovtorres/docker-centos7-slurm) The docker stack will be automatically deployed provided that the user has installed docker and enabled [docker diff --git a/{{cookiecutter.profile_name}}/CookieCutter.py b/{{cookiecutter.profile_name}}/CookieCutter.py index 9f67a94..c2514d0 100644 --- a/{{cookiecutter.profile_name}}/CookieCutter.py +++ b/{{cookiecutter.profile_name}}/CookieCutter.py @@ -28,4 +28,4 @@ def get_cluster_logpath() -> str: @staticmethod def get_cluster_jobname() -> str: - return "{{cookiecutter.cluster_jobname}}" \ No newline at end of file + return "{{cookiecutter.cluster_jobname}}" diff --git a/{{cookiecutter.profile_name}}/slurm_utils.py b/{{cookiecutter.profile_name}}/slurm_utils.py index bd6d190..7a96e75 100644 --- a/{{cookiecutter.profile_name}}/slurm_utils.py +++ b/{{cookiecutter.profile_name}}/slurm_utils.py @@ -95,7 +95,7 @@ def format(_pattern, _quote_all=False, **kwargs): # noqa: A001 # adapted from Job.format_wildcards in snakemake.jobs def format_wildcards(string, job_properties): - """ Format a string with variables from the job. """ + """Format a string with variables from the job.""" class Job(object): def __init__(self, job_properties): @@ -263,7 +263,7 @@ class Time: "d": _day_size, "w": _week_size, } - pattern = re.compile(rf'(?P\d+(\.\d*)?|\.\d+)(?P[a-zA-Z])') + pattern = re.compile(rf"(?P\d+(\.\d*)?|\.\d+)(?P[a-zA-Z])") def __init__(self, duration: str): self.duration = Time._from_str(duration) @@ -301,7 +301,8 @@ def _from_str(duration: str) -> Union[timedelta, str]: unit = m.group("unit").lower() if unit not in Time.units: raise InvalidTimeUnitError( - "Unknown unit '{}' in time {}".format(unit, duration)) + "Unknown unit '{}' in time {}".format(unit, duration) + ) total += float(value) * Time.units[unit]