Skip to content

feat: Enables running snakemake job within a slurm cluster reservation. #285

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bmilash
Copy link

@bmilash bmilash commented May 15, 2025

This change lets the plugin start a slurm job using a reservation resource provided within a profile or on the command line.

Summary by CodeRabbit

  • New Features
    • Added support for specifying a SLURM job reservation when submitting jobs. If a reservation is provided, it will be included in the job submission command.

Copy link
Contributor

coderabbitai bot commented May 15, 2025

Walkthrough

Support for specifying a SLURM job reservation has been added to the submit command string generator. When a reservation is defined in the job's resources, a --reservation='...' argument is included in the sbatch command. No other logic or public interfaces were changed.

Changes

File(s) Change Summary
snakemake_executor_plugin_slurm/submit_string.py Added logic to append a --reservation='...' option to the sbatch command when specified in job resources.

Poem

In the warren of SLURM, a new path appears,
Reservations now honored, no need for cheers.
With a dash and a quote, the command grows strong,
Jobs find their place, where they truly belong.
🐇✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 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 8568780 and bbe459d.

📒 Files selected for processing (1)
  • snakemake_executor_plugin_slurm/submit_string.py (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: cmeesters
PR: snakemake/snakemake-executor-plugin-slurm#0
File: :0-0
Timestamp: 2025-01-13T09:54:22.950Z
Learning: PR #173 (adding gres resource specification) depends on PR #28 in snakemake-executor-plugin-slurm-jobstep repository, as changes were required in the cpu-settings function of the jobstep-Executor module.
🔇 Additional comments (1)
snakemake_executor_plugin_slurm/submit_string.py (1)

53-57: Nicely implemented SLURM reservation support!

The implementation correctly adds the --reservation flag to the SLURM submission command when a reservation is specified in the job resources. The use of single quotes around the reservation name is appropriate to handle potential spaces in reservation names.

The placement of this code block is logical - after nodes specification and before task count configuration, following the same pattern as other resource parameters.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

@cmeesters
Copy link
Member

cmeesters commented May 15, 2025

Thank you for your contribution!

Honestly? I thought about that flag, too. Then I learned about the magnetic flag for reservations and as I only use reservations during courses, adding something to the executor did not seem necessary any longer. Is there a need for this flag? I am a little bit concerned about adding too many resources, let alone adding flags to the executor. Here, though, this should not be a property of a rule/job, but rather a default resource or a flag passed to snakemake like --slurm-reservation=<name>.

@cmeesters cmeesters changed the title Enables running snakemake job within a slurm cluster reservation. feat: Enables running snakemake job within a slurm cluster reservation. May 15, 2025
@cmeesters cmeesters self-requested a review May 15, 2025 19:13
@@ -50,6 +50,11 @@ def get_submit_command(job, params):
if job.resources.get("nodes", False):
call += f" --nodes={job.resources.get('nodes', 1)}"

# Specify reservation for job if any. Reservation name is in
Copy link
Member

Choose a reason for hiding this comment

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

is this is a resource per job, users would need to alter workflows or write a default resource in their workflow profiles. Both scenarios not really desirable, when wanting to stay as generic as possible. See the comment thread for alternatives.

Copy link
Author

Choose a reason for hiding this comment

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

Hi Christian,
I hadn't considered relying on the magnetic attribute of a reservation. I agree, this would be best as a default resource for a workflow, or passed on the command line, and not a per job resource. This capability is something we would use during post-downtime cluster testing. I'll discuss use of magnetic reservations with our sys admins.
Thanks,
Brett

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