Skip to content

Commit

Permalink
add class for dealing with job names and logs
Browse files Browse the repository at this point in the history
  • Loading branch information
mbhall88 committed May 17, 2022
1 parent 817674b commit d5072cb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.profile_name}}/CookieCutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ def get_cluster_logpath() -> str:

@staticmethod
def get_cluster_jobname() -> str:
return "{{cookiecutter.cluster_jobname}}"
return "{{cookiecutter.cluster_jobname}}"
7 changes: 4 additions & 3 deletions {{cookiecutter.profile_name}}/slurm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -263,7 +263,7 @@ class Time:
"d": _day_size,
"w": _week_size,
}
pattern = re.compile(rf'(?P<val>\d+(\.\d*)?|\.\d+)(?P<unit>[a-zA-Z])')
pattern = re.compile(rf"(?P<val>\d+(\.\d*)?|\.\d+)(?P<unit>[a-zA-Z])")

def __init__(self, duration: str):
self.duration = Time._from_str(duration)
Expand Down Expand Up @@ -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]

Expand Down

0 comments on commit d5072cb

Please sign in to comment.