Skip to content

feat: add function get_tmp to ioutils, and allow ioutils functions to be used when parsing resources#3820

Open
fgvieira wants to merge 44 commits intosnakemake:mainfrom
fgvieira:tmp_list
Open

feat: add function get_tmp to ioutils, and allow ioutils functions to be used when parsing resources#3820
fgvieira wants to merge 44 commits intosnakemake:mainfrom
fgvieira:tmp_list

Conversation

@fgvieira
Copy link
Copy Markdown
Contributor

@fgvieira fgvieira commented Oct 31, 2025

Sometimes, HPC nodes have different options to write temp depending on the hardware (e.g. some might have nvme).

This function allows the use to specify a list of possible temp folders that, on each job submission, is evaluated. The first valid dir is selected.

Moved dynamic resources to after standard and default resources.

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

  • New Features

    • Adds a helper to select a usable temporary directory and exposes it for use in workflows and resource expressions.
    • Resource expressions can now reference ioutils helpers during evaluation.
  • Tests

    • Workflow tests consolidated to exercise dynamic tmpdir selection via profile-based runs; one legacy default-only test removed.
  • Documentation

    • Expanded guidance and examples for standard/default resources, dynamic resources, and tmpdir configuration.
  • Chores

    • CI test matrix parallelism increased for faster runs.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 31, 2025

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a new helper choose_tmp that selects a creatable temporary directory, exposes it via snakemake.ioutils globals, integrates ioutils into resource-expression evaluation so expressions can call ioutils helpers, and updates tests, a test profile, documentation, and CI config.

Changes

Cohort / File(s) Summary
New temporary directory utility
src/snakemake/ioutils/tmp.py
New module adding choose_tmp(tmpdirs: List) -> str with nested is_dir_creatable(dir: Path) -> bool; returns first creatable candidate or the "system_tmpdir" fallback.
ioutils public API export
src/snakemake/ioutils/__init__.py
Imports choose_tmp and registers it in the public globals via register_in_globals, exposing "choose_tmp": choose_tmp.
Resource expression integration
src/snakemake/resources.py
eval_resource_expression now builds an ioutils globals dict via snakemake.ioutils.register_in_globals(ioutils) and passes it as globals to eval, enabling resource expressions to call ioutils helpers.
Tests / Snakefile
tests/test_tmpdir/Snakefile, tests/tests.py
Snakefile: minor formatting; rule b no longer hardcodes tmpdir. tests/tests.py: consolidated test flow to load derived profile and run Snakemake with --profile, removed the separate default test.
Test profile config
tests/test_tmpdir/profile/config.yaml
Adds default-resources using tmpdir selection via choose_tmp(["/non_existent", "foo"]).
Documentation
docs/snakefiles/rules.rst
Extensive updates to resource documentation (standard/default/dynamic resources), examples and guidance referencing choose_tmp.
CI
.github/workflows/main.yml
Testing job strategy set max-parallel: 10 for matrix parallelism.

Sequence Diagram

sequenceDiagram
    participant Expr as Resource expression
    participant Res as eval_resource_expression
    participant IOU as snakemake.ioutils
    participant Tmp as choose_tmp
    participant FS as Filesystem

    Expr->>Res: request evaluation of expression
    Res->>IOU: import snakemake.ioutils
    IOU->>IOU: register_in_globals(ioutils_dict)
    Res->>Res: eval(expression, globals=ioutils_dict, locals=provided_locals)
    Expr->>Tmp: call choose_tmp(tmpdirs_list)
    loop for each tmpdir candidate
        Tmp->>FS: is_dir_creatable checks (parent exists, dir status, perms)
        alt creatable
            Tmp-->>Expr: return chosen tmpdir
        else not creatable
            Tmp->>Tmp: try next candidate
        end
    end
    alt none creatable
        Tmp-->>Expr: return "system_tmpdir"
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: adding a function (choose_tmp) to ioutils and enabling ioutils functions in resource parsing.
Description check ✅ Passed The description explains the motivation (HPC heterogeneity), the solution (choose_tmp helper), documentation updates, and both QC checkboxes are completed.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@fgvieira fgvieira changed the title Tmp list feat: add function get_tmp to ioutils, and allow ioutils functions to be used when parsing resources Oct 31, 2025
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: 2

🧹 Nitpick comments (2)
src/snakemake/ioutils/tmp.py (2)

5-5: Specify the element type in the List type hint.

The type hint List should be List[str] to indicate that the function expects a list of string paths.

Apply this diff:

-def get_tmp(tmpdirs: List) -> str:
+def get_tmp(tmpdirs: List[str]) -> str:

28-32: Simplify the loop by removing redundant else clause.

The else: continue statement is redundant since the loop will naturally continue to the next iteration.

Apply this diff:

     for tmpdir in tmpdirs:
         if is_dir_creatable(Path(tmpdir)):
             return tmpdir
-        else:
-            continue
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 83c05cc and 5b0178c.

📒 Files selected for processing (3)
  • src/snakemake/ioutils/__init__.py (2 hunks)
  • src/snakemake/ioutils/tmp.py (1 hunks)
  • src/snakemake/resources.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

Files:

  • src/snakemake/ioutils/tmp.py
  • src/snakemake/resources.py
  • src/snakemake/ioutils/__init__.py
🧠 Learnings (2)
📚 Learning: 2024-12-14T13:11:32.988Z
Learnt from: johanneskoester
Repo: snakemake/snakemake PR: 2927
File: snakemake/ioutils/evaluate.py:11-11
Timestamp: 2024-12-14T13:11:32.988Z
Learning: In `snakemake/ioutils/evaluate.py`, the use of `eval()` with `globals()` is acceptable because it's called by the user under consideration of the implications.

