Skip to content

Conversation

@jan-janssen
Copy link
Member

@jan-janssen jan-janssen commented Jul 11, 2025

Summary by CodeRabbit

  • Refactor
    • Removed automatic creation of cache directories in task execution and scheduler components.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 11, 2025

Walkthrough

This change removes the automatic creation of the cache directory from two locations: the _execute_task_with_cache function and the FileTaskScheduler constructor. The rest of the logic for task execution and cache management remains the same, but the code no longer ensures the cache directory exists.

Changes

File(s) Change Summary
executorlib/task_scheduler/interactive/shared.py Removed automatic cache directory creation in task execution
executorlib/task_scheduler/file/task_scheduler.py Removed cache directory creation from scheduler constructor

Possibly related PRs

Poem

A cache once made with gentle care,
Now left to hands that dare prepare.
No mkdir here, no silent sweep,
Just tidy code and logic deep.
The rabbit hops where caches dwell—
Directories now yours to tell! 🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 452f3f5 and 6d8e451.

📒 Files selected for processing (2)
  • executorlib/task_scheduler/file/task_scheduler.py (0 hunks)
  • executorlib/task_scheduler/interactive/shared.py (0 hunks)
💤 Files with no reviewable changes (2)
  • executorlib/task_scheduler/interactive/shared.py
  • executorlib/task_scheduler/file/task_scheduler.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). (18)
  • GitHub Check: unittest_openmpi (ubuntu-latest, 3.13)
  • GitHub Check: unittest_openmpi (macos-latest, 3.13)
  • GitHub Check: unittest_openmpi (ubuntu-latest, 3.11)
  • GitHub Check: unittest_openmpi (ubuntu-latest, 3.12)
  • GitHub Check: unittest_flux_mpich
  • GitHub Check: benchmark (ubuntu-latest, 3.13, .ci_support/environment-mpich.yml)
  • GitHub Check: notebooks_integration
  • GitHub Check: benchmark (ubuntu-latest, 3.13, .ci_support/environment-openmpi.yml)
  • GitHub Check: unittest_mpich (ubuntu-latest, 3.11)
  • GitHub Check: notebooks
  • GitHub Check: unittest_mpich (macos-latest, 3.13)
  • GitHub Check: unittest_mpich (ubuntu-latest, 3.13)
  • GitHub Check: unittest_mpich (ubuntu-latest, 3.12)
  • GitHub Check: unittest_win
  • GitHub Check: unittest_old
  • GitHub Check: pip_check
  • GitHub Check: unittest_flux_openmpi
  • GitHub Check: minimal
✨ 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.

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.

@jan-janssen jan-janssen linked an issue Jul 11, 2025 that may be closed by this pull request
@jan-janssen jan-janssen requested a review from liamhuber July 11, 2025 06:16
@codecov
Copy link

codecov bot commented Jul 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.89%. Comparing base (e019a0b) to head (6d8e451).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #706      +/-   ##
==========================================
- Coverage   96.89%   96.89%   -0.01%     
==========================================
  Files          29       29              
  Lines        1321     1319       -2     
==========================================
- Hits         1280     1278       -2     
  Misses         41       41              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

🔭 Outside diff range comments (1)
tests/test_cache_fileexecutor_serial.py (1)

104-134: Tests must be updated to match the new execute_tasks_h5 signature

The execute_tasks_h5 function no longer accepts a top-level cache_directory parameter (its signature is now

def execute_tasks_h5(
    future_queue: queue.Queue,
    execute_function: Callable,
    resource_dict: dict,
    terminate_function: Optional[Callable] = None,
    pysqa_config_directory: Optional[str] = None,
    backend: Optional[str] = None,
    disable_dependencies: bool = False,
) -> None:

). All occurrences in your serial tests that pass "cache_directory": cache_dir will fail at runtime. Please remove or relocate this argument into the appropriate place (e.g. inside resource_dict or via the new high-level executor API).

Locations to fix in tests/test_cache_fileexecutor_serial.py:

  • Lines 118–122
  • Lines 159–163
  • Lines 200–204

