From c27f5f8b4dcf7c2d9bc34fd4870d13ff24c0dfae Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Fri, 23 Aug 2024 08:47:46 +0200 Subject: [PATCH 1/2] feat: in job stability (#137) might increase stability of in-job submissions, might fix #113 ## Summary by CodeRabbit - **New Features** - Introduced a utility function to manage SLURM environment variables, enhancing job submission reliability. - Updated warning handling to clean up SLURM environments when specific conditions are met. - **Bug Fixes** - Improved resource management by ensuring lingering SLURM job contexts are addressed. --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- snakemake_executor_plugin_slurm/__init__.py | 5 ++++- snakemake_executor_plugin_slurm/utils.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 snakemake_executor_plugin_slurm/utils.py diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index a39936b..5b25540 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -26,6 +26,8 @@ from snakemake_interface_common.exceptions import WorkflowError from snakemake_executor_plugin_slurm_jobstep import get_cpus_per_task +from .utils import delete_slurm_environment + @dataclass class ExecutorSettings(ExecutorSettingsBase): @@ -85,10 +87,11 @@ def warn_on_jobcontext(self, done=None): if "SLURM_JOB_ID" in os.environ: self.logger.warning( "You are running snakemake in a SLURM job context. " - "This is not recommended, as it may lead to unexpected behavior." + "This is not recommended, as it may lead to unexpected behavior. " "Please run Snakemake directly on the login node." ) time.sleep(5) + delete_slurm_environment() done = True def additional_general_args(self): diff --git a/snakemake_executor_plugin_slurm/utils.py b/snakemake_executor_plugin_slurm/utils.py new file mode 100644 index 0000000..50eb1f4 --- /dev/null +++ b/snakemake_executor_plugin_slurm/utils.py @@ -0,0 +1,16 @@ +# utility functions for the SLURM executor plugin + +import os + + +def delete_slurm_environment(): + """ + Function to delete all environment variables + starting with 'SLURM_'. The parent shell will + still have this environment. This is needed to + submit within a SLURM job context to avoid + conflicting environments. + """ + for var in os.environ: + if var.startswith("SLURM_"): + del os.environ[var] From c414f6571d5de30e834162ca987a5cdf81f869c5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 23 Aug 2024 14:56:52 +0200 Subject: [PATCH 2/2] chore(main): release 0.10.0 (#138) :robot: I have created a release *beep* *boop* --- ## [0.10.0](https://github.com/snakemake/snakemake-executor-plugin-slurm/compare/v0.9.0...v0.10.0) (2024-08-23) ### Features * in job stability ([#137](https://github.com/snakemake/snakemake-executor-plugin-slurm/issues/137)) ([c27f5f8](https://github.com/snakemake/snakemake-executor-plugin-slurm/commit/c27f5f8b4dcf7c2d9bc34fd4870d13ff24c0dfae)) ### Bug Fixes * add --parsable to sbatch call for a more robust output parsing ([#125](https://github.com/snakemake/snakemake-executor-plugin-slurm/issues/125)) ([5e41d05](https://github.com/snakemake/snakemake-executor-plugin-slurm/commit/5e41d0577593909f8f0f255c8de29141bfd0bbe3)) * issue [#109](https://github.com/snakemake/snakemake-executor-plugin-slurm/issues/109) - preemption is no longer considered a failed status ([#132](https://github.com/snakemake/snakemake-executor-plugin-slurm/issues/132)) ([6dad273](https://github.com/snakemake/snakemake-executor-plugin-slurm/commit/6dad273b2f09ed8f10e3c26b92e2963c382e9fb8)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). ## Summary by CodeRabbit - **New Features** - Introduced the `--parsable` option to the `sbatch` command for improved output parsing. - **Bug Fixes** - Revised job preemption handling to prevent it from being marked as a failed status, enhancing job stability. - **Chores** - Updated the version number of the Snakemake Executor Plugin for Slurm to 0.10.0 in preparation for the release. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 13 +++++++++++++ pyproject.toml | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6200b6..1d5c927 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [0.10.0](https://github.com/snakemake/snakemake-executor-plugin-slurm/compare/v0.9.0...v0.10.0) (2024-08-23) + + +### Features + +* in job stability ([#137](https://github.com/snakemake/snakemake-executor-plugin-slurm/issues/137)) ([c27f5f8](https://github.com/snakemake/snakemake-executor-plugin-slurm/commit/c27f5f8b4dcf7c2d9bc34fd4870d13ff24c0dfae)) + + +### Bug Fixes + +* add --parsable to sbatch call for a more robust output parsing ([#125](https://github.com/snakemake/snakemake-executor-plugin-slurm/issues/125)) ([5e41d05](https://github.com/snakemake/snakemake-executor-plugin-slurm/commit/5e41d0577593909f8f0f255c8de29141bfd0bbe3)) +* issue [#109](https://github.com/snakemake/snakemake-executor-plugin-slurm/issues/109) - preemption is no longer considered a failed status ([#132](https://github.com/snakemake/snakemake-executor-plugin-slurm/issues/132)) ([6dad273](https://github.com/snakemake/snakemake-executor-plugin-slurm/commit/6dad273b2f09ed8f10e3c26b92e2963c382e9fb8)) + ## [0.9.0](https://github.com/snakemake/snakemake-executor-plugin-slurm/compare/v0.8.0...v0.9.0) (2024-08-06) diff --git a/pyproject.toml b/pyproject.toml index 739a2e2..e79cba9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "snakemake-executor-plugin-slurm" -version = "0.9.0" +version = "0.10.0" description = "A Snakemake executor plugin for submitting jobs to a SLURM cluster." authors = [ "Christian Meesters ",