Applied to files:

  • src/snakemake/resources.py
📚 Learning: 2025-08-28T13:17:37.693Z
Learnt from: Hocnonsense
Repo: snakemake/snakemake PR: 3714
File: src/snakemake/workflow.py:637-665
Timestamp: 2025-08-28T13:17:37.693Z
Learning: In Snakemake, rule.module_globals["__name__"] always exists and defaults to "snakemake.workflow" when not modified, so direct dictionary access is safe without needing .get().

Applied to files:

  • src/snakemake/ioutils/__init__.py
🧬 Code graph analysis (2)
src/snakemake/resources.py (1)
src/snakemake/ioutils/__init__.py (1)
  • register_in_globals (12-31)
src/snakemake/ioutils/__init__.py (1)
src/snakemake/ioutils/tmp.py (1)
  • get_tmp (5-33)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (46)
  • GitHub Check: tests (10, ubuntu-latest, py313)
  • GitHub Check: tests (10, ubuntu-latest, py312)
  • GitHub Check: tests (9, ubuntu-latest, py313)
  • GitHub Check: tests (10, ubuntu-latest, py311)
  • GitHub Check: tests (10, windows-2022, py313)
  • GitHub Check: tests (9, ubuntu-latest, py311)
  • GitHub Check: tests (9, windows-2022, py313)
  • GitHub Check: tests (7, ubuntu-latest, py313)
  • GitHub Check: tests (7, windows-2022, py313)
  • GitHub Check: tests (8, ubuntu-latest, py313)
  • GitHub Check: tests (8, macos-latest, py313)
  • GitHub Check: tests (8, ubuntu-latest, py311)
  • GitHub Check: tests (8, ubuntu-latest, py312)
  • GitHub Check: tests (9, ubuntu-latest, py312)
  • GitHub Check: tests (8, windows-2022, py313)
  • GitHub Check: tests (7, ubuntu-latest, py312)
  • GitHub Check: tests (6, ubuntu-latest, py313)
  • GitHub Check: tests (5, ubuntu-latest, py312)
  • GitHub Check: tests (7, ubuntu-latest, py311)
  • GitHub Check: tests (6, ubuntu-latest, py312)
  • GitHub Check: tests (6, ubuntu-latest, py311)
  • GitHub Check: tests (6, macos-latest, py313)
  • GitHub Check: tests (6, windows-2022, py313)
  • GitHub Check: tests (5, ubuntu-latest, py313)
  • GitHub Check: tests (5, ubuntu-latest, py311)
  • GitHub Check: tests (5, windows-2022, py313)
  • GitHub Check: tests (3, windows-2022, py313)
  • GitHub Check: tests (4, ubuntu-latest, py311)
  • GitHub Check: tests (4, ubuntu-latest, py312)
  • GitHub Check: tests (4, ubuntu-latest, py313)
  • GitHub Check: tests (4, windows-2022, py313)
  • GitHub Check: tests (3, ubuntu-latest, py313)
  • GitHub Check: tests (3, ubuntu-latest, py311)
  • GitHub Check: tests (3, macos-latest, py313)
  • GitHub Check: tests (2, ubuntu-latest, py311)
  • GitHub Check: tests (3, ubuntu-latest, py312)
  • GitHub Check: tests (2, windows-2022, py313)
  • GitHub Check: tests (2, ubuntu-latest, py312)
  • GitHub Check: tests (2, ubuntu-latest, py313)
  • GitHub Check: tests (2, macos-latest, py313)
  • GitHub Check: tests (1, macos-latest, py313)
  • GitHub Check: tests (1, ubuntu-latest, py311)
  • GitHub Check: tests (1, windows-2022, py313)
  • GitHub Check: tests (1, ubuntu-latest, py313)
  • GitHub Check: tests (1, ubuntu-latest, py312)
  • GitHub Check: apidocs
🔇 Additional comments (2)
src/snakemake/resources.py (1)

534-544: LGTM! Clean integration of ioutils into resource evaluation.

The implementation correctly registers ioutils functions into the global namespace for eval, enabling resource expressions to access utilities like get_tmp. The comment accurately explains precedence behavior.

src/snakemake/ioutils/__init__.py (1)

9-9: LGTM! Consistent API extension.

The import and registration of get_tmp follows the established pattern for exposing ioutils functions.

Also applies to: 29-29

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

♻️ Duplicate comments (1)
src/snakemake/ioutils/tmp.py (1)

33-33: Return actual system temp directory, not a placeholder string.

When get_tmp is called within a resource expression via eval(), returning the literal string "system_tmpdir" will not trigger a lookup in the evaluation context. The function should return the actual system temporary directory path.

Apply this diff:

+    import tempfile
+
     for tmpdir in tmpdirs:
         if is_dir_creatable(Path(tmpdir)):
             return tmpdir
-    return "system_tmpdir"
+    return tempfile.gettempdir()
🧹 Nitpick comments (1)
src/snakemake/ioutils/tmp.py (1)

31-32: Remove redundant else clause.

The else: continue statement is unnecessary since the loop will continue by default when the if condition is false.

Apply this diff:

     for tmpdir in tmpdirs:
         if is_dir_creatable(Path(tmpdir)):
             return tmpdir
-        else:
-            continue
     return "system_tmpdir"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 63ad8f9 and 40c066c.

📒 Files selected for processing (2)
  • docs/snakefiles/rules.rst (1 hunks)
  • src/snakemake/ioutils/tmp.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

Files:

  • src/snakemake/ioutils/tmp.py
🧠 Learnings (3)
📚 Learning: 2024-12-14T13:11:32.988Z
Learnt from: johanneskoester
Repo: snakemake/snakemake PR: 2927
File: snakemake/ioutils/evaluate.py:11-11
Timestamp: 2024-12-14T13:11:32.988Z
Learning: In `snakemake/ioutils/evaluate.py`, the use of `eval()` with `globals()` is acceptable because it's called by the user under consideration of the implications.

