From 38fa919ead6554c804e95424a61170e4967c9d63 Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Wed, 15 Jan 2025 12:50:31 +0100 Subject: [PATCH] fix: sshare testing as an alternative to sacctmgr account tests (#178) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses issue #177 ## 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. --------- Co-authored-by: Johannes Köster --- .github/workflows/post_to_mastodon.yml | 2 +- snakemake_executor_plugin_slurm/__init__.py | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/post_to_mastodon.yml b/.github/workflows/post_to_mastodon.yml index cb1a2df..72e17f2 100644 --- a/.github/workflows/post_to_mastodon.yml +++ b/.github/workflows/post_to_mastodon.yml @@ -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" \ diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index 6fdfbb1..9789ef5 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -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.