Skip to content
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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

ElienVandermaesenVITO
Copy link
Contributor

Copy link
Member

@soxofaan soxofaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this PR you add a lot of utility functions. A couple of notes on that:

  • they are al public at the moment, so adding them adds the burden to keep/maintain/support them. In that sense, they should also get good test coverage.
  • some of the seem quite tailored for the specific use case of this PR, while they are named very generically

also note that we already have parsing functionality for process definitions: e.g. see starting point openeo.internal.processes.Process.from_dict(). I think that should eliminate the need for all these new utility functions

I think it's also important that the core goal of this PR gets unit tests coverage

openeo/rest/connection.py Outdated Show resolved Hide resolved
openeo/rest/connection.py Outdated Show resolved Hide resolved
openeo/rest/connection.py Outdated Show resolved Hide resolved
openeo/rest/datacube.py Outdated Show resolved Hide resolved
@ElienVandermaesenVITO
Copy link
Contributor Author

The test fail because of No mock address: GET https://oeo.test/processes. Do I have to change the test and add the address or is there another way to solve it?

@soxofaan
Copy link
Member

soxofaan commented Jan 9, 2025

this feature indeed impacts existing tests

FAILED tests/rest/datacube/test_datacube100.py::test_sar_backscatter_defaults - requests_mock.exceptions.NoMockAddress: No mock address: GET https://oeo.test/processes
FAILED tests/rest/datacube/test_datacube100.py::test_sar_backscatter_custom - requests_mock.exceptions.NoMockAddress: No mock address: GET https://oeo.test/processes
FAILED tests/rest/datacube/test_datacube100.py::test_sar_backscatter_coefficient_none - requests_mock.exceptions.NoMockAddress: No mock address: GET https://oeo.test/processes
FAILED tests/rest/datacube/test_datacube100.py::test_sar_backscatter_coefficient_invalid - requests_mock.exceptions.NoMockAddress: No mock address: GET https://oeo.test/processes

doing cube.sar_backscatter() now triggers a GET /processes request, so you should indeed add a mock for that in these tests

openeo/util.py Outdated Show resolved Hide resolved
Copy link
Member

@soxofaan soxofaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some quick notes

openeo/rest/connection.py Outdated Show resolved Hide resolved
openeo/rest/connection.py Outdated Show resolved Hide resolved
openeo/rest/connection.py Outdated Show resolved Hide resolved
openeo/rest/connection.py Outdated Show resolved Hide resolved
openeo/rest/datacube.py Outdated Show resolved Hide resolved
…ore compact, and remove get_schema_from_process_parameter
openeo/internal/processes/parse.py Outdated Show resolved Hide resolved
openeo/rest/connection.py Outdated Show resolved Hide resolved
openeo/rest/datacube.py Outdated Show resolved Hide resolved
openeo/internal/processes/parse.py Outdated Show resolved Hide resolved
openeo/rest/datacube.py Outdated Show resolved Hide resolved
openeo/internal/processes/parse.py Outdated Show resolved Hide resolved
openeo/util.py Outdated Show resolved Hide resolved
tests/rest/datacube/test_datacube100.py Outdated Show resolved Hide resolved
Copy link
Member

@soxofaan soxofaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple of additional notes

elif isinstance(self.schema,dict):
if name in self.schema:
result = self.schema[name]
return result
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look compatible with how json schema works.

For example, this methods should allow to extract the options from these example use cases:

For example, the caller should not have to specify a name. The implementation should extract the options from the "enum" listing(s) in the schema data

],
)
@pytest.mark.parametrize(("key", "expected"), [("x1", "y1"), ("x2", "y2"), ("x4", None)])
def test_get_enum_options(schema, key, expected):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To parameterize this test, I would use more realistic use cases, e.g. the ones linked above

]
try:
schema = Process.from_dict(self.connection.describe_process("sar_backscatter")).get_parameter("coefficient").schema
coefficient_options = schema.get_enum_options("enum") + [None]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On top of getting the options, we should also get the default value from the schema. It is now hardcoded to "gamma0-terrain" (above), but that should also be dynamic

"summary": "Computes backscatter from SAR input",
"parameters": [
{
"default": "gamma0-terrain",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test should also check that this default value is picked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants