Skip to content

Commit

Permalink
Feature/update stac pydantic3.1.0 (#697)
Browse files Browse the repository at this point in the history
* update stac-pydantic dependendy

* replace stac-pydantic todos

* fix benchmark

* replace deprecated .dict()

* fix datetime interval for GET Search

* update changelog
  • Loading branch information
vincentsarago authored May 21, 2024
1 parent f815c23 commit 5a4d5b9
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
6 changes: 4 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

### Changed

* switch from `fastapi` to `fastapi-slim` to avoid installing unwanted dependencies. ([#687](https://github.com/stac-utils/stac-fastapi/pull/687))
* replace Enum with `Literal` for `FilterLang`. ([#686](https://github.com/stac-utils/stac-fastapi/pull/686))
* Switch from `fastapi` to `fastapi-slim` to avoid installing unwanted dependencies. ([#687](https://github.com/stac-utils/stac-fastapi/pull/687))
* Replace Enum with `Literal` for `FilterLang`. ([#686](https://github.com/stac-utils/stac-fastapi/pull/686))
* Update stac-pydantic requirement to `~3.1` ([#697](https://github.com/stac-utils/stac-fastapi/pull/697))
* Fix datetime interval for GET Search when passing a single value ([#697](https://github.com/stac-utils/stac-fastapi/pull/697))

### Removed

Expand Down
4 changes: 2 additions & 2 deletions stac_fastapi/api/stac_fastapi/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ def register_conformance_classes(self):
name="Conformance Classes",
path="/conformance",
response_model=(
api.ConformanceClasses if self.settings.enable_response_models else None
api.Conformance if self.settings.enable_response_models else None
),
responses={
200: {
"content": {
MimeTypes.json.value: {},
},
"model": api.ConformanceClasses,
"model": api.Conformance,
},
},
response_class=self.response_class,
Expand Down
5 changes: 3 additions & 2 deletions stac_fastapi/api/tests/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
collections = [
stac_types.Collection(
id=f"test_collection_{n}",
type="Collection",
title="Test Collection",
description="A test collection",
keywords=["test"],
Expand All @@ -25,7 +26,7 @@
"spatial": {"bbox": [[-180, -90, 180, 90]]},
"temporal": {"interval": [["2000-01-01T00:00:00Z", None]]},
},
links=collection_links.dict(exclude_none=True),
links=collection_links.model_dump(exclude_none=True),
)
for n in range(0, 10)
]
Expand All @@ -37,7 +38,7 @@
geometry={"type": "Point", "coordinates": [0, 0]},
bbox=[-180, -90, 180, 90],
properties={"datetime": "2000-01-01T00:00:00Z"},
links=item_links.dict(exclude_none=True),
links=item_links.model_dump(exclude_none=True),
assets={},
)
for n in range(0, 1000)
Expand Down
1 change: 1 addition & 0 deletions stac_fastapi/api/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
@pytest.fixture
def _collection():
return Collection(
type="Collection",
id="test_collection",
title="Test Collection",
description="A test collection",
Expand Down
2 changes: 1 addition & 1 deletion stac_fastapi/types/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"fastapi-slim",
"attrs>=23.2.0",
"pydantic-settings>=2",
"stac_pydantic>=3",
"stac_pydantic~=3.1",
"iso8601>=1.0.2,<2.2.0",
]

Expand Down
12 changes: 4 additions & 8 deletions stac_fastapi/types/stac_fastapi/types/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,8 @@ def landing_page(self, **kwargs) -> stac.LandingPage:
if self.extension_is_enabled("FilterExtension"):
landing_page["links"].append(
{
# TODO: replace this with Relations.queryables.value,
"rel": "http://www.opengis.net/def/rel/ogc/1.0/queryables",
# TODO: replace this with MimeTypes.jsonschema,
"type": "application/schema+json",
"rel": Relations.queryables.value,
"type": MimeTypes.jsonschema.value,
"title": "Queryables",
"href": urljoin(base_url, "queryables"),
"method": "GET",
Expand Down Expand Up @@ -586,10 +584,8 @@ async def landing_page(self, **kwargs) -> stac.LandingPage:
if self.extension_is_enabled("FilterExtension"):
landing_page["links"].append(
{
# TODO: replace this with Relations.queryables.value,
"rel": "http://www.opengis.net/def/rel/ogc/1.0/queryables",
# TODO: replace this with MimeTypes.jsonschema,
"type": "application/schema+json",
"rel": Relations.queryables.value,
"type": MimeTypes.jsonschema.value,
"title": "Queryables",
"href": urljoin(base_url, "queryables"),
"method": "GET",
Expand Down
3 changes: 3 additions & 0 deletions stac_fastapi/types/stac_fastapi/types/rfc3339.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ def str_to_interval(interval: Optional[str]) -> Optional[DateTimeType]:
detail="Interval string contains more than one forward slash.",
)

if len(values) == 1:
values = [values[0], values[0]]

try:
start = parse_single_date(values[0]) if values[0] not in ["..", ""] else None
end = (
Expand Down

0 comments on commit 5a4d5b9

Please sign in to comment.