Skip to content

Commit 8dc770c

Browse files
authored
Merge pull request #281 from ironArray/enable_calculator
Changes to allow calculator function for prompt
2 parents 758edf5 + 8562ef1 commit 8dc770c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

caterva2/services/server.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,17 @@ def open_b2(abspath, path):
128128
for key, value in operands.items():
129129
if value is None:
130130
raise ValueError(f'Missing operand "{key}"')
131-
metaval = value.schunk.meta if hasattr(value, "schunk") else {}
132-
vlmetaval = value.schunk.vlmeta
133-
if "proxy-source" in metaval or ("_ftype" in vlmetaval and vlmetaval["_ftype"] == "hdf5"):
134-
# Save operand as Proxy, see blosc2.open doc for more info.
135-
# Or, it can be an HDF5 dataset too (which should be handled in the next call)
136-
relpath = srv_utils.get_relpath(value)
137-
operands[key] = open_b2(value.schunk.urlpath, relpath)
131+
if isinstance(value, blosc2.Operand):
132+
metaval = value.schunk.meta if hasattr(value, "schunk") else {}
133+
vlmetaval = value.schunk.vlmeta
134+
if "proxy-source" in metaval or ("_ftype" in vlmetaval and vlmetaval["_ftype"] == "hdf5"):
135+
# Save operand as Proxy, see blosc2.open doc for more info.
136+
# Or, it can be an HDF5 dataset too (which should be handled in the next call)
137+
relpath = srv_utils.get_relpath(value)
138+
operands[key] = open_b2(value.schunk.urlpath, relpath)
139+
else:
140+
if value.shape != ():
141+
raise ValueError("Something has gone wrong. Non-blosc2.Operands should be scalars.")
138142

139143
if not hasattr(container, "_where_args"):
140144
# If the container does not have _where_args, it is a LazyExpr

0 commit comments

Comments
 (0)