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

3.0 release #743

Merged
merged 6 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

## [Unreleased]

## [3.0.0] - 2024-07-29

### Changed

* Add version pinning (`~=3.0`) for stac-fastapi submodules
* Moved `AsyncBaseFiltersClient` and `BaseFiltersClient` classes in `stac_fastapi.extensions.core.filter.client` submodule

### Removed

* Removed the `Context` extension
* Removed deprecated `stac_fastapi.api.openapi.config_openapi` method and `stac_fastapi.api.openapi.VndOaiResponse` class
* Removed `response_class` argument in `stac_fastapi.api.routes.create_async_endpoint` method
* Removed `filter_fields` property in `stac_fastapi.extensions.core.fields.request.PostFieldsExtension` class

## [3.0.0b3] - 2024-07-25

### Changed
Expand Down Expand Up @@ -450,7 +464,8 @@

* First PyPi release!

[Unreleased]: <https://github.com/stac-utils/stac-fastapi/compare/3.0.0b3..main>
[Unreleased]: <https://github.com/stac-utils/stac-fastapi/compare/3.0.0..main>
[3.0.0]: <https://github.com/stac-utils/stac-fastapi/compare/3.0.0b3..3.0.0>
[3.0.0b3]: <https://github.com/stac-utils/stac-fastapi/compare/3.0.0b2..3.0.0b3>
[3.0.0b2]: <https://github.com/stac-utils/stac-fastapi/compare/3.0.0b1..3.0.0b2>
[3.0.0b1]: <https://github.com/stac-utils/stac-fastapi/compare/3.0.0a4..3.0.0b1>
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.0b3
3.0.0
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ section-order = ["future", "standard-library", "third-party", "first-party", "lo
quote-style = "double"

[tool.bumpversion]
current_version = "3.0.0b3"
current_version = "3.0.0"
parse = """(?x)
(?P<major>\\d+)\\.
(?P<minor>\\d+)\\.
Expand Down
2 changes: 1 addition & 1 deletion stac_fastapi/api/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

install_requires = [
"brotli_asgi",
"stac-fastapi.types",
"stac-fastapi.types~=3.0",
]

extra_reqs = {
Expand Down
1 change: 0 additions & 1 deletion stac_fastapi/api/stac_fastapi/api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class ApiExtensions(enum.Enum):
Ref: https://github.com/stac-api-extensions
"""

context = "context"
fields = "fields"
filter = "filter"
query = "query"
Expand Down
50 changes: 0 additions & 50 deletions stac_fastapi/api/stac_fastapi/api/openapi.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,10 @@
"""openapi."""

import warnings

from fastapi import FastAPI
from fastapi.openapi.utils import get_openapi
from starlette.requests import Request
from starlette.responses import JSONResponse, Response
from starlette.routing import Route, request_response

from stac_fastapi.api.config import ApiExtensions
from stac_fastapi.types.config import ApiSettings


class VndOaiResponse(JSONResponse):
"""JSON with custom, vendor content-type."""

media_type = "application/vnd.oai.openapi+json;version=3.0"

def __init__(self, *args, **kwargs):
"""Init function with deprecation warning."""
warnings.warn(
"VndOaiResponse is deprecated and will be removed in v3.0",
DeprecationWarning,
)
super().__init__(*args, **kwargs)


def update_openapi(app: FastAPI) -> FastAPI:
"""Update OpenAPI response content-type.
Expand Down Expand Up @@ -55,33 +35,3 @@ async def patched_openapi_endpoint(req: Request) -> Response:

# return the patched app
return app


def config_openapi(app: FastAPI, settings: ApiSettings):
"""Config openapi."""
warnings.warn(
"config_openapi is deprecated and will be removed in v3.0",
DeprecationWarning,
)

def custom_openapi():
"""Config openapi."""
if app.openapi_schema:
return app.openapi_schema

openapi_schema = get_openapi(
title="Arturo STAC API", version="0.1", routes=app.routes
)

if settings.api_extension_is_enabled(ApiExtensions.fields):
openapi_schema["paths"]["/search"]["get"]["responses"]["200"]["content"][
"application/json"
]["schema"] = {"$ref": "#/components/schemas/ItemCollection"}
openapi_schema["paths"]["/search"]["post"]["responses"]["200"]["content"][
"application/json"
]["schema"] = {"$ref": "#/components/schemas/ItemCollection"}

app.openapi_schema = openapi_schema
return app.openapi_schema

app.openapi = custom_openapi
8 changes: 0 additions & 8 deletions stac_fastapi/api/stac_fastapi/api/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import copy
import functools
import inspect
import warnings
from typing import Any, Callable, Dict, List, Optional, Type, TypedDict, Union

from fastapi import Depends, params
Expand Down Expand Up @@ -38,19 +37,12 @@ async def run(*args, **kwargs):
def create_async_endpoint(
func: Callable,
request_model: Union[Type[APIRequest], Type[BaseModel], Dict],
response_class: Optional[Type[Response]] = None,
):
"""Wrap a function in a coroutine which may be used to create a FastAPI endpoint.

Synchronous functions are executed asynchronously using a background thread.
"""

if response_class:
warnings.warn(
"`response_class` option is deprecated, please set the Response class directly in the endpoint.", # noqa: E501
DeprecationWarning,
)

if not inspect.iscoroutinefunction(func):
func = sync_to_async(func)

Expand Down
3 changes: 2 additions & 1 deletion stac_fastapi/api/stac_fastapi/api/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Library version."""
__version__ = "3.0.0b3"

__version__ = "3.0.0"
4 changes: 2 additions & 2 deletions stac_fastapi/extensions/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
desc = f.read()

install_requires = [
"stac-fastapi.types",
"stac-fastapi.api",
"stac-fastapi.types~=3.0",
"stac-fastapi.api~=3.0",
]

extra_reqs = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from .aggregation import AggregationExtension
from .collection_search import CollectionSearchExtension, CollectionSearchPostExtension
from .context import ContextExtension
from .fields import FieldsExtension
from .filter import FilterExtension
from .free_text import FreeTextAdvancedExtension, FreeTextExtension
Expand All @@ -13,7 +12,6 @@

__all__ = (
"AggregationExtension",
"ContextExtension",
"FieldsExtension",
"FilterExtension",
"FreeTextExtension",
Expand Down
46 changes: 0 additions & 46 deletions stac_fastapi/extensions/stac_fastapi/extensions/core/context.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Request models for the fields extension."""

import warnings
from typing import Dict, List, Optional, Set

import attr
Expand Down Expand Up @@ -44,31 +43,6 @@ def _get_field_dict(fields: Optional[Set[str]]) -> Dict:

return field_dict

@property
def filter_fields(self) -> Dict:
"""Create pydantic include/exclude expression.

Create dictionary of fields to include/exclude on model export based on
the included and excluded fields passed to the API
Ref: https://pydantic-docs.helpmanual.io/usage/exporting_models/#advanced-include-and-exclude
"""
warnings.warn(
"""The `PostFieldsExtension.filter_fields`
method is deprecated and will be removed in 3.0.""",
DeprecationWarning,
stacklevel=1,
)

# Always include default_includes, even if they
# exist in the exclude list.
include = (self.include or set()) - (self.exclude or set())
include |= set()

return {
"include": self._get_field_dict(include),
"exclude": self._get_field_dict(self.exclude),
}


def _fields_converter(
val: Annotated[
Expand Down
3 changes: 2 additions & 1 deletion stac_fastapi/extensions/stac_fastapi/extensions/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Library version."""
__version__ = "3.0.0b3"

__version__ = "3.0.0"
17 changes: 0 additions & 17 deletions stac_fastapi/types/stac_fastapi/types/core.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Base clients."""

import abc
import importlib
import warnings
from typing import Any, Dict, List, Optional, Union
from urllib.parse import urljoin

Expand Down Expand Up @@ -784,18 +782,3 @@ async def item_collection(
An ItemCollection.
"""
...


# TODO: remove for 3.0.0 final release
def __getattr__(name: str) -> Any:
if name in ["AsyncBaseFiltersClient", "BaseFiltersClient"]:
warnings.warn(
f"""importing {name} from `stac_fastapi.types.core` is deprecated,
please import it from `stac_fastapi.extensions.core.filter.client`.""",
DeprecationWarning,
stacklevel=2,
)
clients = importlib.import_module("stac_fastapi.extensions.core.filter.client")
return getattr(clients, name)

raise AttributeError(f"module {__name__} has no attribute {name}")
3 changes: 2 additions & 1 deletion stac_fastapi/types/stac_fastapi/types/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Library version."""
__version__ = "3.0.0b3"

__version__ = "3.0.0"
Loading