Skip to content

Conversation

@jan-janssen
Copy link
Member

@jan-janssen jan-janssen commented Feb 10, 2025

Summary by CodeRabbit

  • New Features
    • Enhanced handling of dictionary inputs, allowing for mixed lists and dictionaries containing asynchronous elements for improved execution and visualization.
  • Tests
    • Introduced new tests to validate the processing of input dictionaries with asynchronous results and updated existing tests to reflect changes in the dependency graph structure.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 10, 2025

Walkthrough

The changes enhance the handling of dictionary inputs by adding recursive processing for future objects. In the shared library, functions such as _update_futures_in_input, _get_future_objects_from_input, and get_result now inspect dictionaries and evaluate nested future objects. Additionally, a new helper function return_input_dict and accompanying test cases have been added to the test suite to validate that such nested future evaluations are correctly processed.

Changes

Files Change Summary
executorlib/interactive/shared.py Modified _update_futures_in_input, _get_future_objects_from_input, and get_result to add recursive handling for dictionaries containing future objects.
executorlib/standalone/plot.py Updated add_element and convert_arg functions to handle mixed lists and dictionaries of Future instances, enhancing visualization and hashing of complex data structures.
tests/test_dependencies_executor.py Added return_input_dict to return dictionaries unchanged and a new test method test_future_input_dict in TestExecutorWithDependencies to verify correct evaluation of nested future objects.
tests/test_plot_dependency.py Introduced return_input_dict and a new test method test_future_input_dict in TestLocalExecutorWithDependencies. Updated assertions in test_many_to_one_plot to reflect changes in node/edge counts.
tests/test_plot_dependency_flux.py Updated assertions in test_many_to_one_plot for TestFluxAllocationExecutorWithDependencies and TestFluxSubmissionExecutorWithDependencies to reflect new expected counts of nodes and edges.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant get_result
    participant Iteration
    participant FutureEvaluator

    Caller->>+get_result: Call with input (possibly a dictionary)
    alt Input is a dictionary
        get_result->>+Iteration: Iterate over key/value pairs
        Iteration-->>-get_result: Each value processed recursively
        get_result->>+FutureEvaluator: Evaluate future object if found
        FutureEvaluator-->>-get_result: Return computed value
    else Input is not a dictionary
        get_result-->>Caller: Return value as-is
    end
    get_result-->>Caller: Return fully evaluated result
Loading

Poem

Oh, how the code does flow and spin,
With futures tucked in dictionaries within.
I hop through loops with a joyful breeze,
Recursing deep with relative ease.
From future dreams to results so neat,
This rabbit cheers with every beat!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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 Feb 10, 2025 that may be closed by this pull request
@jan-janssen jan-janssen marked this pull request as draft February 10, 2025 20:24
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 (1)
tests/test_dependencies_executor.py (1)

137-143: Enhance test coverage for nested dictionaries.

While the test verifies basic dictionary handling with future objects, consider adding test cases for:

  • Nested dictionaries with multiple levels of future objects
  • Dictionaries with multiple future objects at different levels
  • Empty dictionaries
  • Dictionaries with mixed types (futures, lists, nested dicts)

Example test cases:

def test_future_input_dict_nested(self):
    with SingleNodeExecutor() as exe:
        fs = exe.submit(
            return_input_dict,
            input_dict={
                "a": exe.submit(sum, [2, 2]),
                "b": {"c": exe.submit(sum, [3, 3])},
                "d": [],
                "e": {}
            },
        )
        result = fs.result()
        self.assertEqual(result["a"], 4)
        self.assertEqual(result["b"]["c"], 6)
        self.assertEqual(result["d"], [])
        self.assertEqual(result["e"], {})
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f7de7f7 and 5b0d938.

