Skip to content

Commit

Permalink
Add parallel read
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-janssen committed Nov 20, 2024
1 parent c0d3642 commit 2828b2a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 280 deletions.
6 changes: 3 additions & 3 deletions executorlib/standalone/hdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def load(file_name: str) -> dict:
Returns:
dict: dictionary containing the python function to be executed {"fn": ..., "args": (), "kwargs": {}}
"""
with h5py.File(file_name, "r") as hdf:
with h5py.File(file_name, "r", swmr=True) as hdf:
data_dict = {}
if "function" in hdf:
data_dict["fn"] = cloudpickle.loads(np.void(hdf["/function"]))
Expand All @@ -66,15 +66,15 @@ def get_output(file_name: str) -> Tuple[bool, object]:
Returns:
Tuple[bool, object]: boolean flag indicating if output is available and the output object itself
"""
with h5py.File(file_name, "r") as hdf:
with h5py.File(file_name, "r", swmr=True) as hdf:
if "output" in hdf:
return True, cloudpickle.loads(np.void(hdf["/output"]))
else:
return False, None


def get_queue_id(file_name: str) -> Optional[int]:
with h5py.File(file_name, "r") as hdf:
with h5py.File(file_name, "r", swmr=True) as hdf:
if "queue_id" in hdf:
return cloudpickle.loads(np.void(hdf["/queue_id"]))
else:
Expand Down
Loading

0 comments on commit 2828b2a

Please sign in to comment.