Each block’s kwargs should drop "cache_directory": cache_dir. For example:

 kwargs={
-    "future_queue": q,
-    "cache_directory": cache_dir,
+    "future_queue": q,
     "execute_function": execute_in_subprocess,
     "resource_dict": {"cores": 1, "cwd": None},
     "terminate_function": terminate_subprocess,
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 059f888 and 2b049e5.

📒 Files selected for processing (3)
  • executorlib/task_scheduler/file/task_scheduler.py (3 hunks)
  • tests/test_cache_fileexecutor_mpi.py (1 hunks)
  • tests/test_cache_fileexecutor_serial.py (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
tests/test_cache_fileexecutor_mpi.py (1)
executorlib/task_scheduler/file/subprocess_spawner.py (1)
  • execute_in_subprocess (8-52)
tests/test_cache_fileexecutor_serial.py (3)
executorlib/task_scheduler/file/task_scheduler.py (1)
  • FileTaskScheduler (27-76)
executorlib/task_scheduler/file/subprocess_spawner.py (1)
  • execute_in_subprocess (8-52)
tests/test_cache_backend_execute.py (1)
  • my_funct (18-19)
⏰ 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). (17)
  • GitHub Check: unittest_mpich (ubuntu-latest, 3.13)
  • GitHub Check: unittest_mpich (ubuntu-latest, 3.11)
  • GitHub Check: unittest_mpich (macos-latest, 3.13)
  • GitHub Check: benchmark (ubuntu-latest, 3.13, .ci_support/environment-mpich.yml)
  • GitHub Check: unittest_mpich (ubuntu-latest, 3.12)
  • GitHub Check: unittest_flux_openmpi
  • GitHub Check: benchmark (ubuntu-latest, 3.13, .ci_support/environment-openmpi.yml)
  • GitHub Check: unittest_flux_mpich
  • GitHub Check: unittest_openmpi (ubuntu-latest, 3.11)
  • GitHub Check: unittest_openmpi (ubuntu-latest, 3.12)
  • GitHub Check: unittest_openmpi (macos-latest, 3.13)
  • GitHub Check: unittest_old
  • GitHub Check: unittest_openmpi (ubuntu-latest, 3.13)
  • GitHub Check: notebooks_integration
  • GitHub Check: notebooks
  • GitHub Check: unittest_win
  • GitHub Check: minimal
🔇 Additional comments (4)
tests/test_cache_fileexecutor_mpi.py (1)

35-36: LGTM! Correctly adapts test to new cache directory interface.

The change properly moves the cache directory specification from a separate parameter to within the resource_dict, which aligns with the refactoring described in the PR. The explicit addition of execute_function=execute_in_subprocess also makes the test more explicit about its dependencies.

tests/test_cache_fileexecutor_serial.py (1)

39-42: LGTM! Consistently adapts high-level tests to new cache directory interface.

The changes correctly move the cache directory specification from separate parameters to within the resource_dict, making the tests compatible with the refactored FileTaskScheduler interface.

Also applies to: 49-52, 59-62, 78-81, 88-90, 97-99

executorlib/task_scheduler/file/task_scheduler.py (2)

63-63: LGTM! Correctly removes cache_directory from process kwargs.

The removal of "cache_directory": cache_directory from self._process_kwargs is consistent with the refactoring to move cache directory handling into resource_dict.


96-99: LGTM! Proper cache directory handling in resource_dict.

The refactoring correctly moves cache directory specification into resource_dict and maintains proper path normalization with os.path.abspath. This approach centralizes cache directory management and aligns with the PR objective.



def create_file_executor(
resource_dict: dict,
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

Add validation for required resource_dict parameter.

The function signature now requires resource_dict (no longer Optional), but there's no validation to ensure it's not None. This could cause runtime errors if someone passes None.

 def create_file_executor(
     resource_dict: dict,
     # ... other parameters
 ):
+    if resource_dict is None:
+        raise ValueError("resource_dict is required and cannot be None")
     if cache_directory is None:
         resource_dict["cache_directory"] = os.path.abspath("executorlib_cache")

Also applies to: 96-99

🤖 Prompt for AI Agents
In executorlib/task_scheduler/file/task_scheduler.py around lines 80 and 96 to
99, the resource_dict parameter is required but lacks validation to ensure it is
not None. Add explicit checks at the start of the functions to raise a
ValueError or similar if resource_dict is None, preventing runtime errors and
enforcing the parameter's required status.

Copy link
Member

@liamhuber liamhuber left a comment

Choose a reason for hiding this comment

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

Nice. Resolves the example in #704

@jan-janssen jan-janssen merged commit 7e64c3b into main Jul 11, 2025
52 of 53 checks passed
@jan-janssen jan-janssen deleted the remove_makedirs branch July 11, 2025 13:43
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.

[Bug] Directories created awkwardly early

3 participants