Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion executorlib/standalone/cache.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os

import cloudpickle
import numpy as np

group_dict = {
"fn": "function",
Expand All @@ -25,6 +24,7 @@ def get_cache_data(cache_directory: str) -> list[dict]:
list[dict]: List of dictionaries each representing on of the HDF5 files in the cache directory.
"""
import h5py
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

Ensure numpy is declared as a dependency and consider import error handling.

Moving import numpy as np into the function introduces a new runtime dependency on numpy. Make sure that:

  1. numpy is listed in your packaging dependencies (e.g., install_requires in setup.py or pyproject.toml), otherwise calls to get_cache_data will break at runtime.
  2. Optionally wrap the local import in a try/except ImportError to provide a clear error message if numpy isn’t installed.

Example diff for setup.py:

--- setup.py
+++ setup.py
@@ setup(
     install_requires=[
-        "cloudpickle>=1.5.0",
+        "cloudpickle>=1.5.0",
+        "numpy>=1.21.0",
     ],
 )

Example of import error handling:

    try:
        import numpy as np
    except ImportError:
        raise RuntimeError(
            "get_cache_data requires numpy; please install it via 'pip install numpy'"
        )


file_lst = []
for task_key in os.listdir(cache_directory):
Expand Down
Loading