Skip to content

Commit

Permalink
fix: logfile quoting and scancel error handling (#140)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced handling of output paths in SLURM job commands to better
accommodate spaces and special characters.
- Improved error reporting for job cancellations, providing clearer
feedback on failures.

- **Bug Fixes**
- Added robust exception handling for job cancellation processes to
capture and report errors effectively.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Christian Meesters <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 7, 2024
1 parent edadd3e commit cb5d656
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion snakemake_executor_plugin_slurm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def run_job(self, job: JobExecutorInterface):
f"sbatch "
f"--parsable "
f"--job-name {self.run_uuid} "
f"--output {slurm_logfile} "
f"--output '{slurm_logfile}' "
f"--export=ALL "
f"--comment {comment_str}"
)
Expand Down Expand Up @@ -408,6 +408,14 @@ def cancel_jobs(self, active_jobs: List[SubmittedJobInfo]):
)
except subprocess.TimeoutExpired:
self.logger.warning("Unable to cancel jobs within a minute.")
except subprocess.CalledProcessError as e:
msg = e.stderr.strip()
if msg:
msg = f": {msg}"
raise WorkflowError(
"Unable to cancel jobs with scancel "
f"(exit code {e.returncode}){msg}"
) from e

async def job_stati(self, command):
"""Obtain SLURM job status of all submitted jobs with sacct
Expand Down

0 comments on commit cb5d656

Please sign in to comment.