Skip to content

fix: group resources#3367

Closed
fgvieira wants to merge 6 commits intosnakemake:mainfrom
fgvieira:group_resources
Closed

fix: group resources#3367
fgvieira wants to merge 6 commits intosnakemake:mainfrom
fgvieira:group_resources

Conversation

@fgvieira
Copy link
Copy Markdown
Contributor

@fgvieira fgvieira commented Mar 11, 2025

Resources on groups are gathered but, currently, it only works if they are all numeric. If some resources are human-readable strings (e.g. "10 m" or "5 GiB"), it fails.

Should pass all tests with #3421.

QC

  • The PR contains a test case for the changes or the changes are already covered by an existing test case.
  • The documentation (docs/) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake).

Summary by CodeRabbit

  • Chores
    • Updated resource allocations to use descriptive, human-readable formats for memory, enhancing clarity and consistency.
    • Added setuptools, cwltool, and cwl-utils as top-level dependencies in the test environment configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 11, 2025

📝 Walkthrough

Walkthrough

The pull request updates resource specifications within the Snakefile located in the test suite. In the rule named "a", the resource key mem_mb is replaced with mem, while the value remains as "20 GiB". Additionally, the test-environment.yml file is modified to include the dependencies setuptools, cwltool, and cwl-utils directly under the main dependencies section, while removing cwltool and cwl-utils from the nested pip section.

Changes

File Change Summary
tests/.../Snakefile In rule a: changed resource key mem_mb to mem, value remains "20 GiB"
test-environment.yml Added dependencies: setuptools, cwltool, cwl-utils; removed cwltool, cwl-utils from pip section

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

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
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 (2)
test-environment.yml (2)

7-7: New Dependency Addition: setuptools
The dependency setuptools has been added directly under the main dependencies section. This change helps simplify dependency management by ensuring that setuptools is installed from the primary channel list rather than being nested elsewhere. Consider pinning its version if there are concerns about future compatibility.


61-62: Relocating Dependencies: cwltool and cwl-utils
The packages cwltool and cwl-utils have been moved to the main dependencies section, ensuring unified management and installation via the specified channels. This shift removes them from the nested pip section as intended. Verify that these packages are available from the channels in use and consider adding version constraints if necessary for stability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec1533c and cfede10.

⛔ Files ignored due to path filters (1)
  • pyproject.toml is excluded by !pyproject.toml
📒 Files selected for processing (1)
  • test-environment.yml (2 hunks)

@fgvieira fgvieira moved this from Ready to In progress in Snakemake Hackathon March 2025 Mar 14, 2025
johanneskoester pushed a commit that referenced this pull request Feb 5, 2026
This centralizes the code for resource handling into the `resource.py`
file under a new `Resource` class. Notably, `DefaultResources` has been
removed, its functionality rolled into the new class. The same class is
now used for handling global resource limits, default resources, and
rule resource constraints

As a result of this standarization, the following bugs/inconsistencies
are fixed:

1) humanreadable resources can now be specified in a group job in
cluster submit without crashing the program (#3367)
2) `mem`, `mem_mb`, and `mem_mib` can now be used interchangeably across
`--resources`, `--set-resource-scopes`, `--default-resources`,
`--set-resources`, and the `resource` keyword within a `Snakefile`, as
the names are internally standardized.
4) humanreadable resources can now be used in all resource contexts
(e.g. `--resources`)
6) Providing the same effective resource twice (e.g. mem, mem_mb and/or
mem_mib) in the same rule or in the global resource specification raises
an error.
7) **BREAKING** `mem_mb` and `mem_mib` can no longer be provided a
string or a function that returns a string within a rule.
8) The `{resources}` object available within a shell command or
parameter context now has access to all versions of a sized resource,
e.g. `mem`, `mem_mb`, `mem_mib`. `mem` is now always a string with a
unit.


A few additional changes:

- The old `Resource` class in snakemake/io.py (that subclasses
`Namedlist` was renamed to `ResourceList` to prevent confusion. This
class is still used within the `Job` class and is ultimately passed onto
the executor. This ensures compatibility with the existing plugin
interface.
- I added the ability to watch for a specific Exception class within the
tests to help increase the resolution of some of my "failure" tests.
This is completely backwards-compatible
- Additional typing annotations were added throughout the code I
touched.
- A small rearrangement in the code within snakemake/workflow.py to
group the resource-related code together.

### Outstanding issues (not to be resolved here)
1. It was, and remains, possible to sneak a string value as a thread
using `--set-threads` with a python expression
1. --resources cannot be given an expression, per design. Currently,
though, nothing stops one from from providing an expression directly via
the api. This problem preexists this PR.
3. There is currently no testing of the cli parsing functions. This
should be written in a new PR.
4. The check for positive integers is only done for the CLI. Resources
requested within rules will not be so validated. This is unchanged from
previous

### Gotchas
1. This does represent a breaking change for API use, as the dataclasses
will not perform any automatic conversion. Specifically,
ResourceSettings.resources, .overwrite_threads, .overwrite_resources,
and .default_resources will be broken in dependent apps.



<!--Add a description of your PR here-->

### QC
<!-- Make sure that you can tick the boxes below. -->

* [x] The PR contains a test case for the changes or the changes are
already covered by an existing test case.
* [x] The documentation (`docs/`) is updated to reflect the changes or
this is not necessary (e.g. if the change does neither modify the
language nor the behavior or functionalities of Snakemake).


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

# Release Notes

* **New Features**
* Support for human-readable resource specifications (e.g., "1 GB", "1
GiB")
* New resource units: mem_mib, disk_mib alongside existing mem_mb,
disk_mb

* **Bug Fixes**
  * Improved resource handling and validation with better error messages
  * Enhanced resource constraint detection and reporting

* **Refactor**
  * Unified resource management system for simplified configuration
  * Streamlined CLI resource parsing and argument handling
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@fgvieira
Copy link
Copy Markdown
Contributor Author

fgvieira commented Feb 6, 2026

Closing, as no longer relevant.

@fgvieira fgvieira closed this Feb 6, 2026
@github-project-automation github-project-automation bot moved this from In progress to Done in Snakemake Hackathon March 2025 Feb 6, 2026
@fgvieira fgvieira deleted the group_resources branch March 16, 2026 15:12
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