Skip to content

fix: skip account setting upon user request #224

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 11 commits into from
Mar 13, 2025
Merged

fix: skip account setting upon user request #224

merged 11 commits into from
Mar 13, 2025

Conversation

cmeesters
Copy link
Member

@cmeesters cmeesters commented Mar 11, 2025

Summary by CodeRabbit

  • New Features
    • Users can now opt-out from automatic account specification during job submission using a new configuration flag, offering greater flexibility for environments with multiple accounts or enforced defaults.
  • Documentation
    • Enhanced guidance on SLURM account management, including advice on explicitly setting accounts when necessary and details on overriding default behaviors with a new flag.

Copy link
Contributor

coderabbitai bot commented Mar 11, 2025

Walkthrough

This pull request updates the SLURM executor plugin by enhancing documentation and modifying job submission behavior. The documentation now explains SLURM account configuration, including cases with multiple accounts and the --slurm-no-account flag. In the code, a new boolean option, no_account, is added to the executor settings, and the run_job method’s control flow is updated to conditionally include the account argument. The test_account method now uses sshare instead of sacctmgr with additional logging for empty results.

Changes

File(s) Change Summary
docs/further.md Added detailed explanation regarding SLURM account configuration, multiple account management, and the use of the --slurm-no-account flag to override default behavior.
snakemake_executor_plugin_slurm/init.py Added a new boolean field no_account in ExecutorSettings (default False) with help metadata; modified the run_job method to conditionally add the account argument; updated test_account to use sshare with added logging.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Workflow
  participant Executor
  participant SLURM
  User->>Workflow: Submit job with executor settings
  Workflow->>Executor: run_job(job)
  Executor->>Executor: Evaluate no_account flag
  alt no_account is False
      Executor->>SLURM: Append SLURM account argument (via get_account_arg)
  else no_account is True
      Executor->>SLURM: Submit without account argument
  end
  SLURM-->>Executor: Job submission response
Loading

Possibly related PRs

Suggested reviewers

  • cmeesters
  • johanneskoester
  • fgvieira

Poem

In a burrow of code where changes unfold,
I hop through new settings, both timid and bold.
The SLURM flags twirl in a rhythmic dance,
No_account toggles give jobs a new chance.
With a skip and a hop, our plugin shines bright—
A bunny’s delight in every line of insight! 🐇💻

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f1e0abe and 7e8318f.

📒 Files selected for processing (1)
  • docs/further.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/further.md

🪧 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
Contributor

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.

cmeesters and others added 3 commits March 12, 2025 22:50
- correct typos and grammar, based on languagetool.org and coderabbitai
- mention partitions as another thing that can be blocked by local cluster settings (e.g.: on ETH Zürich's Euler)
@DrYak
Copy link
Contributor

DrYak commented Mar 13, 2025

Updated doc, looks nice to me.

Copy link
Contributor

@DrYak DrYak left a comment

Choose a reason for hiding this comment

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

👍

@cmeesters
Copy link
Member Author

@DrYak merci!

@cmeesters cmeesters merged commit 08a867a into main Mar 13, 2025
6 checks passed
@cmeesters cmeesters deleted the fix/no_account branch March 13, 2025 14:41
@github-project-automation github-project-automation bot moved this from In review to Done in Snakemake Hackathon March 2025 Mar 13, 2025
cmeesters pushed a commit that referenced this pull request Mar 13, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.0.1](v1.0.0...v1.0.1)
(2025-03-13)


### Bug Fixes

* skip account setting upon user request
([#224](#224))
([08a867a](08a867a))

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

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

## Summary by CodeRabbit

- **Bug Fixes**
- Improved account setup flow, allowing users to opt-out of configuring
account settings.

- **Chores**
- Updated the project version to 1.0.1, with a corresponding release
note entry.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@cmeesters cmeesters self-assigned this Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants