-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue #693 add search for schema and find parameters from the backend #698
base: master
Are you sure you want to change the base?
Changes from 1 commit
488262f
8699f3c
7440d71
b506a11
71b2b79
53936a6
ece05dc
503154b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -127,6 +127,12 @@ def from_json_file(cls, path: Union[str, Path]) -> Process: | |||||
with Path(path).open("r") as f: | ||||||
return cls.from_json(f.read()) | ||||||
|
||||||
def get_parameter(self, parameter_id: str) -> Union[dict, list]: | ||||||
for parameter in self.parameters: | ||||||
if parameter.name == parameter_id: | ||||||
return parameter.schema.schema | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would return the whole parameter instead of just its schema to be more generic
Suggested change
|
||||||
raise LookupError(f"Expected parameter {parameter_id} not found.") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
|
||||||
def parse_all_from_dir(path: Union[str, Path], pattern="*.json") -> Iterator[Process]: | ||||||
"""Parse all openEO process files in given directory""" | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -35,6 +35,7 @@ | |||||
convert_callable_to_pgnode, | ||||||
get_parameter_names, | ||||||
) | ||||||
from openeo.internal.processes.parse import Process | ||||||
from openeo.internal.warnings import UserDeprecationWarning, deprecated, legacy_alias | ||||||
from openeo.metadata import ( | ||||||
Band, | ||||||
|
@@ -2739,10 +2740,19 @@ def sar_backscatter( | |||||
.. versionadded:: 0.4.9 | ||||||
.. versionchanged:: 0.4.10 replace `orthorectify` and `rtc` arguments with `coefficient`. | ||||||
""" | ||||||
coefficient_options = [None] | ||||||
if self.connection: | ||||||
schema = self.connection.get_schema_from_process_parameter("sar_backscatter", "coefficient") | ||||||
coefficient_options += search_list_for_dict_key(schema, "enum") | ||||||
try: | ||||||
schema = Process.from_dict(self.connection.describe_process("sar_backscatter")).get_parameter("coefficient") | ||||||
coefficient_options = search_list_for_dict_key(schema, "enum") + [None] | ||||||
except Exception: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
log.warning(f"Failed to extract option for coefficient in sar_backscatter") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
coefficient_options = [ | ||||||
"beta0", | ||||||
"sigma0-ellipsoid", | ||||||
"sigma0-terrain", | ||||||
"gamma0-ellipsoid", | ||||||
"gamma0-terrain", | ||||||
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 | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a test for this new method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also to stay closer to the openEO spec, I would just use
name
as argument here. "Parameter Id" is not really a thing in the spec