snakemake-executor-plugin-slurm 0.5.2__py3-none-any.whl → 0.7.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of snakemake-executor-plugin-slurm might be problematic. Click here for more details.

@@ -6,6 +6,7 @@ __license__ = "MIT"
6
6
  import csv
7
7
  from io import StringIO
8
8
  import os
9
+ import re
9
10
  import subprocess
10
11
  import time
11
12
  from datetime import datetime, timedelta
@@ -49,11 +50,24 @@ common_settings = CommonSettings(
49
50
  # Implementation of your executor
50
51
  class Executor(RemoteExecutor):
51
52
  def __post_init__(self):
53
+ # run check whether we are running in a SLURM job context
54
+ self.warn_on_jobcontext()
52
55
  self.run_uuid = str(uuid.uuid4())
53
56
  self.logger.info(f"SLURM run ID: {self.run_uuid}")
54
57
  self._fallback_account_arg = None
55
58
  self._fallback_partition = None
56
59
 
60
+ def warn_on_jobcontext(self, done=None):
61
+ if not done:
62
+ if "SLURM_JOB_ID" in os.environ:
63
+ self.logger.warning(
64
+ "Running Snakemake in a SLURM within a job may lead"
65
+ " to unexpected behavior. Please run Snakemake directly"
66
+ " on the head node."
67
+ )
68
+ time.sleep(5)
69
+ done = True
70
+
57
71
  def additional_general_args(self):
58
72
  return "--executor slurm-jobstep --jobs 1"
59
73
 
@@ -143,6 +157,7 @@ class Executor(RemoteExecutor):
143
157
  call += f" --cpus-per-task={get_cpus_per_task(job)}"
144
158
 
145
159
  if job.resources.get("slurm_extra"):
160
+ self.check_slurm_extra(job)
146
161
  call += f" {job.resources.slurm_extra}"
147
162
 
148
163
  exec_job = self.format_job_exec(job)
@@ -391,6 +406,7 @@ class Executor(RemoteExecutor):
391
406
  account = self.get_account()
392
407
  if account:
393
408
  self.logger.warning(f"Guessed SLURM account: {account}")
409
+ self.test_account(f"{account}")
394
410
  self._fallback_account_arg = f" -A {account}"
395
411
  else:
396
412
  self.logger.warning(
@@ -428,7 +444,7 @@ class Executor(RemoteExecutor):
428
444
  sacct_out = subprocess.check_output(
429
445
  cmd, shell=True, text=True, stderr=subprocess.PIPE
430
446
  )
431
- return sacct_out.strip()
447
+ return sacct_out.replace("(null)", "").strip()
432
448
  except subprocess.CalledProcessError as e:
433
449
  self.logger.warning(
434
450
  f"No account was given, not able to get a SLURM account via sacct: "
@@ -488,3 +504,15 @@ class Executor(RemoteExecutor):
488
504
  "'slurm_partition=<your default partition>'."
489
505
  )
490
506
  return ""
507
+
508
+ def check_slurm_extra(self, job):
509
+ jobname = re.compile(r"--job-name[=?|\s+]|-J\s?")
510
+ if re.search(jobname, job.resources.slurm_extra):
511
+ raise WorkflowError(
512
+ "The '--job-name' option is not allowed in the 'slurm_extra' "
513
+ "parameter. The job name is set by snakemake and must not be "
514
+ "overwritten. It is internally used to check the stati of all "
515
+ "submitted jobs by this workflow."
516
+ "Please consult the documentation if you are unsure how to "
517
+ "query the status of your jobs."
518
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: snakemake-executor-plugin-slurm
3
- Version: 0.5.2
3
+ Version: 0.7.0
4
4
  Summary: A Snakemake executor plugin for submitting jobs to a SLURM cluster.
5
5
  Home-page: https://github.com/snakemake/snakemake-executor-plugin-slurm
6
6
  License: MIT
@@ -0,0 +1,5 @@
1
+ snakemake_executor_plugin_slurm/__init__.py,sha256=23xB0r9M9PqkM6g8sdOps_J6xKCwOUBOrNkZY9vJN_k,22157
2
+ snakemake_executor_plugin_slurm-0.7.0.dist-info/LICENSE,sha256=YVc4xTLWMqGfFL36120k7rzXtsT6e4RkJsh68VVn12s,1076
3
+ snakemake_executor_plugin_slurm-0.7.0.dist-info/METADATA,sha256=f77cauodNnBf_n9sGNgTkkiAhf_1A3-oAOQRtDioFZ0,1380
4
+ snakemake_executor_plugin_slurm-0.7.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
5
+ snakemake_executor_plugin_slurm-0.7.0.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- snakemake_executor_plugin_slurm/__init__.py,sha256=q25l-j-o7I4hjHIX8mIuyEqde4g_oz7_bjZuflcGTnU,20908
2
- snakemake_executor_plugin_slurm-0.5.2.dist-info/LICENSE,sha256=YVc4xTLWMqGfFL36120k7rzXtsT6e4RkJsh68VVn12s,1076
3
- snakemake_executor_plugin_slurm-0.5.2.dist-info/METADATA,sha256=7dUfUtoxbgD-ZluaigOJJAqKwMw1XJOXjJ0RJvCMVyo,1380
4
- snakemake_executor_plugin_slurm-0.5.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
5
- snakemake_executor_plugin_slurm-0.5.2.dist-info/RECORD,,