-
Notifications
You must be signed in to change notification settings - Fork 3
Bug: Do not require numpy #885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughThe pull request relocates a numpy import from module-level to local scope within the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this 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 importsrc/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
📒 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
| import numpy as np | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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.