Skip to content

Commit

Permalink
Merge pull request #2 from znamlab/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ablot authored Dec 11, 2023
2 parents 12b06b9 + aa6269b commit ae4b0cc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

## Changelog

### [v0.3] - 2023-12-05

- Bugfix: `slurm_options` was required but can now be ommited in the decorator

### [v0.2] - 2023-12-05

- Add option to change slurm options when calling the decorated function
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="znamutils",
version="v0.2",
version="v0.3-dev",
packages=find_packages(exclude=["tests"]),
url="https://github.com/znamlab/znamutils",
license="MIT",
Expand Down
2 changes: 1 addition & 1 deletion tests/test-results/pytest_in_tests.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="3" time="3.478" timestamp="2023-12-05T17:31:48.510906" hostname="int000"><testcase classname="tests.test_decorators" name="test_slurm_my_func" time="0.223" /><testcase classname="tests.test_decorators" name="test_update_slurm_options" time="0.052" /><testcase classname="tests.test_slurm_helpers" name="test_create_slurm_sbatch" time="0.000" /></testsuite></testsuites>
<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="3" time="6.868" timestamp="2023-12-06T12:02:22.125240" hostname="int002"><testcase classname="tests.test_decorators" name="test_slurm_my_func" time="0.529" /><testcase classname="tests.test_decorators" name="test_update_slurm_options" time="0.057" /><testcase classname="tests.test_slurm_helpers" name="test_create_slurm_sbatch" time="0.000" /></testsuite></testsuites>
7 changes: 7 additions & 0 deletions tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ def test_slurm_my_func():
)
slurm_folder.mkdir(exist_ok=True)

@slurm_it(conda_env="cottage_analysis")
def test_func(a, b):
return a + b

assert test_func(1, 2, use_slurm=False) == 3
assert isinstance(test_func(1, 2, use_slurm=True, slurm_folder=slurm_folder), str)

@slurm_it(conda_env="cottage_analysis", slurm_options={"time": "00:01:00"})
def test_func(a, b):
from datetime import datetime
Expand Down
2 changes: 2 additions & 0 deletions znamutils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def slurm_it(
function: decorated function
"""
# make a copy of default slurm options to avoid modifying the original
if slurm_options is None:
slurm_options = {}
default_slurm_options = slurm_options.copy()

# add parameters to the wrapped function signature
Expand Down

0 comments on commit ae4b0cc

Please sign in to comment.