Skip to content

Conversation

@jan-janssen
Copy link
Member

@jan-janssen jan-janssen commented Apr 26, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a unified executor interface, providing a consistent set of properties and methods for all executor types.
  • Refactor

    • Updated all executor classes to use a standard inheritance-based initialization pattern, improving code consistency and maintainability.
    • Executor classes now expose a consistent interface for properties and methods, ensuring a more predictable user experience.
    • Internal task scheduler attributes were reorganized, with related properties now accessed through nested scheduler objects, improving encapsulation.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 26, 2025

Warning

Rate limit exceeded

@jan-janssen has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 14 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 9e0b462 and 718c46b.

📒 Files selected for processing (14)
  • executorlib/base/executor.py (3 hunks)
  • executorlib/cache/task_scheduler.py (3 hunks)
  • executorlib/interactive/blockallocation.py (4 hunks)
  • executorlib/interactive/dependency.py (5 hunks)
  • executorlib/interactive/onetoone.py (2 hunks)
  • executorlib/interfaces/flux.py (7 hunks)
  • executorlib/interfaces/single.py (7 hunks)
  • executorlib/interfaces/slurm.py (7 hunks)
  • notebooks/4-developer.ipynb (1 hunks)
  • tests/test_cache_fileexecutor_mpi.py (2 hunks)
  • tests/test_cache_fileexecutor_serial.py (3 hunks)
  • tests/test_fluxpythonspawner.py (6 hunks)
  • tests/test_interactive_dependencies.py (5 hunks)
  • tests/test_mpiexecspawner.py (23 hunks)
## Walkthrough

A new `ExecutorInterface` class was introduced as a standardized wrapper around executor implementations, delegating all operations to an internal executor instance. Classes for different executor types—such as Flux, Slurm, and Single Node—were refactored to inherit from `ExecutorInterface`. Their initialization logic was unified: instead of returning executor instances from `__new__`, each class now uses `super().__init__()` with the appropriate executor, optionally wrapped in a dependency manager. This change consolidates and standardizes executor interface design, with no modifications to the underlying executor logic.

## Changes

| File(s)                                             | Change Summary                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
|-----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `executorlib/base/executor.py`                      | Added `ExecutorInterface` class, inheriting from `FutureExecutor`, acting as a proxy to an internal `ExecutorBase`. Implements property and method delegation, including resource cleanup in `__del__`. Updated `ExecutorBase.submit` method to enforce positional-only `fn` argument.                                                                                                                                                                                                                                                                                                                                                                          |
| `executorlib/interfaces/flux.py`                    | Refactored `FluxJobExecutor` and `FluxClusterExecutor` to inherit from `ExecutorInterface`. Removed `__new__` methods; initialization now uses `super().__init__()` with the appropriate executor instance, handling dependency wrapping as needed.                                                                                                                                                                                                                                                                                                                                                                   |
| `executorlib/interfaces/single.py`                  | Refactored `SingleNodeExecutor` to inherit from `ExecutorInterface`. Removed `__new__` method; initialization logic moved to `__init__`, calling `super().__init__()` with the correct executor instance, handling dependency wrapping and validation as required.                                                                                                                                                                                                                                                                                                                                                   |
| `executorlib/interfaces/slurm.py`                   | Refactored `SlurmClusterExecutor` and `SlurmJobExecutor` to inherit from `ExecutorInterface`. Removed `__new__` methods and empty `__init__` placeholders; initialization now uses `super().__init__()` with constructed executor, handling dependency wrapping and validation as appropriate.                                                                                                                                                                                                                                                                                                                      |
| `tests/test_singlenodeexecutor_plot_dependency.py` | Updated test attribute access to retrieve `_future_hash_dict` and `_task_hash_dict` via the internal `_task_scheduler` attribute instead of directly on the executor instance.                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `tests/test_singlenodeexecutor_resize.py`          | Updated test assertions to access the `_process` attribute through the internal `_task_scheduler` attribute rather than directly on the executor instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `tests/test_fluxjobexecutor_plot.py`                | Updated test attribute access to retrieve `_future_hash_dict` and `_task_hash_dict` via the internal `_task_scheduler` attribute instead of directly on the executor instance.                                                                                                                                                                                                                                                                                                                                                                                                                                  |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant ExecutorInterface
    participant InternalExecutor

    User->>ExecutorInterface: create instance (with parameters)
    ExecutorInterface->>InternalExecutor: initialize wrapped executor
    User->>ExecutorInterface: submit(fn, *args, **kwargs)
    ExecutorInterface->>InternalExecutor: submit(fn, *args, **kwargs)
    InternalExecutor-->>ExecutorInterface: Future
    ExecutorInterface-->>User: Future
    User->>ExecutorInterface: shutdown()
    ExecutorInterface->>InternalExecutor: shutdown()

Poem

In the warren of code, a new path appears,
Executors now don smart rabbit ears.
No more __new__, just hop in and run,
With interfaces wrapping, the work’s neatly done.
From Slurm to Flux, and Single Node too,
The garden’s grown tidier, thanks to this crew.
🐇✨ Hooray for clean starts and carrots anew!


<!-- walkthrough_end -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEejqANiS4BJDDQoAzNA2lcAqohKQAQmi+Qdg7OrpBUuLCUkBGYkCEEFPLc1A4YBgBy2MwClFwAbADMACwGnrmQQphglRiIXmkG+sbgUGT0+I44BMRkyjT0TKzsXLz8wqLiUjLyTEpUqupaOk0mUHCoqLFoeISk5OF0CkP2XFQA7pCIWcxoiZByCnMqapraumCGzaYGJAAeojsKBZ4AIAPQCfwkUF/AEJDTcWQcAwAIlRBgAxOjIABBGw9fbUQ5XVi3eQdRiwTCkRBmSKQAAGVwEzHU9MgbAiin4nXpAFF/gxAX4vGyzv5INhuLRCfQCJAyI58BRQjFcNE6Y54BREGrbkQsuw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A== -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

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.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=pyiron/executorlib&utm_content=634):

- 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](https://docs.coderabbit.ai/finishing-touches/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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

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

🧹 Nitpick comments (5)
executorlib/base/executor.py (1)

191-193: ExecutorInterface.__init__ should call super().__init__ for forward-compatibility

concurrent.futures.Executor currently provides a no-op __init__, so skipping it works today.
However, if upstream ever adds bookkeeping logic (e.g. for thread tracking or weak-ref registration), this subclass will silently miss it.

-    def __init__(self, executor: ExecutorBase):
-        self._executor = executor
+    def __init__(self, executor: ExecutorBase):
+        super().__init__()
+        self._executor = executor
executorlib/interfaces/flux.py (1)

168-189: Minor: duplicate resource-dict merge mutates caller’s input

resource_dict.update(...) mutates the user-supplied dictionary. Consider
working on a shallow copy to prevent surprising side-effects:

-        if resource_dict is None:
-            resource_dict = {}
-        resource_dict.update(
+        if resource_dict is None:
+            resource_dict = {}
+        resource_dict = resource_dict.copy()
+        resource_dict.update(
executorlib/interfaces/slurm.py (3)

152-158: Avoid mutating caller-provided resource_dict in-place

resource_dict.update(…) modifies the dictionary object that the caller passed in.
If the same dict is reused elsewhere, the defaults inserted here may leak into unrelated code paths.

-        resource_dict.update({…})
+        resource_dict = {**default_resource_dict, **resource_dict}

This creates an internal copy and leaves the caller’s data untouched.


330-346: Duplicate dependency-wrapper logic – consider a helper

Both SlurmClusterExecutor and SlurmJobExecutor replicate almost identical DependencyExecutor( create_slurm_executor(…)) scaffolding. Extracting this into a private factory function would reduce duplication and keep the interface classes concise.

Example sketch:

def _wrap_for_dependencies(exec_ctor, *, enable_deps, **kwargs):
    inner = exec_ctor(**kwargs)
    return DependencyExecutor(inner, **{k: kwargs[k] for k in ("max_cores", "refresh_rate",
                                                               "plot_dependency_graph",
                                                               "plot_dependency_graph_filename")}) \
           if enable_deps else inner

Using such a helper will simplify future maintenance when the dependency-handling API changes.


347-349: Minor: consolidate validation helpers

check_plot_dependency_graph and check_refresh_rate are only needed in the branch where dependencies are disabled. Placing them inside the else branch is correct but makes the flow less obvious.

A small guard clause at the top of the method could make intent clearer:

if disable_dependencies:
    check_plot_dependency_graph(plot_dependency_graph)
    check_refresh_rate(refresh_rate)

No functional change, but improves readability.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2d6666a and ad7ed14.

📒 Files selected for processing (4)
  • executorlib/base/executor.py (1 hunks)
  • executorlib/interfaces/flux.py (5 hunks)
  • executorlib/interfaces/single.py (4 hunks)
  • executorlib/interfaces/slurm.py (5 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
executorlib/interfaces/flux.py (4)
executorlib/base/executor.py (5)
  • ExecutorInterface (183-287)
  • max_workers (36-37)
  • max_workers (40-41)
  • max_workers (195-196)
  • max_workers (199-200)
executorlib/interactive/dependency.py (3)
  • DependencyExecutor (21-183)
  • max_workers (86-94)
  • max_workers (97-110)
executorlib/standalone/inputcheck.py (2)
  • check_plot_dependency_graph (93-100)
  • check_refresh_rate (83-90)
executorlib/cache/executor.py (1)
  • create_file_executor (84-122)
executorlib/base/executor.py (5)
executorlib/interactive/blockallocation.py (4)
  • max_workers (74-75)
  • max_workers (78-100)
  • submit (102-138)
  • shutdown (140-165)
executorlib/interactive/dependency.py (4)
  • max_workers (86-94)
  • max_workers (97-110)
  • info (69-83)
  • submit (112-154)
tests/test_singlenodeexecutor_noblock.py (1)
  • resource_dict (11-12)
executorlib/standalone/interactive/communication.py (1)
  • shutdown (90-110)
executorlib/standalone/interactive/spawner.py (2)
  • shutdown (41-48)
  • shutdown (114-126)
🪛 Ruff (0.8.2)
executorlib/base/executor.py

254-254: Star-arg unpacking after a keyword argument is strongly discouraged

(B026)

🔇 Additional comments (2)
executorlib/interfaces/single.py (1)

148-165: Good use of ExecutorInterface — branch handles dependencies cleanly

The refactor cleanly wraps the single-node executor in DependencyExecutor
while maintaining the original constructor signature. Nice work!

executorlib/interfaces/slurm.py (1)

152-169:

❌ Incorrect review comment

Validate create_file_executor signature – extra kwargs may break at runtime

create_file_executor(…) is called with several Flux-specific kwargs (flux_executor, flux_executor_pmi_mode, flux_executor_nesting, flux_log_files).
These parameters look unrelated to a SLURM file-submission backend and are not listed in the public signature in earlier releases. If the function does not accept them, a TypeError will be raised the first time the constructor is executed.

-                    flux_executor=None,
-                    flux_executor_pmi_mode=None,
-                    flux_executor_nesting=False,
-                    flux_log_files=False,

Please double-check the current signature of create_file_executor and remove or gate these arguments to avoid accidental breakage.


🏁 Script executed:

#!/bin/bash
# Locate the definition of create_file_executor and display context
rg "def create_file_executor" -n -C5

Length of output: 697


🏁 Script executed:

#!/bin/bash
# Display the full signature of create_file_executor and its parameters
sed -n '84,200p' executorlib/cache/executor.py

Length of output: 1704


No action needed: create_file_executor already accepts Flux-specific kwargs

The signature of create_file_executor (executorlib/cache/executor.py, lines 84–99) defines and uses all of these parameters:

  • flux_executor
  • flux_executor_pmi_mode
  • flux_executor_nesting
  • flux_log_files

They’re validated internally before returning the FileExecutor. Passing them for the SLURM backend won’t raise a TypeError, so no removal or gating is required.

Likely an incorrect or invalid review comment.

Comment on lines 283 to 287
def __del__(self):
"""
Clean-up the resources associated with the Executor.
"""
del self._executor
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

__del__ should call shutdown() to avoid dangling threads

Deleting the wrapped executor reference does not guarantee that its destructor
executes promptly; therefore worker threads or processes may survive the
interface object. Be explicit:

-    def __del__(self):
-        """
-        Clean-up the resources associated with the Executor.
-        """
-        del self._executor
+    def __del__(self):
+        """
+        Ensure the wrapped executor is shut down before disposal.
+        """
+        with contextlib.suppress(Exception):
+            self._executor.shutdown(wait=False, cancel_futures=True)
+        del self._executor
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def __del__(self):
"""
Clean-up the resources associated with the Executor.
"""
del self._executor
def __del__(self):
"""
Ensure the wrapped executor is shut down before disposal.
"""
with contextlib.suppress(Exception):
self._executor.shutdown(wait=False, cancel_futures=True)
del self._executor

Comment on lines 170 to 187
else:
super().__init__(
executor=DependencyExecutor(
executor=create_slurm_executor(
max_workers=max_workers,
cache_directory=cache_directory,
max_cores=max_cores,
resource_dict=resource_dict,
hostname_localhost=hostname_localhost,
block_allocation=block_allocation,
init_function=init_function,
),
max_cores=max_cores,
refresh_rate=refresh_rate,
plot_dependency_graph=plot_dependency_graph,
plot_dependency_graph_filename=plot_dependency_graph_filename,
)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

disable_dependencies is silently ignored when plot_dependency_graph=True

In the dependency-graph branch the inner create_slurm_executor is always wrapped in a DependencyExecutor, regardless of the user-supplied disable_dependencies flag.
A caller that explicitly sets disable_dependencies=True while requesting a graph will be surprised that dependencies are still resolved.

Consider honouring the flag, e.g.

-                executor=DependencyExecutor(
+                executor=DependencyExecutor(
                     executor=create_slurm_executor(
@@
-                )
+                ) if not disable_dependencies else create_slurm_executor(
+
+                    ),
+                ) if not disable_dependencies else create_slurm_executor(
+
+                    )

or explicitly raise a ValueError when both options are used together.


🏁 Script executed:

#!/bin/bash
# Search for usages of the disable_dependencies flag across the repo
rg --color=never -n "disable_dependencies" -n .

Length of output: 4974


🏁 Script executed:

#!/bin/bash
set -e
echo "Plot dependency graph occurrences in slurm.py:"
rg --color=never -n "plot_dependency_graph" executorlib/interfaces/slurm.py || true

echo ""
echo "Context around SLURM executor __init__ (lines 120-200):"
sed -n '120,200p' executorlib/interfaces/slurm.py

Length of output: 6432


🏁 Script executed:

#!/bin/bash
# Locate the definition of create_slurm_executor in the slurm interface module
rg --color=never -n "create_slurm_executor" -n executorlib/interfaces/slurm.py

Length of output: 273


🏁 Script executed:

#!/bin/bash
# Display the definition of create_slurm_executor to inspect its parameters
sed -n '350,420p' executorlib/interfaces/slurm.py

Length of output: 4590


Honor disable_dependencies when plot_dependency_graph=True

Currently, in SlurmExecutor.__init__ (executorlib/interfaces/slurm.py, lines 170–187), the disable_dependencies flag is ignored whenever plot_dependency_graph=True, because we unconditionally wrap the SLURM executor in a DependencyExecutor. This means a caller who sets

disable_dependencies=True, plot_dependency_graph=True

will still have their futures resolved, violating the intent of disable_dependencies.

Please update the else branch to either:

  • Bypass DependencyExecutor when disable_dependencies=True, e.g.:

             else:
    -            super().__init__(
    -                executor=DependencyExecutor(
    -                    executor=create_slurm_executor(...),
    -                    max_cores=max_cores,
    -                    ...
    -                )
    -            )
    +            if disable_dependencies:
    +                super().__init__(
    +                    executor=create_slurm_executor(
    +                        max_workers=max_workers,
    +                        cache_directory=cache_directory,
    +                        max_cores=max_cores,
    +                        resource_dict=resource_dict,
    +                        hostname_localhost=hostname_localhost,
    +                        block_allocation=block_allocation,
    +                        init_function=init_function,
    +                    )
    +                )
    +            else:
    +                super().__init__(
    +                    executor=DependencyExecutor(
    +                        executor=create_slurm_executor(
    +                            max_workers=max_workers,
    +                            cache_directory=cache_directory,
    +                            max_cores=max_cores,
    +                            resource_dict=resource_dict,
    +                            hostname_localhost=hostname_localhost,
    +                            block_allocation=block_allocation,
    +                            init_function=init_function,
    +                        ),
    +                        max_cores=max_cores,
    +                        refresh_rate=refresh_rate,
    +                        plot_dependency_graph=plot_dependency_graph,
    +                        plot_dependency_graph_filename=plot_dependency_graph_filename,
    +                    )
    +                )
  • Or explicitly forbid the combination:

    if plot_dependency_graph and disable_dependencies:
        raise ValueError(
            "`disable_dependencies=True` cannot be used with `plot_dependency_graph=True`"
        )

This will prevent the silent mismatch between user intent and actual behavior.

@jan-janssen jan-janssen force-pushed the executorbaseinterface branch from 6f7ad18 to 5f66419 Compare April 26, 2025 05:19
@codecov
Copy link

codecov bot commented Apr 26, 2025

Codecov Report

Attention: Patch coverage is 90.54054% with 7 lines in your changes missing coverage. Please review.

Project coverage is 96.65%. Comparing base (5a33b55) to head (718c46b).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
executorlib/interfaces/slurm.py 60.00% 6 Missing ⚠️
executorlib/base/executor.py 95.83% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #634      +/-   ##
==========================================
+ Coverage   96.30%   96.65%   +0.35%     
==========================================
  Files          28       28              
  Lines        1271     1287      +16     
==========================================
+ Hits         1224     1244      +20     
+ Misses         47       43       -4     

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

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@jan-janssen jan-janssen reopened this Apr 26, 2025
@jan-janssen jan-janssen deleted the executorbaseinterface branch April 26, 2025 08:34
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.

2 participants