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

fix: lib and server mode queryables #974

Merged
merged 14 commits into from Jan 8, 2024
Merged

fix: lib and server mode queryables #974

merged 14 commits into from Jan 8, 2024

Conversation

sbrunato
Copy link
Collaborator

@sbrunato sbrunato commented Jan 8, 2024

Fixes and refactor of list_queryables() and server-mode /queryables features.

list_queryables() returns a dict containing the EODAG queryable properties, Tuple[Annotated, Any]], tuple of annotated type and default value, that can be directly used as pydantic.create_model() argument:

>>> from pydantic import create_model
>>> from eodag import EODataAccessGateway
>>> dag = EODataAccessGateway()
>>> queryables = dag.list_queryables(product_type="S2_MSI_L1C", provider="peps")
>>> queryables
{'productType': (typing.Annotated[str, FieldInfo(annotation=NoneType, required=True)], None), ...}

>>> my_model = create_model("my_model", **queryables)
>>> my_model(productType="S2_MSI_L1C", start="2023-01-01", end="2023-01-05", cloudCover=20)
my_model(productType="S2_MSI_L1C", start="2023-01-01", end="2023-01-05", cloudCover=20, id=None, ...)

>>> my_model(productType="S2_MSI_L1C", cloudCover=150)
Traceback (most recent call last):
    [...]
pydantic_core._pydantic_core.ValidationError: 1 validation error for my_model
cloudCover
  Input should be less than 100 [type=less_than, input_value=150, input_type=int]

Copy link
Contributor

github-actions bot commented Jan 8, 2024

Test Results

    4 files  ± 0      4 suites  ±0   4m 11s ⏱️ +4s
  447 tests + 6    444 ✅ + 6   3 💤 ±0  0 ❌ ±0 
1 788 runs  +24  1 710 ✅ +24  78 💤 ±0  0 ❌ ±0 

Results for commit ada4201. ± Comparison against base commit 9b95224.

This pull request removes 1 and adds 7 tests. Note that renamed tests count towards both.
tests.units.test_core.TestCore ‑ test_get_queryables
eodag.types.__init__ ‑ eodag.types.json_field_definition_to_python
eodag.types.__init__ ‑ eodag.types.json_type_to_python
eodag.types.__init__ ‑ eodag.types.model_fields_to_annotated_tuple
eodag.types.__init__ ‑ eodag.types.python_field_definition_to_json
eodag.types.__init__ ‑ eodag.types.python_type_to_json
eodag.types.queryables ‑ eodag.types.queryables.CommonQueryables.get_queryable_from_alias
tests.units.test_core.TestCore ‑ test_list_queryables

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Jan 8, 2024

Code Coverage (Ubuntu)

File Coverage
All files 81%

Minimum allowed coverage is 70%

Generated by 🐒 cobertura-action against ada4201

Copy link
Contributor

github-actions bot commented Jan 8, 2024

Code Coverage (Windows)

File Coverage
All files 76%

Minimum allowed coverage is 70%

Generated by 🐒 cobertura-action against ada4201

@sbrunato sbrunato force-pushed the fix_queryables branch 2 times, most recently from 6398e50 to 6f8d04a Compare January 8, 2024 15:48
@sbrunato sbrunato merged commit 4061b78 into develop Jan 8, 2024
12 checks passed
@sbrunato sbrunato deleted the fix_queryables branch January 8, 2024 16:02
@sbrunato sbrunato added this to the 2.12.0 milestone Feb 12, 2024
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.

None yet

2 participants