Skip to content

Commit 63883f7

Browse files
Fix when a raw str is used.
1 parent da629e5 commit 63883f7

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

openeo/udf/run_code.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,8 @@ def execute_local_udf(
246246
:param fmt: format of the file if datacube is string
247247
:return: the resulting DataCube
248248
"""
249-
if isinstance(udf, openeo.UDF):
250-
udf_code = udf.code
251-
elif isinstance(udf, str):
252-
udf_code = udf
253-
else:
254-
raise ValueError(udf)
249+
if isinstance(udf, str):
250+
udf = openeo.UDF(code=udf)
255251

256252
if isinstance(datacube, (str, pathlib.Path)):
257253
d = XarrayDataCube.from_file(path=datacube, fmt=fmt)
@@ -278,7 +274,7 @@ def execute_local_udf(
278274
# signature: UdfData(proj, datacube_list, feature_collection_list, structured_data_list, ml_model_list, metadata)
279275

280276
# run the udf through the same routine as it would have been parsed in the backend
281-
result = run_udf_code(udf_code, udf_data)
277+
result = run_udf_code(udf.code, udf_data)
282278
return result
283279

284280

0 commit comments

Comments
 (0)