Skip to content

Commit 57afbbc

Browse files
committed
fixed get_running_jobs_slurm
1 parent 69a84c9 commit 57afbbc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

hpc_helper/_hpc_helper.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def get_running_jobs_torque(job_pattern: str, target_system: Optional[TARGET_SYS
120120
return re.findall(rf"\S* {job_pattern}\s*\w+\s*\S*\s*R", out)
121121

122122

123-
def get_running_jobs_slurm(job_pattern: str, target_system: str):
123+
def get_running_jobs_slurm(target_system: str, job_pattern: Optional[str] = None) -> Sequence[str]:
124124
"""Return a list of all currently running jobs in the Slurm scheduler on the HPC.
125125
126126
Parameters
@@ -139,7 +139,9 @@ def get_running_jobs_slurm(job_pattern: str, target_system: str):
139139
out = subprocess.check_output([f"squeue.{target_system}", "--json", "--states=RUNNING"]).decode("utf-8")
140140
out = json.loads(out)
141141
jobs = out["jobs"]
142-
running_jobs = [job["name"] for job in jobs if re.findall(job_pattern, job["name"])]
142+
running_jobs = [job["name"] for job in jobs]
143+
if job_pattern is not None:
144+
running_jobs = [job for job in running_jobs if re.search(job_pattern, job)]
143145
return running_jobs
144146

145147

0 commit comments

Comments
 (0)