Skip to content

Commit

Permalink
issue #698 add fallback situations
Browse files Browse the repository at this point in the history
  • Loading branch information
ElienVandermaesenVITO committed Jan 9, 2025
1 parent 7440d71 commit b506a11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 1 addition & 3 deletions openeo/rest/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ def describe_process(self, id: str, namespace: Optional[str] = None) -> dict:

def get_schema_from_process_parameter(
self, process_id: str, parameter_id: str, namespace: Optional[str] = None
) -> dict:
) -> Union[dict, list]:
"""
Returns schema of the parameter of the process from the back end.
Expand Down Expand Up @@ -2123,6 +2123,4 @@ def search_list_for_dict_key(lst: list, key: str) -> Union[dict, list]:
result = item[key]
else:
raise OpenEoClientException("Multiple keys found with value {v}.".format(v=key))
if result is None:
raise OpenEoClientException("No dictionary found with the key {k}.".format(k=key))
return result
9 changes: 7 additions & 2 deletions openeo/rest/datacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -2724,8 +2724,13 @@ def sar_backscatter(
.. versionadded:: 0.4.9
.. versionchanged:: 0.4.10 replace `orthorectify` and `rtc` arguments with `coefficient`.
"""
schema = self.connection.get_schema_from_process_parameter("sar_backscatter", "coefficient")
coefficient_options = search_list_for_dict_key(schema, "enum")
if self.connection == None:
coefficient_options = [None]
else:
schema = self.connection.get_schema_from_process_parameter("sar_backscatter", "coefficient")
coefficient_options = search_list_for_dict_key(schema, "enum")
if coefficient_options is None:
coefficient_options = [None]
if coefficient not in coefficient_options:
raise OpenEoClientException("Invalid `sar_backscatter` coefficient {c!r}. Should be one of {o}".format(
c=coefficient, o=coefficient_options
Expand Down

0 comments on commit b506a11

Please sign in to comment.