Applied to files:

  • src/snakemake/ioutils/tmp.py
📚 Learning: 2024-10-06T14:09:54.370Z
Learnt from: johanneskoester
Repo: snakemake/snakemake PR: 3117
File: tests/test_wrapper/Snakefile:11-11
Timestamp: 2024-10-06T14:09:54.370Z
Learning: Changes made within test cases, such as in `tests/test_wrapper/Snakefile`, are for testing purposes and do not require updates to the project documentation.

Applied to files:

  • docs/snakefiles/rules.rst
📚 Learning: 2024-12-14T13:10:48.450Z
Learnt from: johanneskoester
Repo: snakemake/snakemake PR: 2927
File: tests/test_subpath/Snakefile:11-11
Timestamp: 2024-12-14T13:10:48.450Z
Learning: In Snakemake, when a rule defines a single output file (even if the output is specified as a dictionary), `{output}` in the shell command can be used directly to refer to that file.

Applied to files:

  • docs/snakefiles/rules.rst
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (46)
  • GitHub Check: tests (10, ubuntu-latest, py313)
  • GitHub Check: tests (9, windows-2022, py313)
  • GitHub Check: tests (10, ubuntu-latest, py312)
  • GitHub Check: tests (8, windows-2022, py313)
  • GitHub Check: tests (7, ubuntu-latest, py311)
  • GitHub Check: tests (9, ubuntu-latest, py313)
  • GitHub Check: tests (10, windows-2022, py313)
  • GitHub Check: tests (9, ubuntu-latest, py312)
  • GitHub Check: tests (10, ubuntu-latest, py311)
  • GitHub Check: tests (8, ubuntu-latest, py311)
  • GitHub Check: tests (9, ubuntu-latest, py311)
  • GitHub Check: tests (8, ubuntu-latest, py313)
  • GitHub Check: tests (7, ubuntu-latest, py313)
  • GitHub Check: tests (8, ubuntu-latest, py312)
  • GitHub Check: tests (7, windows-2022, py313)
  • GitHub Check: tests (5, macos-latest, py313)
  • GitHub Check: tests (6, macos-latest, py313)
  • GitHub Check: tests (2, ubuntu-latest, py311)
  • GitHub Check: tests (7, ubuntu-latest, py312)
  • GitHub Check: tests (5, windows-2022, py313)
  • GitHub Check: tests (4, ubuntu-latest, py311)
  • GitHub Check: tests (6, ubuntu-latest, py311)
  • GitHub Check: tests (6, ubuntu-latest, py312)
  • GitHub Check: tests (6, windows-2022, py313)
  • GitHub Check: tests (5, ubuntu-latest, py313)
  • GitHub Check: tests (5, ubuntu-latest, py312)
  • GitHub Check: tests (6, ubuntu-latest, py313)
  • GitHub Check: tests (4, ubuntu-latest, py313)
  • GitHub Check: tests (5, ubuntu-latest, py311)
  • GitHub Check: tests (4, windows-2022, py313)
  • GitHub Check: tests (4, ubuntu-latest, py312)
  • GitHub Check: tests (3, windows-2022, py313)
  • GitHub Check: tests (3, ubuntu-latest, py313)
  • GitHub Check: tests (3, macos-latest, py313)
  • GitHub Check: tests (2, ubuntu-latest, py313)
  • GitHub Check: tests (3, ubuntu-latest, py312)
  • GitHub Check: tests (2, macos-latest, py313)
  • GitHub Check: tests (3, ubuntu-latest, py311)
  • GitHub Check: tests (2, ubuntu-latest, py312)
  • GitHub Check: tests (1, ubuntu-latest, py312)
  • GitHub Check: tests (2, windows-2022, py313)
  • GitHub Check: tests (1, macos-latest, py313)
  • GitHub Check: tests (1, ubuntu-latest, py313)
  • GitHub Check: tests (1, windows-2022, py313)
  • GitHub Check: tests (1, ubuntu-latest, py311)
  • GitHub Check: apidocs
🔇 Additional comments (3)
docs/snakefiles/rules.rst (3)

791-792: LGTM!

Header formatting update is consistent with documentation style.


799-809: Clear documentation of the get_tmp feature.

The documentation clearly explains the use case and provides a practical example. The description of falling back to the system temp directory is accurate for the intended behavior.


813-814: LGTM!

Header formatting update maintains documentation consistency.

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

♻️ Duplicate comments (1)
src/snakemake/ioutils/tmp.py (1)

33-33: Return actual system temp directory path.

The function currently returns the literal string "system_tmpdir", which won't resolve to a usable path when evaluated in resource expressions. This should return the actual system temporary directory.

Apply this diff to fix:

+    import tempfile
+
     for tmpdir in tmpdirs:
         if is_dir_creatable(Path(tmpdir)):
             return tmpdir
-    return "system_tmpdir"
+    return tempfile.gettempdir()
🧹 Nitpick comments (1)
src/snakemake/ioutils/tmp.py (1)

28-32: Optional: Remove redundant else clause.

The else: continue is implicit in a for loop and can be removed for cleaner code.

Apply this diff if desired:

     for tmpdir in tmpdirs:
         if is_dir_creatable(Path(tmpdir)):
             return tmpdir
-        else:
-            continue
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b71370 and ae319b5.

