Skip to content

Commit

Permalink
apply_dimension: prevent specifying process with deprecated runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Nov 20, 2023
1 parent 0e9f55d commit 4166e3e
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions openeo/rest/datacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ def apply_dimension(
runtime=None,
# TODO: drop None default of process (when `code` and `runtime` args can be dropped)
process: Union[str, typing.Callable, UDF, PGNode] = None,
version="latest",
version: Optional[str] = None,
# TODO: dimension has no default (per spec)?
dimension: str = "t",
target_dimension: Optional[str] = None,
Expand Down Expand Up @@ -1084,13 +1084,19 @@ def apply_dimension(
"""
# TODO #137 #181 #312 remove support for code/runtime/version
if runtime or (isinstance(code, str) and "\n" in code):
warnings.warn(
"Specifying UDF code through `code`, `runtime` and `version` arguments is deprecated. "
"Instead create an `openeo.UDF` object and pass that to the `process` argument.",
category=UserDeprecationWarning, stacklevel=2
)
process = UDF(code=code, runtime=runtime, version=version, context=context)
if runtime or (isinstance(code, str) and "\n" in code) or version:
if process:
raise ValueError(
"Cannot specify `process` argument together with deprecated `code`/`runtime`/`version` arguments."
)
else:
warnings.warn(
"Specifying UDF code through `code`, `runtime` and `version` arguments is deprecated. "
"Instead create an `openeo.UDF` object and pass that to the `process` argument.",
category=UserDeprecationWarning,
stacklevel=2,
)
process = UDF(code=code, runtime=runtime, version=version, context=context)
else:
process = process or code
process = build_child_callback(
Expand Down

0 comments on commit 4166e3e

Please sign in to comment.