Skip to content

Commit

Permalink
fix: allowing for accounts containing whitespace (#86)
Browse files Browse the repository at this point in the history
As [reported](snakemake/snakemake#2320), the
plugin will not deal with account names containing whitespace. (accounts
containing whitespace were not anticipated).

This PR is an attempt to fix this.

---------

Co-authored-by: Filipe G. Vieira <1151762+fgvieira@users.noreply.github.com>
  • Loading branch information
cmeesters and fgvieira committed May 14, 2024
1 parent 7b94aec commit 6993f2d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions snakemake_executor_plugin_slurm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def get_account_arg(self, job: JobExecutorInterface):
# here, we check whether the given or guessed account is valid
# if not, a WorkflowError is raised
self.test_account(job.resources.slurm_account)
return f" -A {job.resources.slurm_account}"
return f" -A '{job.resources.slurm_account}'"
else:
if self._fallback_account_arg is None:
self.logger.warning("No SLURM account given, trying to guess.")
Expand Down Expand Up @@ -442,7 +442,9 @@ def test_account(self, account):
f"'{account}' with sacctmgr: {e.stderr}"
)

accounts = accounts.split()
# The set() has been introduced during review to eliminate
# duplicates. They are not harmful, but disturbing to read.
accounts = set(_.strip() for _ in accounts.split("\n") if _)

if account not in accounts:
raise WorkflowError(
Expand Down

0 comments on commit 6993f2d

Please sign in to comment.