📒 Files selected for processing (4)
  • docs/snakefiles/rules.rst (1 hunks)
  • src/snakemake/ioutils/__init__.py (2 hunks)
  • src/snakemake/ioutils/tmp.py (1 hunks)
  • tests/test_tmpdir/Snakefile (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/snakefiles/rules.rst
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

Files:

  • src/snakemake/ioutils/tmp.py
  • src/snakemake/ioutils/__init__.py
🧠 Learnings (7)
📚 Learning: 2024-12-14T13:11:32.988Z
Learnt from: johanneskoester
Repo: snakemake/snakemake PR: 2927
File: snakemake/ioutils/evaluate.py:11-11
Timestamp: 2024-12-14T13:11:32.988Z
Learning: In `snakemake/ioutils/evaluate.py`, the use of `eval()` with `globals()` is acceptable because it's called by the user under consideration of the implications.

Applied to files:

  • src/snakemake/ioutils/tmp.py
📚 Learning: 2025-08-28T13:17:37.693Z
Learnt from: Hocnonsense
Repo: snakemake/snakemake PR: 3714
File: src/snakemake/workflow.py:637-665
Timestamp: 2025-08-28T13:17:37.693Z
Learning: In Snakemake, rule.module_globals["__name__"] always exists and defaults to "snakemake.workflow" when not modified, so direct dictionary access is safe without needing .get().

Applied to files:

  • src/snakemake/ioutils/__init__.py
📚 Learning: 2024-10-06T14:09:54.370Z
Learnt from: johanneskoester
Repo: snakemake/snakemake PR: 3117
File: tests/test_wrapper/Snakefile:11-11
Timestamp: 2024-10-06T14:09:54.370Z
Learning: Changes made within test cases, such as in `tests/test_wrapper/Snakefile`, are for testing purposes and do not require updates to the project documentation.

Applied to files:

  • tests/test_tmpdir/Snakefile
📚 Learning: 2024-12-21T15:10:31.992Z
Learnt from: johanneskoester
Repo: snakemake/snakemake PR: 2925
File: tests/test_nonstr_params/Snakefile:14-15
Timestamp: 2024-12-21T15:10:31.992Z
Learning: The file "test.jsonl" in tests/test_nonstr_params is automatically created by Snakemake, rather than manually generated in the Snakefile.

Applied to files:

  • tests/test_tmpdir/Snakefile
📚 Learning: 2024-08-13T16:09:09.726Z
Learnt from: johanneskoester
Repo: snakemake/snakemake PR: 3014
File: snakemake/dag.py:1265-1266
Timestamp: 2024-08-13T16:09:09.726Z
Learning: For the Snakemake project, avoid suggesting trailing commas as they use Black as an autoformatter.

Applied to files:

  • tests/test_tmpdir/Snakefile
📚 Learning: 2025-01-17T12:00:09.368Z
Learnt from: leoschwarz
Repo: snakemake/snakemake PR: 3176
File: tests/test_output_index.py:99-157
Timestamp: 2025-01-17T12:00:09.368Z
Learning: New test dependencies for Snakemake should be introduced in separate PRs rather than being added as part of feature or refactoring PRs.

Applied to files:

  • tests/test_tmpdir/Snakefile
📚 Learning: 2024-12-14T13:10:48.450Z
Learnt from: johanneskoester
Repo: snakemake/snakemake PR: 2927
File: tests/test_subpath/Snakefile:11-11
Timestamp: 2024-12-14T13:10:48.450Z
Learning: In Snakemake, when a rule defines a single output file (even if the output is specified as a dictionary), `{output}` in the shell command can be used directly to refer to that file.

Applied to files:

  • tests/test_tmpdir/Snakefile
🧬 Code graph analysis (1)
src/snakemake/ioutils/__init__.py (1)
src/snakemake/ioutils/tmp.py (1)
  • choose_tmp (5-33)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (46)
  • GitHub Check: tests (9, ubuntu-latest, py311)
  • GitHub Check: tests (9, ubuntu-latest, py312)
  • GitHub Check: tests (10, windows-2022, py313)
  • GitHub Check: tests (10, ubuntu-latest, py313)
  • GitHub Check: tests (8, ubuntu-latest, py312)
  • GitHub Check: tests (10, ubuntu-latest, py311)
  • GitHub Check: tests (9, windows-2022, py313)
  • GitHub Check: tests (8, windows-2022, py313)
  • GitHub Check: tests (10, ubuntu-latest, py312)
  • GitHub Check: tests (8, ubuntu-latest, py313)
  • GitHub Check: tests (9, ubuntu-latest, py313)
  • GitHub Check: tests (7, ubuntu-latest, py311)
  • GitHub Check: tests (7, windows-2022, py313)
  • GitHub Check: tests (6, ubuntu-latest, py312)
  • GitHub Check: tests (3, ubuntu-latest, py311)
  • GitHub Check: tests (5, windows-2022, py313)
  • GitHub Check: tests (5, ubuntu-latest, py313)
  • GitHub Check: tests (4, ubuntu-latest, py313)
  • GitHub Check: tests (7, ubuntu-latest, py313)
  • GitHub Check: tests (3, macos-latest, py313)
  • GitHub Check: tests (6, ubuntu-latest, py311)
  • GitHub Check: tests (6, windows-2022, py313)
  • GitHub Check: tests (7, ubuntu-latest, py312)
  • GitHub Check: tests (5, ubuntu-latest, py312)
  • GitHub Check: tests (3, windows-2022, py313)
  • GitHub Check: tests (6, ubuntu-latest, py313)
  • GitHub Check: tests (4, ubuntu-latest, py312)
  • GitHub Check: tests (8, ubuntu-latest, py311)
  • GitHub Check: tests (3, ubuntu-latest, py313)
  • GitHub Check: tests (6, macos-latest, py313)
  • GitHub Check: tests (5, ubuntu-latest, py311)
  • GitHub Check: tests (5, macos-latest, py313)
  • GitHub Check: tests (4, windows-2022, py313)
  • GitHub Check: tests (4, ubuntu-latest, py311)
  • GitHub Check: tests (2, ubuntu-latest, py312)
  • GitHub Check: tests (1, windows-2022, py313)
  • GitHub Check: tests (1, ubuntu-latest, py313)
  • GitHub Check: tests (2, macos-latest, py313)
  • GitHub Check: tests (1, ubuntu-latest, py311)
  • GitHub Check: tests (2, ubuntu-latest, py313)
  • GitHub Check: tests (1, ubuntu-latest, py312)
  • GitHub Check: tests (2, windows-2022, py313)
  • GitHub Check: tests (3, ubuntu-latest, py312)
  • GitHub Check: tests (2, ubuntu-latest, py311)
  • GitHub Check: tests (1, macos-latest, py313)
  • GitHub Check: apidocs
🔇 Additional comments (3)
tests/test_tmpdir/Snakefile (1)

14-14: LGTM! Test correctly validates fallback behavior.

The test appropriately exercises choose_tmp by providing a non-existent path first, ensuring the function falls back to the second option.

src/snakemake/ioutils/__init__.py (1)

9-9: LGTM! Proper public API exposure.

The import and registration of choose_tmp follow the established pattern for exposing ioutils functions.

Also applies to: 29-29

src/snakemake/ioutils/tmp.py (1)

26-26: Good fix on the recursive return.

The past review correctly identified that the recursive call needed an explicit return statement, which has been properly addressed.

@johanneskoester
Copy link
Copy Markdown
Contributor

Why not just relying on the tmpdir resource, which can be configured by the admins or the user via the standard tmpdir env variable?

@fgvieira
Copy link
Copy Markdown
Contributor Author

The issue is when HPC have different hardware configurations. In my case, some have a fast nvme scratch space, while others only have a slow nfs scratch. Since we never know where the jobs will be submitted to, this decision has to be made at runtime.

The best solution would definitely be to have the admins define the best temp folder into a env variable, and use it in tmpdir resource. However, it might not be possible.
As for the user defining the tempdir via the standard tmpdir env variable, how would you do it at runtime?

The idea here is to define a helper function that can be passed to resources.tmpdir to select the first valid folder of a list or, if none, system_tmpdir. For example:

resources:
    tmpdir = choose_tmp(["/fast_nvme", "/home/$USER/scratch", "/scratch/$SLURM_JOB_ID"])

This function would be executed at runtime and, depending on the node, it would select the first folder that meets certain criteria to be a tmpdir.

"parse_input": parse_input,
"extract_checksum": extract_checksum,
"flatten": flatten,
"choose_tmp": choose_tmp,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think in addition this needs to be present in the eval environment for resource expressions, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, but I think I have already included it in src/snakemake/resources.py, no?

fgvieira and others added 2 commits December 3, 2025 13:22
Co-authored-by: Johannes Köster <johannes.koester@uni-due.de>
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: 1

♻️ Duplicate comments (2)
src/snakemake/ioutils/tmp.py (2)

12-26: Missing return statement breaks recursive directory check.

Line 26 calls is_dir_creatable(dir.parent) recursively but doesn't return the result, causing the function to implicitly return None instead of propagating the boolean result from parent directory checks.

Apply this diff:

         else:
-            return is_dir_creatable(dir.parent)
+            return is_dir_creatable(dir.parent)

33-33: Return actual system temp directory, not the string placeholder.

When called within a resource expression via eval(), returning the string "system_tmpdir" will not trigger a lookup in the evaluation context. The function should return the actual system temporary directory path.

Apply this diff:

+    import tempfile
+
     for tmpdir in tmpdirs:
         if is_dir_creatable(Path(tmpdir)):
             return tmpdir
-    return "system_tmpdir"
+    return tempfile.gettempdir()
🧹 Nitpick comments (1)
src/snakemake/ioutils/tmp.py (1)

28-32: Remove redundant else: continue clause.

The else: continue on lines 31-32 is redundant since the loop naturally continues when the condition is not met.

Apply this diff:

     for tmpdir in tmpdirs:
         if is_dir_creatable(Path(tmpdir)):
             return tmpdir
-        else:
-            continue
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56fe95e and a436080.

📒 Files selected for processing (1)
  • src/snakemake/ioutils/tmp.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

Files:

  • src/snakemake/ioutils/tmp.py
🧠 Learnings (1)
📚 Learning: 2024-12-14T13:11:32.988Z
Learnt from: johanneskoester
Repo: snakemake/snakemake PR: 2927
File: snakemake/ioutils/evaluate.py:11-11
Timestamp: 2024-12-14T13:11:32.988Z
Learning: In `snakemake/ioutils/evaluate.py`, the use of `eval()` with `globals()` is acceptable because it's called by the user under consideration of the implications.

Applied to files:

  • src/snakemake/ioutils/tmp.py
🪛 Ruff (0.14.7)
src/snakemake/ioutils/tmp.py

5-5: Undefined name Union

(F821)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: tests (10, windows-2022, py313)
  • GitHub Check: tests (8, macos-latest, py313)
  • GitHub Check: tests (9, windows-2022, py313)
  • GitHub Check: tests (7, windows-2022, py313)
  • GitHub Check: tests (8, windows-2022, py313)
  • GitHub Check: tests (7, macos-latest, py313)
  • GitHub Check: tests (6, windows-2022, py313)
  • GitHub Check: tests (5, macos-latest, py313)
  • GitHub Check: tests (5, windows-2022, py313)
  • GitHub Check: tests (4, windows-2022, py313)
  • GitHub Check: tests (4, macos-latest, py313)
  • GitHub Check: tests (3, macos-latest, py313)
  • GitHub Check: tests (3, windows-2022, py313)
  • GitHub Check: tests (2, windows-2022, py313)
  • GitHub Check: tests (1, windows-2022, py313)
  • GitHub Check: apidocs
🔇 Additional comments (1)
src/snakemake/ioutils/tmp.py (1)

5-10: Verify environment variable expansion is handled.

The PR objectives mention example usage like choose_tmp(["/fast_nvme", "/home/$USER/scratch", "/scratch/$SLURM_JOB_ID"]) with environment variables, but the current implementation doesn't expand variables like $USER or $SLURM_JOB_ID. Please verify that variable expansion is handled at an earlier stage (e.g., during resource expression evaluation) or consider using os.path.expandvars() on each tmpdir path before checking creatability.

If expansion is needed here, apply this diff:

+    import os
+
     def is_dir_creatable(dir: Path) -> bool:
-        import os
 
         if dir == dir.parent:
             return False

And update the loop:

     for tmpdir in tmpdirs:
-        if is_dir_creatable(Path(tmpdir)):
-            return tmpdir
+        expanded = os.path.expandvars(str(tmpdir))
+        if is_dir_creatable(Path(expanded)):
+            return expanded

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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

♻️ Duplicate comments (1)
src/snakemake/ioutils/tmp.py (1)

33-33: Return actual system temp directory, not string placeholder.

When used in resource expressions via eval(), returning the literal string "system_tmpdir" will not resolve to an actual path. The function should return the actual system temporary directory.

Apply this diff:

+    import tempfile
+
     for tmpdir in tmpdirs:
         if is_dir_creatable(Path(tmpdir)):
             return tmpdir
-        else:
-            continue
-    return "system_tmpdir"
+    return tempfile.gettempdir()
🧹 Nitpick comments (1)
src/snakemake/ioutils/tmp.py (1)

32-32: Optional: Remove redundant continue.

The continue statement is redundant at the end of the loop body.

Apply this diff:

         if is_dir_creatable(Path(tmpdir)):
             return tmpdir
-        else:
-            continue
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 802c7aa and 3c06bcf.

📒 Files selected for processing (1)
  • src/snakemake/ioutils/tmp.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

Files:

  • src/snakemake/ioutils/tmp.py
🧠 Learnings (1)
📚 Learning: 2024-12-14T13:11:32.988Z
Learnt from: johanneskoester
Repo: snakemake/snakemake PR: 2927
File: snakemake/ioutils/evaluate.py:11-11
Timestamp: 2024-12-14T13:11:32.988Z
Learning: In `snakemake/ioutils/evaluate.py`, the use of `eval()` with `globals()` is acceptable because it's called by the user under consideration of the implications.

Applied to files:

  • src/snakemake/ioutils/tmp.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (47)
  • GitHub Check: tests (10, ubuntu-latest, py311)
  • GitHub Check: tests (9, ubuntu-latest, py311)
  • GitHub Check: tests (10, ubuntu-latest, py313)
  • GitHub Check: tests (7, windows-2022, py313)
  • GitHub Check: tests (10, windows-2022, py313)
  • GitHub Check: tests (10, ubuntu-latest, py312)
  • GitHub Check: tests (6, windows-2022, py313)
  • GitHub Check: tests (8, ubuntu-latest, py313)
  • GitHub Check: tests (8, ubuntu-latest, py312)
  • GitHub Check: tests (8, windows-2022, py313)
  • GitHub Check: tests (6, ubuntu-latest, py313)
  • GitHub Check: tests (9, windows-2022, py313)
  • GitHub Check: tests (9, ubuntu-latest, py313)
  • GitHub Check: tests (7, ubuntu-latest, py311)
  • GitHub Check: tests (5, macos-latest, py313)
  • GitHub Check: tests (9, ubuntu-latest, py312)
  • GitHub Check: tests (8, ubuntu-latest, py311)
  • GitHub Check: tests (7, ubuntu-latest, py313)
  • GitHub Check: tests (6, ubuntu-latest, py311)
  • GitHub Check: tests (7, ubuntu-latest, py312)
  • GitHub Check: tests (8, macos-latest, py313)
  • GitHub Check: tests (6, ubuntu-latest, py312)
  • GitHub Check: tests (5, ubuntu-latest, py311)
  • GitHub Check: tests (5, ubuntu-latest, py313)
  • GitHub Check: tests (4, ubuntu-latest, py311)
  • GitHub Check: tests (4, macos-latest, py313)
  • GitHub Check: tests (5, ubuntu-latest, py312)
  • GitHub Check: tests (3, windows-2022, py313)
  • GitHub Check: tests (5, windows-2022, py313)
  • GitHub Check: tests (4, windows-2022, py313)
  • GitHub Check: tests (3, macos-latest, py313)
  • GitHub Check: tests (2, macos-latest, py313)
  • GitHub Check: tests (4, ubuntu-latest, py313)
  • GitHub Check: tests (3, ubuntu-latest, py311)
  • GitHub Check: tests (4, ubuntu-latest, py312)
  • GitHub Check: tests (3, ubuntu-latest, py312)
  • GitHub Check: tests (3, ubuntu-latest, py313)
  • GitHub Check: tests (2, windows-2022, py313)
  • GitHub Check: tests (2, ubuntu-latest, py312)
  • GitHub Check: tests (2, ubuntu-latest, py313)
  • GitHub Check: tests (2, ubuntu-latest, py311)
  • GitHub Check: tests (1, ubuntu-latest, py312)
  • GitHub Check: tests (1, ubuntu-latest, py311)
  • GitHub Check: tests (1, windows-2022, py313)
  • GitHub Check: tests (1, ubuntu-latest, py313)
  • GitHub Check: formatting
  • GitHub Check: apidocs
🔇 Additional comments (3)
src/snakemake/ioutils/tmp.py (3)

1-2: LGTM! Import issue resolved.

The Union import has been added as recommended in previous reviews. All necessary imports are now present.


5-10: LGTM!

Function signature and docstring are clear and correctly typed.


12-26: LGTM! Recursive return fixed.

The missing return statement on line 26 has been corrected. The helper function now properly propagates the boolean result from parent directory checks.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3c06bcf and 78c5c4b.

📒 Files selected for processing (4)
  • docs/snakefiles/rules.rst (3 hunks)
  • tests/test_tmpdir/Snakefile (1 hunks)
  • tests/test_tmpdir/profile/config.yaml (1 hunks)
  • tests/tests.py (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tests/test_tmpdir/profile/config.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/test_tmpdir/Snakefile
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

Files:

  • tests/tests.py
🧠 Learnings (5)
📚 Learning: 2024-10-06T14:09:54.370Z
Learnt from: johanneskoester
Repo: snakemake/snakemake PR: 3117
File: tests/test_wrapper/Snakefile:11-11
Timestamp: 2024-10-06T14:09:54.370Z
Learning: Changes made within test cases, such as in `tests/test_wrapper/Snakefile`, are for testing purposes and do not require updates to the project documentation.

Applied to files:

  • docs/snakefiles/rules.rst
  • tests/tests.py
📚 Learning: 2024-12-14T13:10:48.450Z
Learnt from: johanneskoester
Repo: snakemake/snakemake PR: 2927
File: tests/test_subpath/Snakefile:11-11
Timestamp: 2024-12-14T13:10:48.450Z
Learning: In Snakemake, when a rule defines a single output file (even if the output is specified as a dictionary), `{output}` in the shell command can be used directly to refer to that file.

Applied to files:

  • docs/snakefiles/rules.rst
📚 Learning: 2025-10-30T15:39:38.224Z
Learnt from: johanneskoester
Repo: snakemake/snakemake PR: 3813
File: tests/test_pathvars/Snakefile:22-23
Timestamp: 2025-10-30T15:39:38.224Z
Learning: In Snakemake, `<resources>` is a default pathvar that does not need to be explicitly defined in the pathvars section. It is available for use in rules and functions without requiring declaration.

Applied to files:

  • docs/snakefiles/rules.rst
📚 Learning: 2025-01-17T12:00:09.368Z
Learnt from: leoschwarz
Repo: snakemake/snakemake PR: 3176
File: tests/test_output_index.py:99-157
Timestamp: 2025-01-17T12:00:09.368Z
Learning: New test dependencies for Snakemake should be introduced in separate PRs rather than being added as part of feature or refactoring PRs.

Applied to files:

  • tests/tests.py
📚 Learning: 2024-12-21T15:10:31.992Z
Learnt from: johanneskoester
Repo: snakemake/snakemake PR: 2925
File: tests/test_nonstr_params/Snakefile:14-15
Timestamp: 2024-12-21T15:10:31.992Z
Learning: The file "test.jsonl" in tests/test_nonstr_params is automatically created by Snakemake, rather than manually generated in the Snakefile.

Applied to files:

  • tests/tests.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (46)
  • GitHub Check: apidocs
  • GitHub Check: tests (10, ubuntu-latest, py313)
  • GitHub Check: tests (10, windows-2022, py313)
  • GitHub Check: tests (9, macos-latest, py313)
  • GitHub Check: tests (10, ubuntu-latest, py311)
  • GitHub Check: tests (8, macos-latest, py313)
  • GitHub Check: tests (6, ubuntu-latest, py313)
  • GitHub Check: tests (9, ubuntu-latest, py311)
  • GitHub Check: tests (10, ubuntu-latest, py312)
  • GitHub Check: tests (9, windows-2022, py313)
  • GitHub Check: tests (9, ubuntu-latest, py312)
  • GitHub Check: tests (7, windows-2022, py313)
  • GitHub Check: tests (9, ubuntu-latest, py313)
  • GitHub Check: tests (7, ubuntu-latest, py312)
  • GitHub Check: tests (8, windows-2022, py313)
  • GitHub Check: tests (8, ubuntu-latest, py312)
  • GitHub Check: tests (7, ubuntu-latest, py313)
  • GitHub Check: tests (8, ubuntu-latest, py313)
  • GitHub Check: tests (7, macos-latest, py313)
  • GitHub Check: tests (8, ubuntu-latest, py311)
  • GitHub Check: tests (6, macos-latest, py313)
  • GitHub Check: tests (6, ubuntu-latest, py311)
  • GitHub Check: tests (7, ubuntu-latest, py311)
  • GitHub Check: tests (6, ubuntu-latest, py312)
  • GitHub Check: tests (4, windows-2022, py313)
  • GitHub Check: tests (6, windows-2022, py313)
  • GitHub Check: tests (5, ubuntu-latest, py313)
  • GitHub Check: tests (4, macos-latest, py313)
  • GitHub Check: tests (5, ubuntu-latest, py311)
  • GitHub Check: tests (5, ubuntu-latest, py312)
  • GitHub Check: tests (5, windows-2022, py313)
  • GitHub Check: tests (4, ubuntu-latest, py312)
  • GitHub Check: tests (4, ubuntu-latest, py313)
  • GitHub Check: tests (4, ubuntu-latest, py311)
  • GitHub Check: tests (3, windows-2022, py313)
  • GitHub Check: tests (3, ubuntu-latest, py313)
  • GitHub Check: tests (3, ubuntu-latest, py312)
  • GitHub Check: tests (2, ubuntu-latest, py311)
  • GitHub Check: tests (3, ubuntu-latest, py311)
  • GitHub Check: tests (2, ubuntu-latest, py312)
  • GitHub Check: tests (2, ubuntu-latest, py313)
  • GitHub Check: tests (2, windows-2022, py313)
  • GitHub Check: tests (1, ubuntu-latest, py311)
  • GitHub Check: tests (1, windows-2022, py313)
  • GitHub Check: tests (1, ubuntu-latest, py313)
  • GitHub Check: tests (1, ubuntu-latest, py312)
🔇 Additional comments (3)
docs/snakefiles/rules.rst (2)

1112-1119: Documentation of choose_tmp feature addresses prior reviewer feedback well.

The section now properly:

  • Places the example in a profile's default_resources configuration (addressing the feedback to mention profile usage)
  • Explains runtime evaluation clearly without misleading about when the function executes
  • Locates the content in the Dynamic Resources section under Resources, as requested

The example usage is clear and shows the intended pattern for heterogeneous environments.


979-1030: Standard Resources and Default Resources sections provide comprehensive documentation.

The new sections clearly explain:

  • Special handling of tmpdir, runtime, disk, mem, and gpu resources
  • Default values and their rationale
  • Integration points for user customization

This provides good context for the choose_tmp feature introduced later in the Dynamic Resources section.

tests/tests.py (1)

1321-1328: Pass cleanup=False to the first run() call to return the temporary directory

The first run() call uses the default cleanup=True, which returns None. This causes os.path.join(test_path, "profile") to raise a TypeError. Add cleanup=False to capture the temporary directory:

test_path = run(dpath("test_tmpdir"), cleanup=False)

Also verify whether this test should include the @skip_on_windows decorator, as the preceding test_tmpdir function uses it due to tmpdir environment variable behavior on Windows.

@cademirch
Copy link
Copy Markdown
Contributor

This is a nice addition @fgvieira - are you wanting to wait until the hackathon to get this merged? If its okay I'll see if I can get the tests passing and merge this sooner.

@cademirch
Copy link
Copy Markdown
Contributor

I had a thought on the design: instead of exposing a choose_tmp function, what if we natively supported a list for tmpdir? Since this is YAML, users could just write:

default-resources:
  tmpdir:
    - "/scratch/nvme"
    - "/home/$USER/scratch"
    - "/scratch/$SLURM_JOB_ID"

Snakemake would iterate through and pick the first valid path, falling back to system_tmpdir if none work.

Pixi install is failing with "failed to parse pypi name mapping" errors
likely due to rate limiting
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 (1)
.github/workflows/main.yml (1)

49-49: Clarify the rationale for limiting parallelism.

Adding max-parallel: 10 will limit concurrent jobs to 10 out of ~50 total matrix combinations, which will increase overall CI execution time. The PR description focuses on tmpdir functionality and doesn't mention this CI configuration change.

Consider adding an inline comment explaining why this limit is necessary (e.g., runner availability, cost management, rate limiting, or resource contention).

Example of documenting the rationale
     strategy:
       fail-fast: false
+      # Limit parallelism to manage runner availability and costs
       max-parallel: 10
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86a3055 and 1e42fd9.

📒 Files selected for processing (1)
  • .github/workflows/main.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: tests (2, windows-2022, py313)
  • GitHub Check: tests (2, macos-latest, py313)
  • GitHub Check: tests (1, macos-latest, py313)
  • GitHub Check: tests (2, ubuntu-latest, py313)
  • GitHub Check: tests (1, windows-2022, py313)
  • GitHub Check: tests (2, ubuntu-latest, py312)
  • GitHub Check: tests (1, ubuntu-latest, py311)
  • GitHub Check: tests (1, ubuntu-latest, py312)
  • GitHub Check: tests (2, ubuntu-latest, py311)
  • GitHub Check: tests (1, ubuntu-latest, py313)

@cademirch cademirch mentioned this pull request Jan 4, 2026
2 tasks
@fgvieira
Copy link
Copy Markdown
Contributor Author

fgvieira commented Jan 4, 2026

@cademirch I also thought about that, but I wondered if it would be too disruptive. An io_utils function is completely independent from the main code and the users are free to use or not.

But if @johanneskoester thinks it is a better solution, I am all for it!

cademirch added a commit that referenced this pull request Jan 5, 2026
Pixi install github action is failing with "failed to parse pypi name
mapping" errors likely due to rate limiting when 30+ jobs are kicked off
nearly simultaneously

I tested this fix on #3820 since the tests kept failing due to the
`pixi` install action failing. After committing this change, [the
actions ran
successfully](https://github.com/snakemake/snakemake/actions/runs/20684893321).

In [this failing
run's](https://github.com/snakemake/snakemake/actions/runs/20682879051/job/59383597583#step:3:3261)
debug logs we see:
```
pixi install -e py311
[...]
   WARN resolve_conda{group=py313 platform=win-64}: reqwest_retry::middleware: Retry attempt #1. Sleeping 1.225245051s before the next attempt
  Error:   × failed to parse pypi name mapping
    ├─▶ error decoding response body
    ╰─▶ expected value at line 1 column 1
```
This warning is repeated many times until finally pixi stops retrying -
this is what suggested to me that some sort of rate limit was the issue.


One downside is that this does make the CI take a bit longer to run. We
could consider using the `cache` feature of the pixi action. And turning
up the max-parallel, or reducing the number of test-groups


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

* [ ] 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).



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

## Summary by CodeRabbit

* **Chores**
* Updated development toolchain dependencies for improved build and test
infrastructure.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@fgvieira fgvieira moved this to In review in Snakemake Hackathon 2026 Mar 10, 2026
@fgvieira fgvieira added the enhancement New feature or request label Mar 10, 2026
@johanneskoester
Copy link
Copy Markdown
Contributor

For reference: we discussed to generalize this function into something that can work with any list of directories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants