Skip to content

Conversation

@jan-janssen
Copy link
Member

@jan-janssen jan-janssen commented Aug 5, 2025

Summary by CodeRabbit

  • New Features

    • Added new functions for retrieving and managing cache data, and for terminating tasks in cache.
  • Refactor

    • Consolidated cache and HDF5 file handling into a single module for improved maintainability.
    • Updated import paths throughout the codebase to use the new consolidated module.
  • Chores

    • Removed obsolete cache management code and updated internal references for consistency.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 5, 2025

Walkthrough

This change migrates cache file handling from executorlib.standalone.cache to executorlib.standalone.hdf, removes the former module, and updates all imports accordingly. It introduces new wrapper functions in executorlib/__init__.py for cache data retrieval and task termination, and updates the relevant test and scheduler files to use the new HDF-based implementations.

Changes

Cohort / File(s) Change Summary
Core API and Exports
executorlib/__init__.py
Adds local get_cache_data and terminate_tasks_in_cache functions, updates imports, removes conditional export logic, and updates __all__.
Cache Handling Module Removal
executorlib/standalone/cache.py
Deletes the module and its functions for cache file discovery and reading.
HDF Cache Handling Implementation
executorlib/standalone/hdf.py
Adds get_cache_data, get_cache_files, and _get_content_of_file functions; inlines group_dict; implements HDF5-based cache file handling.
Task Scheduler File Backend
executorlib/task_scheduler/file/backend.py,
.../queue_spawner.py,
.../shared.py,
.../subprocess_spawner.py
Updates imports to use cache and dump functions from executorlib.standalone.hdf instead of the removed cache module or file.hdf module.
Task Scheduler Interactive Shared
executorlib/task_scheduler/interactive/shared.py
Updates _execute_task_with_cache to use get_cache_files from the new HDF module and updates related imports.
Tests
tests/test_cache_backend_execute.py,
tests/test_fluxclusterexecutor.py,
tests/test_slurmclusterexecutor.py,
tests/test_standalone_hdf.py
Updates imports to use cache and dump functions from executorlib.standalone.hdf instead of the removed or relocated modules.

Sequence Diagram(s)

sequenceDiagram participant User participant executorlib.__init__ participant executorlib.standalone.hdf User->>executorlib.__init__: get_cache_data(cache_directory) executorlib.__init__->>executorlib.standalone.hdf: get_cache_data(cache_directory) executorlib.standalone.hdf->>executorlib.standalone.hdf: get_cache_files(cache_directory) executorlib.standalone.hdf->>executorlib.standalone.hdf: _get_content_of_file(file_name) for each file executorlib.standalone.hdf-->>executorlib.__init__: list of cache data dicts executorlib.__init__-->>User: list of cache data dicts 
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • liamhuber

Poem

In the warren where code does reside,
Cache files now take an HDF ride.
Old modules are gone, new wrappers appear,
With imports refreshed, the path is clear.
Tasks and tests all hop in line—
This rabbit thinks the code looks fine! 🐇

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 d867664 and 8b4589d.

📒 Files selected for processing (1)
  • tests/test_fluxclusterexecutor.py (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tests/test_fluxclusterexecutor.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). (14)
  • GitHub Check: unittest_old
  • GitHub Check: benchmark (ubuntu-latest, 3.13, .ci_support/environment-openmpi.yml)
  • GitHub Check: unittest_flux_mpich
  • GitHub Check: benchmark (ubuntu-latest, 3.13, .ci_support/environment-mpich.yml)
  • GitHub Check: notebooks
  • GitHub Check: unittest_openmpi (ubuntu-latest, 3.13)
  • GitHub Check: unittest_mpich (macos-latest, 3.13)
  • GitHub Check: unittest_openmpi (macos-latest, 3.13)
  • GitHub Check: unittest_openmpi (ubuntu-latest, 3.12)
  • GitHub Check: unittest_win
  • GitHub Check: unittest_openmpi (ubuntu-latest, 3.11)
  • GitHub Check: unittest_flux_openmpi
  • GitHub Check: unittest_slurm_mpich
  • GitHub Check: notebooks_integration
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hdf

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

Support

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

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 generate unit tests to generate unit tests 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.
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: 0

🧹 Nitpick comments (2)
executorlib/standalone/hdf.py (2)

124-137: Consider error handling and Python version compatibility.