📒 Files selected for processing (2)
  • executorlib/interactive/shared.py (2 hunks)
  • tests/test_dependencies_executor.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (17)
  • GitHub Check: unittest_openmpi (ubuntu-latest, 3.10)
  • GitHub Check: unittest_openmpi (ubuntu-latest, 3.11)
  • GitHub Check: unittest_openmpi (ubuntu-latest, 3.12)
  • GitHub Check: unittest_mpich (ubuntu-latest, 3.10)
  • GitHub Check: unittest_mpich (ubuntu-latest, 3.11)
  • GitHub Check: unittest_openmpi (ubuntu-latest, 3.13)
  • GitHub Check: unittest_win
  • GitHub Check: unittest_mpich (ubuntu-latest, 3.12)
  • GitHub Check: unittest_openmpi (macos-latest, 3.13)
  • GitHub Check: unittest_mpich (ubuntu-latest, 3.13)
  • GitHub Check: unittest_old
  • GitHub Check: unittest_mpich (macos-latest, 3.13)
  • GitHub Check: unittest_flux_openmpi
  • GitHub Check: unittest_flux_mpich
  • GitHub Check: notebooks
  • GitHub Check: benchmark (ubuntu-latest, 3.13, .ci_support/environment-mpich.yml)
  • GitHub Check: benchmark (ubuntu-latest, 3.13, .ci_support/environment-openmpi.yml)
🔇 Additional comments (3)
tests/test_dependencies_executor.py (1)

41-42: LGTM!

Simple helper function that returns its input dictionary unchanged, used for testing purposes.

executorlib/interactive/shared.py (2)

486-487: LGTM!

The implementation correctly handles dictionaries by recursively processing their values, maintaining consistency with the existing list handling.


515-516: LGTM!

The implementation correctly extends future object detection to dictionary values, maintaining consistency with the existing list handling.

@codecov
Copy link

codecov bot commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.80%. Comparing base (9f232ff) to head (a758c1f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #568      +/-   ##
==========================================
+ Coverage   95.73%   95.80%   +0.06%     
==========================================
  Files          26       26              
  Lines        1149     1168      +19     
==========================================
+ Hits         1100     1119      +19     
  Misses         49       49              

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

@jan-janssen jan-janssen marked this pull request as ready for review February 11, 2025 10:18
@jan-janssen jan-janssen merged commit 2fe5ba1 into main Feb 11, 2025
29 of 30 checks passed
@jan-janssen jan-janssen deleted the input_dict branch February 11, 2025 10:20
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/plot.py (1)

42-63: LGTM! Consider adding type hints for better code maintainability.

The implementation for handling dictionaries containing Future objects is well-structured and follows the same pattern as list handling. The approach of creating placeholder dictionaries and linking Future values is clean and consistent.

Consider adding type hints to improve code maintainability:

-def add_element(arg, link_to, label=""):
+def add_element(arg: Any, link_to: int, label: str = "") -> None:
tests/test_plot_dependency.py (1)

42-43: LGTM! Consider adding a docstring for better documentation.

The helper function is simple and serves its purpose well.

Add a docstring to improve documentation:

 def return_input_dict(input_dict):
+    """
+    Helper function that returns the input dictionary unchanged.
+    Used for testing dictionary handling with Future objects.
+
+    Args:
+        input_dict (dict): The input dictionary to return
+
+    Returns:
+        dict: The unchanged input dictionary
+    """
     return input_dict
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5b0d938 and a758c1f.

📒 Files selected for processing (3)
  • executorlib/standalone/plot.py (2 hunks)
  • tests/test_plot_dependency.py (4 hunks)
  • tests/test_plot_dependency_flux.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: benchmark (ubuntu-latest, 3.13, .ci_support/environment-mpich.yml)
🔇 Additional comments (4)
executorlib/standalone/plot.py (1)

114-118: LGTM! Clean implementation of dictionary support in hash generation.

The recursive conversion of dictionary values is well-implemented and maintains consistency with the existing list handling pattern.

tests/test_plot_dependency_flux.py (1)

109-110: LGTM! Assertion updates reflect the new graph structure.

The updated node and edge counts are consistent across test classes and accurately reflect the changes in graph structure due to dictionary support.

Also applies to: 178-179

tests/test_plot_dependency.py (2)

134-149: LGTM! Comprehensive test coverage for dictionary handling.

The test case effectively validates the handling of Future objects within dictionaries, checking both the execution flow and the generated dependency graph structure.


131-132: LGTM! Consistent assertion updates across test classes.

The updated node and edge counts are consistent across all test classes, maintaining test integrity for the new dictionary support feature.

Also applies to: 221-222, 290-291

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] Dependencies are not recognised in dictionaries

2 participants