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

feat: job arrays #174

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

feat: job arrays #174

wants to merge 2 commits into from

Conversation

johanneskoester
Copy link
Contributor

@johanneskoester johanneskoester commented Nov 29, 2024

Summary by CodeRabbit

  • New Features
    • Introduced a new method for processing jobs in the Executor class, enhancing job management capabilities.
  • Chores
    • Added necessary imports to support the new functionality.

Copy link
Contributor

coderabbitai bot commented Nov 29, 2024

Warning

Rate limit exceeded

@johanneskoester has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 28 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 3abb561 and 5e8acca.

📒 Files selected for processing (1)
  • snakemake_executor_plugin_slurm/__init__.py (2 hunks)

Walkthrough

The changes introduce a new method, run_jobs, in the Executor class within the snakemake_executor_plugin_slurm module. This method processes jobs grouped by their rule names using the groupby function. For single-job groups, it invokes run_job, while groups with multiple jobs have a placeholder for future enhancements. The import statement for groupby has been added, but existing methods and their functionality remain unchanged.

Changes

File Path Change Summary
snakemake_executor_plugin_slurm/init.py Added run_jobs method to Executor class for processing jobs; added import for groupby.

Sequence Diagram(s)

sequenceDiagram
    participant Executor
    participant JobExecutorInterface

    Executor->>JobExecutorInterface: run_jobs(jobs)
    alt Single Job
        Executor->>JobExecutorInterface: run_job(job)
    else Multiple Jobs
        Executor->>Executor: // TODO: Implement job array submission
    end
Loading

🐰 In the meadow where bunnies hop,
A new method's born, it won't stop!
Jobs grouped by name, they dance and play,
With run_jobs leading the way.
So here's to the code, fresh and bright,
A leap towards the future, oh what a sight! 🌼


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: 2

🧹 Outside diff range and nitpick comments (1)
snakemake_executor_plugin_slurm/__init__.py (1)

111-124: Enhance error handling and logging

The new method should follow the same error handling and logging patterns as the rest of the codebase. Consider adding:

  1. Error handling for empty job lists
  2. Logging for job grouping operations
  3. Consistent error propagation

Here's a suggested implementation:

def run_jobs(self, jobs: List[JobExecutorInterface]):
+    if not jobs:
+        return
+
+    self.logger.debug(f"Grouping {len(jobs)} jobs by rule name")
     try:
         for rule_name, group in groupby(jobs, key=lambda job: job.rule.name):
             same_rule_jobs = list(group)
+            self.logger.debug(
+                f"Processing {len(same_rule_jobs)} jobs for rule '{rule_name}'"
+            )
             if len(same_rule_jobs) == 1:
                 self.run_job(same_rule_jobs[0])
             else:
                 # Temporary implementation: submit jobs individually
                 for job in same_rule_jobs:
                     self.run_job(job)
+    except Exception as e:
+        raise WorkflowError(f"Failed to process job group: {str(e)}")
🧰 Tools
🪛 Ruff (0.8.0)

114-114: Using the generator returned from itertools.groupby() more than once will do nothing on the second usage

(B031)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

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

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

114-114: Using the generator returned from itertools.groupby() more than once will do nothing on the second usage

(B031)

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

8-8: LGTM!

The groupby import is correctly placed with other standard library imports and is required for the new job array functionality.

Comment on lines 115 to 124
else:
# TODO submit as array
# share code with run_job

# TODO in the future: give a hint to the scheduler to select preferably
# many jobs from the same rule if possible, in order to have
# more efficient array jobs. This should be somehow tunable, because
# it might contradict other efficiency goals.
...

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Implement placeholder for array jobs

The current implementation uses an ellipsis (...) as a placeholder, which will raise a NotImplementedError. Until the array job submission is implemented, we should handle these jobs individually.

Apply this improvement to handle multi-job groups temporarily:

         else:
             # TODO submit as array
             # share code with run_job
-            ...
+            # Temporary implementation: submit jobs individually until array support is added
+            for job in same_rule_jobs:
+                self.run_job(job)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
else:
# TODO submit as array
# share code with run_job
# TODO in the future: give a hint to the scheduler to select preferably
# many jobs from the same rule if possible, in order to have
# more efficient array jobs. This should be somehow tunable, because
# it might contradict other efficiency goals.
...
else:
# TODO submit as array
# share code with run_job
# TODO in the future: give a hint to the scheduler to select preferably
# many jobs from the same rule if possible, in order to have
# more efficient array jobs. This should be somehow tunable, because
# it might contradict other efficiency goals.
# Temporary implementation: submit jobs individually until array support is added
for job in same_rule_jobs:
self.run_job(job)

snakemake_executor_plugin_slurm/__init__.py Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@johanneskoester
Copy link
Contributor Author

johanneskoester commented Dec 20, 2024

Plan: support aggregation of jobs in the Snakemake scheduler before they are send to the executor. This can be done by supporting a new standard resource min_jobs that tells the scheduler how many jobs shall be considered at least of a given rule. Of course, this resource will be automatically limited to the theoretical maximum number of jobs from that rule. The latter has to consider that a rule may occur in different topological levels of the workflow, which should be treated independently.

This way we avoid the case that jobs drop into the executor in a too fine-grained way.
Admins can even set this resource to the minimum size they want to have for array jobs on their cluster.

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.

1 participant