The implementation is clean and well-structured. However, consider these points:

  1. The dictionary union operator (|) requires Python 3.9+. Ensure this aligns with your minimum supported version.
  2. Consider adding error handling for file reading failures to prevent the entire operation from failing due to a single corrupted file.
def get_cache_data(cache_directory: str) -> list[dict]: """ Collect all HDF5 files in the cache directory Args: cache_directory (str): The directory to store cache files. Returns: list[dict]: List of dictionaries each representing on of the HDF5 files in the cache directory. """ - return [ - _get_content_of_file(file_name=file_name) | {"filename": file_name} - for file_name in get_cache_files(cache_directory=cache_directory) - ] + result = [] + for file_name in get_cache_files(cache_directory=cache_directory): + try: + content = _get_content_of_file(file_name=file_name) + content["filename"] = file_name + result.append(content) + except Exception as e: + # Log error and continue with other files + print(f"Warning: Failed to read {file_name}: {e}") + return result

157-172: Good implementation, consider adding error handling.

The function correctly extracts HDF5 content using the standardized group_dict mapping and only includes existing datasets. However, consider adding error handling for file I/O and deserialization failures to improve robustness.

def _get_content_of_file(file_name: str) -> dict: """ Get content of an HDF5 file Args: file_name (str): file name Returns: dict: Content of HDF5 file """ - with h5py.File(file_name, "r") as hdf: - return { - key: cloudpickle.loads(np.void(hdf["/" + key])) - for key in group_dict.values() - if key in hdf - } + try: + with h5py.File(file_name, "r") as hdf: + result = {} + for key in group_dict.values(): + if key in hdf: + try: + result[key] = cloudpickle.loads(np.void(hdf["/" + key])) + except Exception as e: + print(f"Warning: Failed to deserialize {key} from {file_name}: {e}") + return result + except Exception as e: + print(f"Warning: Failed to open {file_name}: {e}") + return {}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7afa0d9 and d867664.

📒 Files selected for processing (12)
  • executorlib/__init__.py (3 hunks)
  • executorlib/standalone/cache.py (0 hunks)
  • executorlib/standalone/hdf.py (2 hunks)
  • executorlib/task_scheduler/file/backend.py (1 hunks)
  • executorlib/task_scheduler/file/queue_spawner.py (1 hunks)
  • executorlib/task_scheduler/file/shared.py (1 hunks)
  • executorlib/task_scheduler/file/subprocess_spawner.py (1 hunks)
  • executorlib/task_scheduler/interactive/shared.py (1 hunks)
  • tests/test_cache_backend_execute.py (1 hunks)
  • tests/test_fluxclusterexecutor.py (1 hunks)
  • tests/test_slurmclusterexecutor.py (1 hunks)
  • tests/test_standalone_hdf.py (1 hunks)
💤 Files with no reviewable changes (1)
  • executorlib/standalone/cache.py
🧰 Additional context used
🧬 Code Graph Analysis (10)
tests/test_slurmclusterexecutor.py (1)
executorlib/standalone/hdf.py (1)
  • dump (20-37)
executorlib/task_scheduler/file/queue_spawner.py (1)
executorlib/standalone/hdf.py (2)
  • dump (20-37)
  • get_queue_id (107-121)
executorlib/task_scheduler/file/backend.py (1)
executorlib/standalone/hdf.py (2)
  • dump (20-37)
  • load (40-68)
executorlib/task_scheduler/file/subprocess_spawner.py (1)
executorlib/standalone/hdf.py (1)
  • dump (20-37)
executorlib/task_scheduler/interactive/shared.py (1)
executorlib/standalone/hdf.py (3)
  • dump (20-37)
  • get_cache_files (140-154)
  • get_output (71-87)
executorlib/__init__.py (2)
executorlib/standalone/hdf.py (1)
  • get_cache_data (124-137)
executorlib/task_scheduler/file/queue_spawner.py (1)
  • terminate_tasks_in_cache (93-117)
tests/test_cache_backend_execute.py (1)
executorlib/standalone/hdf.py (2)
  • dump (20-37)
  • get_runtime (90-104)
executorlib/task_scheduler/file/shared.py (1)
executorlib/standalone/hdf.py (2)
  • get_cache_files (140-154)
  • get_output (71-87)
executorlib/standalone/hdf.py (1)
executorlib/__init__.py (1)
  • get_cache_data (30-42)
tests/test_fluxclusterexecutor.py (1)
executorlib/standalone/hdf.py (1)
  • dump (20-37)
