Skip to content

Commit

Permalink
fix: sshare testing as an alternative to sacctmgr account tests (#178)
Browse files Browse the repository at this point in the history
Addresses issue #177 



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Bug Fixes**
- Enhanced error handling in account validation for SLURM, providing
more informative error messages.
- Implemented a fallback mechanism to verify SLURM account validity
through an additional command.
- **Chores**
- Updated the authorization token in the GitHub Actions workflow for
posting to Mastodon.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Johannes Köster <[email protected]>
  • Loading branch information
cmeesters and johanneskoester authored Jan 15, 2025
1 parent 4f5e921 commit 38fa919
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/post_to_mastodon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
timeout_minutes: 2
max_attempts: 3
command: |
curl -X POST -H "Authorization: Bearer ${{ secrets.MASTODON_ACCESS_TOKEN }}" \
curl -X POST -H "Authorization: Bearer ${{ secrets.MASTODONBOT }}" \
-F "status=New release in Snakemake project '${{ github.event.repository.full_name }}' for pull request '#${{ github.event.pull_request.number }}' merged: '${{ github.event.pull_request.title }}'. Get the latest release from #Bioconda or #Pypi." \
https://fediscience.org/api/v1/statuses \
-w "\nResponse code: %{http_code}\n" \
Expand Down
20 changes: 17 additions & 3 deletions snakemake_executor_plugin_slurm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,24 @@ def test_account(self, account):
cmd, shell=True, text=True, stderr=subprocess.PIPE
)
except subprocess.CalledProcessError as e:
raise WorkflowError(
f"Unable to test the validity of the given or guessed SLURM account "
f"'{account}' with sacctmgr: {e.stderr}"
sacctmgr_report = (
"Unable to test the validity of the given or guessed "
f"SLURM account '{account}' with sacctmgr: {e.stderr}."
)
try:
cmd = "sshare -U --format Account --noheader"
accounts = subprocess.check_output(
cmd, shell=True, text=True, stderr=subprocess.PIPE
)
except subprocess.CalledProcessError as e2:
sshare_report = (
"Unable to test the validity of the given or guessed"
f" SLURM account '{account}' with sshare: {e2.stderr}."
)
raise WorkflowError(
f"The 'sacctmgr' reported: '{sacctmgr_report}' "
f"and likewise 'sshare' reported: '{sshare_report}'."
)

# The set() has been introduced during review to eliminate
# duplicates. They are not harmful, but disturbing to read.
Expand Down

0 comments on commit 38fa919

Please sign in to comment.