Skip to content

Commit

Permalink
[feature] Option to print job ID in log when starting
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonin Blot committed Mar 27, 2024
1 parent 58b47c1 commit 41ae3ad
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@

## Changelog

### [v0.5] - 2024-03-27

- Option to print job ID in log when starting.


### [v0.4] - 2024-01-17

- Job dependencies that are list or tuples are automatically formatted as `afterok:jobid1:jobid2:...`
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.4-dev",
version="v0.5",
packages=find_packages(exclude=["tests"]),
url="https://github.com/znamlab/znamutils",
license="MIT",
Expand Down
13 changes: 13 additions & 0 deletions tests/test_slurm_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,16 @@

def test_create_slurm_sbatch():
p = Path(flz.PARAMETERS["data_root"]["processed"]) / "test"
slurm_helper.create_slurm_sbatch(
p,
print_job_id=True,
conda_env="cottage_analysis",
python_script="test.py",
script_name="test.sh",
)
with open(p / "test.sh") as f:
txt = f.read()


if __name__ == "__main__":
test_create_slurm_sbatch()
5 changes: 5 additions & 0 deletions znamutils/slurm_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def create_slurm_sbatch(
slurm_options=None,
module_list=None,
split_err_out=False,
print_job_id=False,
):
"""Create a slurm sh script that will call a python script
Expand Down Expand Up @@ -83,6 +84,10 @@ def create_slurm_sbatch(
boiler = "\n" + "\n".join([f"ml {module}" for module in module_list]) + "\n"
else:
boiler = "\n"

if print_job_id:
boiler += f'echo "Job ID: $SLURM_JOB_ID"\n'

boiler += "\n".join(
[
"ml Anaconda3",
Expand Down

0 comments on commit 41ae3ad

Please sign in to comment.