Skip to content

fix: sshare testing as an alternative to sacctmgr account tests #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 15, 2025

Conversation

cmeesters
Copy link
Member

@cmeesters cmeesters commented Dec 11, 2024

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.

Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

Walkthrough

The changes in this pull request enhance the error handling logic within the test_account method of the Executor class in the snakemake_executor_plugin_slurm module. A fallback mechanism is introduced that attempts to validate SLURM accounts using the sshare command if the initial sacctmgr command fails. This results in more informative error messages that indicate the specific command that failed, improving the clarity of error reporting without altering the overall method structure.

Changes

File Path Change Summary
snakemake_executor_plugin_slurm/init.py Enhanced error handling in test_account method to include a fallback command (sshare) for account validation and improved error message formatting.
.github/workflows/post_to_mastodon.yml Updated the authorization token in the GitHub Actions workflow for Mastodon from MASTODON_ACCESS_TOKEN to MASTODONBOT.

Suggested reviewers

  • johanneskoester
  • fgvieira

🐇 "In the land of SLURM where errors may bloom,
A fallback was crafted to brighten the gloom.
With sacctmgr and sshare in tow,
Clear messages now help us to know.
When accounts go awry, we’ll not be in fright,
For our rabbit's logic shines ever so bright!" 🌼

Finishing Touches

  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 531ebc6 and f035b0e.

📒 Files selected for processing (1)
  • snakemake_executor_plugin_slurm/__init__.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.0)
snakemake_executor_plugin_slurm/__init__.py

566-566: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
snakemake_executor_plugin_slurm/__init__.py (1)

636-650: Improve error handling in account validation

The implementation of a fallback mechanism to sshare when sacctmgr fails is a good improvement for robustness. However, there are a few improvements that can be made:

  1. The exception should be chained using raise ... from e to maintain the error context
  2. The error messages could be more concise based on past feedback

Apply this diff to improve the implementation:

-            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(sacctmgr_report + " - and - " + sshare_report)
+            try:
+                cmd = "sshare -U --format Account --noheader"
+                accounts = subprocess.check_output(
+                    cmd, shell=True, text=True, stderr=subprocess.PIPE
+                )
+            except subprocess.CalledProcessError as e2:
+                raise WorkflowError(
+                    f"Failed to validate account '{account}' with sacctmgr and sshare"
+                ) from e
🧰 Tools
🪛 Ruff (0.8.2)

650-650: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 100da58 and 5b2612b.

📒 Files selected for processing (2)
  • .github/workflows/post_to_mastodon.yml (1 hunks)
  • snakemake_executor_plugin_slurm/__init__.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
snakemake_executor_plugin_slurm/__init__.py

650-650: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: testing
  • GitHub Check: linting
🔇 Additional comments (1)
.github/workflows/post_to_mastodon.yml (1)

24-24: Verify the MASTODONBOT secret is configured

The secret token for Mastodon authentication has been renamed from MASTODON_ACCESS_TOKEN to MASTODONBOT. Please ensure this secret is properly configured in the repository settings.

@cmeesters
Copy link
Member Author

@johanneskoester might give it a check?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
snakemake_executor_plugin_slurm/__init__.py (1)

645-650: Consider adding exception chaining for better error tracking.

The error handling is good, but could be improved by adding exception chaining to preserve the original error context.

Apply this diff to add exception chaining:

-                raise WorkflowError(f"{sacctmgr_report} {sshare_report}")
+                raise WorkflowError(f"{sacctmgr_report} {sshare_report}") from e
🧰 Tools
🪛 Ruff (0.8.2)

650-650: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b2612b and 82eda26.

📒 Files selected for processing (1)
  • snakemake_executor_plugin_slurm/__init__.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
snakemake_executor_plugin_slurm/__init__.py

650-650: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: formatting
🔇 Additional comments (2)
snakemake_executor_plugin_slurm/__init__.py (2)

636-639: LGTM! Clear and informative error message.

The error message for sacctmgr failure is well-formatted and provides useful debugging information.


640-644: LGTM! Good fallback mechanism.

The implementation of sshare as a fallback for account validation is a robust solution that improves reliability.

@johanneskoester
Copy link
Contributor

This has an infinite loop now.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
snakemake_executor_plugin_slurm/__init__.py (1)

636-653: LGTM! The fallback mechanism is a good addition.

The implementation of sshare as a fallback when sacctmgr fails improves the robustness of account validation. The error messages are clear and informative.

Consider using proper exception chaining to maintain the traceback information:

-                raise WorkflowError(
-                    f"The 'sacctmgr' reported: '{sacctmgr_report}' "
-                    f"and likewise 'sshare' reported: '{sshare_report}'."
-                )
+                raise WorkflowError(
+                    f"The 'sacctmgr' reported: '{sacctmgr_report}' "
+                    f"and likewise 'sshare' reported: '{sshare_report}'."
+                ) from e
🧰 Tools
🪛 Ruff (0.8.2)

650-653: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82eda26 and 8a10415.

📒 Files selected for processing (1)
  • snakemake_executor_plugin_slurm/__init__.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
snakemake_executor_plugin_slurm/__init__.py

650-653: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: testing

@johanneskoester johanneskoester merged commit 38fa919 into main Jan 15, 2025
5 checks passed
@johanneskoester johanneskoester deleted the fix/sshare-alternative branch January 15, 2025 11:50
cmeesters pushed a commit that referenced this pull request Jan 15, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.12.1](v0.12.0...v0.12.1)
(2025-01-15)


### Bug Fixes

* sshare testing as an alternative to sacctmgr account tests
([#178](#178))
([38fa919](38fa919))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants