Skip to content
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

fix: skip account setting upon user request #224

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

cmeesters
Copy link
Member

@cmeesters cmeesters commented Mar 11, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved error reporting to ensure missing environment configurations are clearly indicated.
  • Documentation

    • Enhanced guidance on handling SLURM account configurations, detailing when and how to override default settings.
  • New Features

    • Introduced a configurable option allowing users to submit jobs without specifying an account for increased flexibility.

Copy link
Contributor

coderabbitai bot commented Mar 11, 2025

Caution

Review failed

The head commit changed during the review from 4f4945b to 823d96c.

Walkthrough

This pull request modifies error handling in a Mastodon posting shell script, updates documentation regarding SLURM account configuration in Snakemake, and enhances the SLURM executor functionality. Specifically, error messages in the workflow script are now sent to standard error, the docs explain nuances around multiple SLURM accounts and the --slurm-no-account flag, and a new no_account field is introduced in the executor settings to conditionally modify job submission behavior.

Changes

File(s) Change Summary
.github/workflows/post_to_mastodon.sh Redirects error messages to standard error (>&2) when PR_TITLE is not set.
docs/further.md Adds explanatory text on SLURM account configuration and introduces the --slurm-no-account flag.
snakemake_executor_plugin_slurm/__init__.py Adds a new boolean field no_account to ExecutorSettings and updates the job submission logic to conditionally append the account argument.

Possibly related PRs

  • fix: path to posting script #193: The changes in the main PR, which modify error message handling in the post_to_mastodon.sh script, are related to the changes in the retrieved PR that also involve modifications to the same script, specifically regarding the validation of the PR_TITLE environment variable.
  • feat: Improved Mastodon Bot #183: The changes in the main PR, which modify error message handling in the post_to_mastodon.sh script, are directly related to the changes in the retrieved PR that introduces this script, as both involve modifications to the same file for error reporting purposes.
  • ci: post to mastodon #201: The changes in the main PR modify the error message output in the same script file as the retrieved PR, which also addresses error handling related to the PR_TITLE environment variable, indicating a direct connection in their modifications.

Suggested reviewers

  • johanneskoester

Poem

Hopping through changes with a joyful beat,
My code now whispers errors straight to the heat.
SLURM accounts dance with a flag so neat,
No account? No worries—job submissions complete!
I, the rabbit, celebrate this code so sweet.
🐇✨


🪧 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.
  • @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.

@DrYak
Copy link

DrYak commented Mar 11, 2025

Cherry picking the commit and putting it on top of main worked for me.

@cmeesters
Copy link
Member Author

good. I will add some docs, tomorrow.

@cmeesters cmeesters marked this pull request as ready for review March 12, 2025 13:58
@cmeesters cmeesters requested a review from DrYak March 12, 2025 14:00
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)
docs/further.md (1)

21-22: Typos in the new documentation

The explanation of the SLURM account configuration is helpful, but there are a couple of typos in the text:

  • "attept" should be "attempt"
  • "behauvior" should be "behavior"
-Some clusters, however, have a pre-defined default per user and _do not_ allow users to set their account. The plugin will attept to always set an account. To override this behauvior, the `--slurm-no-account` flag can be used.
+Some clusters, however, have a pre-defined default per user and _do not_ allow users to set their account. The plugin will attempt to always set an account. To override this behavior, the `--slurm-no-account` flag can be used.
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 35d7dab and 6ff053e.

📒 Files selected for processing (3)
  • .github/workflows/post_to_mastodon.sh (1 hunks)
  • docs/further.md (1 hunks)
  • snakemake_executor_plugin_slurm/__init__.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: testing
🔇 Additional comments (3)
.github/workflows/post_to_mastodon.sh (1)

4-5: Improved error handling by redirecting to stderr

The change properly redirects error messages to standard error (stderr) using >&2 instead of printing them to standard output. This follows shell scripting best practices for error reporting.

snakemake_executor_plugin_slurm/__init__.py (2)

88-96: Well-defined new no_account setting

The new no_account field in ExecutorSettings is properly structured with appropriate defaults and clear help documentation. This addition aligns with the PR objective of allowing users to skip account settings when required.


225-227: Clean implementation of conditional account setting

The conditional addition of the account argument based on the no_account setting is well implemented. This change directly addresses the PR objective by providing a way to skip account settings upon user request.

@cmeesters
Copy link
Member Author

@DrYak there is now rudimentary documentation. Please review. More detailed documentation changes are upcoming.

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)

644-686: Improve exception chaining in the error handling.

The account validation logic has been improved to first try sshare and then fall back to sacctmgr, with appropriate warning when both return empty results. However, there's a minor issue with the exception handling.

According to best practices for Python exception handling, you should use explicit exception chaining with raise ... from e:

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

This helps distinguish between errors in the original operation and errors in exception handling.

🧰 Tools
🪛 Ruff (0.8.2)

671-674: 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 6ff053e and f1e0abe.

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

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

(B904)

🔇 Additional comments (2)
snakemake_executor_plugin_slurm/__init__.py (2)

88-96: LGTM: Clean implementation of the no_account setting.

The new boolean field follows the established pattern for boolean settings in the ExecutorSettings class, with appropriate default value and helpful documentation.


225-227: LGTM: Core functionality implemented correctly.

The conditional check for the no_account setting works as intended, allowing users to skip account settings upon request, which aligns with the PR objectives.

@cmeesters
Copy link
Member Author

@DrYak now, the order of account tests with sshare and sacctmgr is such, that sshare is performed first and sacctmgr only serves as a fallback. As discussed. This PR addresses #233, too.

@coderabbitai please, update the PR summary accordingly.

Copy link
Contributor

coderabbitai bot commented Mar 12, 2025

🧩 Analysis chain

I'll need to gather more information about issue #233 and check the code changes to properly update the PR summary.


🏁 Script executed:

#!/bin/bash
# First, let's check what issue #233 is about
gh issue view 233 -R snakemake/snakemake-executor-plugin-slurm

# Then, let's examine the code changes to verify the ordering of sshare and sacctmgr
git show --unified=3 HEAD -- snakemake_executor_plugin_slurm/__init__.py | grep -A 20 "test_account"

Length of output: 3973


@cmeesters I'll update the PR summary to include the information about the new order of account tests and how this PR also addresses issue #233.

The PR now accomplishes two main things:

  1. Allows skipping account settings upon user request via the new --slurm-no-account flag
  2. Changes the order of account validation tests to use sshare first with sacctmgr as a fallback, addressing issue SLURM account appears to be invalid #233 where valid SLURM accounts were being incorrectly rejected on certain cluster configurations
✅ Actions performed

Summary regeneration triggered.

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