🔇 Additional comments (17)
executorlib/task_scheduler/file/backend.py (1)

6-6: LGTM! Clean import path update.

The import change from executorlib.task_scheduler.file.hdf to executorlib.standalone.hdf aligns with the HDF5 interface refactoring objectives. The function signatures and usage remain consistent throughout the file.

executorlib/task_scheduler/file/queue_spawner.py (1)

6-6: LGTM! Import path update is consistent.

The import change correctly updates the path for dump and get_queue_id functions to align with the HDF5 interface consolidation. Function usage throughout the file remains unchanged and consistent.

executorlib/task_scheduler/file/subprocess_spawner.py (1)

6-6: LGTM! Simple import path update.

The import change for the dump function from executorlib.task_scheduler.file.hdf to executorlib.standalone.hdf is correct and consistent with the refactoring objectives.

tests/test_standalone_hdf.py (1)

7-13: LGTM! Test imports updated correctly.

The import paths have been correctly updated to use the consolidated executorlib.standalone.hdf module. This ensures the test suite validates the refactored HDF5 functionality in its new location.

tests/test_slurmclusterexecutor.py (1)

17-17: LGTM! Test import updated for consistency.

The import path update for the dump function ensures this test file remains compatible with the HDF5 interface refactoring.

tests/test_cache_backend_execute.py (1)

10-10: LGTM: Import path updated correctly.

The import change from executorlib.task_scheduler.file.hdf to executorlib.standalone.hdf aligns with the HDF5 interface refactoring. The functions dump and get_runtime are available in the new module with compatible signatures.

tests/test_fluxclusterexecutor.py (1)

13-13: LGTM: Import path updated correctly.

The import change from executorlib.task_scheduler.file.hdf to executorlib.standalone.hdf is consistent with the HDF5 interface refactoring. The dump function is available in the new module.

executorlib/task_scheduler/file/shared.py (1)

8-8: LGTM: Import consolidation aligns with refactoring objectives.

The consolidation of get_cache_files and get_output imports into executorlib.standalone.hdf successfully centralizes HDF5-related functionality. Both functions are available with compatible signatures in the new module.

executorlib/task_scheduler/interactive/shared.py (1)

132-132: LGTM: Import update maintains consistency.

The import change consolidates HDF5 functions into executorlib.standalone.hdf, maintaining consistency with the overall refactoring. All three functions (dump, get_cache_files, get_output) are available with compatible signatures.

executorlib/__init__.py (6)

15-15: LGTM: Added necessary import for type hints.

The Optional import is correctly added to support the type hints in the new wrapper functions.


17-17: LGTM: Version import updated to absolute path.

The import change from relative to absolute import (executorlib._version) improves clarity and consistency.


30-42: LGTM: Clean wrapper function implementation.

The get_cache_data wrapper function provides a clean public API that delegates to the underlying implementation in executorlib.standalone.hdf. The function signature and documentation are consistent with the wrapped function.


45-64: LGTM: Well-designed wrapper function.

The terminate_tasks_in_cache wrapper function properly delegates to the underlying implementation while providing a clean public interface. The function signature matches the wrapped function and includes appropriate type hints.


69-69: LGTM: Updated all list correctly.

The addition of terminate_tasks_in_cache to the __all__ list correctly exposes the new public function.


78-78: LGTM: Version reference updated consistently.

The version reference is updated to match the absolute import path used above.

executorlib/standalone/hdf.py (2)

8-17: LGTM! Good consolidation of mapping logic.

The inline group_dict centralizes the key-to-HDF5-dataset-name mapping, improving maintainability and consistency across the module.


140-154: LGTM! Efficient file discovery implementation.

The recursive directory traversal using os.walk and filtering by the "_o.h5" suffix is appropriate for finding HDF5 output files in the cache directory.

@codecov
Copy link

codecov bot commented Aug 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.65%. Comparing base (7afa0d9) to head (8b4589d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@ Coverage Diff @@ ## main #775 +/- ## ========================================== + Coverage 97.53% 97.65% +0.12%  ========================================== Files 33 32 -1 Lines 1460 1451 -9 ========================================== - Hits 1424 1417 -7  + Misses 36 34 -2 

☔ 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.
@jan-janssen jan-janssen merged commit 52e44f3 into main Aug 5, 2025
54 of 55 checks passed
@jan-janssen jan-janssen deleted the hdf branch August 5, 2025 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants