Skip to content

Conversation

@jan-janssen
Copy link
Member

@jan-janssen jan-janssen commented Jan 10, 2026

Summary by CodeRabbit

Release Notes

This release contains internal code optimizations with no user-visible changes or impact. All existing functionality remains unchanged.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 10, 2026

📝 Walkthrough

Walkthrough

The pull request relocates a numpy import from module-level to local scope within the export_dependency_graph_function function in dependency_plot.py. This narrows numpy's visibility to only where it is actively used, while maintaining existing functionality and type checking behavior.

Changes

Cohort / File(s) Summary
Import scope refactoring
src/executorlib/task_scheduler/interactive/dependency_plot.py
Moved import numpy as np from top-level to inside export_dependency_graph_function, making numpy available only within that function scope where it is used for type checks and operations

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A hop, a skip, an import's flight,
From the top, now tucked just right,
NumPy nestles where it's needed most,
Local scope—the rabbit's toast! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Bug: Do not require numpy' clearly identifies the main change: refactoring the code to make numpy an optional local dependency rather than a required global import.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ 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

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

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/executorlib/task_scheduler/interactive/dependency_plot.py (1)

247-273: Fix inconsistent numpy dependency handling across production code.

Numpy is used in two production files with different approaches:

  • src/executorlib/task_scheduler/interactive/dependency_plot.py (line 247): correctly uses local conditional import
  • src/executorlib/standalone/hdf.py (line 6): unconditionally imports numpy at module level and uses it extensively (np.void() calls throughout)

Since numpy is not declared in project dependencies or optional-dependencies in pyproject.toml, the unconditional import in hdf.py will fail if numpy is not installed. Either add numpy as a dependency (noting that h5py indirectly requires it) or guard hdf.py's import with try-except like dependency_plot.py does.

🤖 Fix all issues with AI agents
In @src/executorlib/task_scheduler/interactive/dependency_plot.py:
- Around line 247-248: The module currently does a direct local import "import
numpy as np" which will raise ImportError if numpy is absent; wrap that import
in a try/except ImportError and set np = None on failure, then update any
functions in dependency_plot.py that use numpy to check for np is not None
before performing numpy-specific operations (or raise a clear RuntimeError
advising the user to install numpy), ensuring the module remains importable when
numpy is not installed.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ea87a0 and 6e5bfed.

📒 Files selected for processing (1)
  • src/executorlib/task_scheduler/interactive/dependency_plot.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). (20)
  • GitHub Check: unittest_mpich (ubuntu-latest, 3.11)
  • GitHub Check: unittest_mpich (ubuntu-22.04-arm, 3.13)
  • GitHub Check: unittest_mpich (ubuntu-24.04-arm, 3.13)
  • GitHub Check: unittest_mpich (ubuntu-latest, 3.12)
  • GitHub Check: unittest_openmpi (ubuntu-24.04-arm, 3.13)
  • GitHub Check: unittest_mpich (ubuntu-latest, 3.13)
  • GitHub Check: unittest_openmpi (ubuntu-latest, 3.12)
  • GitHub Check: unittest_openmpi (ubuntu-latest, 3.13)
  • GitHub Check: unittest_openmpi (macos-latest, 3.13)
  • GitHub Check: unittest_mpich (macos-latest, 3.13)
  • GitHub Check: unittest_openmpi (ubuntu-latest, 3.11)
  • GitHub Check: unittest_openmpi (ubuntu-22.04-arm, 3.13)
  • GitHub Check: unittest_win
  • GitHub Check: unittest_old
  • GitHub Check: benchmark (ubuntu-latest, 3.13, .ci_support/environment-mpich.yml)
  • GitHub Check: unittest_flux_mpich
  • GitHub Check: unittest_slurm_mpich
  • GitHub Check: benchmark (ubuntu-latest, 3.13, .ci_support/environment-openmpi.yml)
  • GitHub Check: notebooks
  • GitHub Check: notebooks_integration

Comment on lines +247 to +248
import numpy as np

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Handle ImportError to make numpy truly optional.

The local import achieves lazy loading but doesn't make numpy optional. If numpy is not installed, the function will raise an ImportError when called. To align with the PR objective ("Do not require numpy"), wrap the import in a try-except block and conditionally handle numpy-specific operations.

🔧 Proposed fix to handle missing numpy gracefully
-    import numpy as np
-
+    try:
+        import numpy as np
+        HAS_NUMPY = True
+    except ImportError:
+        HAS_NUMPY = False
+
     pwd_nodes_lst = []
     for n in node_lst:
         if n["type"] == "function":
             pwd_nodes_lst.append(
                 {"id": n["id"], "type": n["type"], "value": n["value"]}
             )
-        elif n["type"] == "input" and isinstance(n["value"], np.ndarray):
+        elif HAS_NUMPY and n["type"] == "input" and isinstance(n["value"], np.ndarray):
             pwd_nodes_lst.append(
                 {
                     "id": n["id"],
🤖 Prompt for AI Agents
In @src/executorlib/task_scheduler/interactive/dependency_plot.py around lines
247 - 248, The module currently does a direct local import "import numpy as np"
which will raise ImportError if numpy is absent; wrap that import in a
try/except ImportError and set np = None on failure, then update any functions
in dependency_plot.py that use numpy to check for np is not None before
performing numpy-specific operations (or raise a clear RuntimeError advising the
user to install numpy), ensuring the module remains importable when numpy is not
installed.

@codecov
Copy link

codecov bot commented Jan 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.41%. Comparing base (3ea87a0) to head (6e5bfed).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #885   +/-   ##
=======================================
  Coverage   93.41%   93.41%           
=======================================
  Files          38       38           
  Lines        1837     1837           
=======================================
  Hits         1716     1716           
  Misses        121      121           

☔ 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 beb21cb into main Jan 10, 2026
62 of 63 checks passed
@jan-janssen jan-janssen deleted the numpy branch January 10, 2026 08:14
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