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

Update pydantic to support v2 #1941

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# Copyright (c) 2020 Tom Kralidis
# Copyright (c) 2019 Just van den Broecke
# Copyright (c) 2020 Francesco Bartoli
# Copyright (c) 2025 Francesco Bartoli
# Copyright (c) 2024 Angelos Tzotsos
# Copyright (c) 2023 Bernhard Mallinger
#
Expand Down Expand Up @@ -134,12 +134,11 @@ RUN python3 -m pip install --no-cache-dir -r requirements-docker.txt \
ADD . /pygeoapi

# Install pygeoapi
RUN python3 -m pip install --no-cache-dir -e .
RUN python3 -m pip install --no-cache-dir -e .

RUN \
RUN \
# Set default config and entrypoint for Docker Image
cp /pygeoapi/docker/default.config.yml /pygeoapi/local.config.yml \
&& cp /pygeoapi/docker/entrypoint.sh /entrypoint.sh
&& cp /pygeoapi/docker/entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]

36 changes: 18 additions & 18 deletions docker/default.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# Copyright (c) 2019 Just van den Broecke
# Copyright (c) 2020 Tom Kralidis
# Copyright (c) 2020 Francesco Bartoli
# Copyright (c) 2025 Francesco Bartoli
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
Expand Down Expand Up @@ -218,18 +218,18 @@ resources:
# target_srs: EPSG:4326
source_capabilities:
paging: True

source_options:
# OGR_WFS_VERSION: 1.1.0
OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN: NO

gdal_ogr_options:
EMPTY_AS_NULL: NO
GDAL_CACHEMAX: 64
# GDAL_HTTP_PROXY: (optional proxy)
# GDAL_PROXY_AUTH: (optional auth for remote WFS)
CPL_DEBUG: NO

crs:
- http://www.opengis.net/def/crs/EPSG/0/4258
- http://www.opengis.net/def/crs/EPSG/0/28992
Expand Down Expand Up @@ -269,18 +269,18 @@ resources:
# target_srs: EPSG:4326
source_capabilities:
paging: True

source_options:
# OGR_WFS_VERSION: 2.0.0
OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN: NO

gdal_ogr_options:
EMPTY_AS_NULL: NO
GDAL_CACHEMAX: 64
# GDAL_HTTP_PROXY: (optional proxy)
# GDAL_PROXY_AUTH: (optional auth for remote WFS)
CPL_DEBUG: NO

crs:
- http://www.opengis.net/def/crs/EPSG/0/4258
- http://www.opengis.net/def/crs/EPSG/0/26912
Expand Down Expand Up @@ -319,18 +319,18 @@ resources:
# target_srs: EPSG:4326
source_capabilities:
paging: True

source_options:
# OGR_WFS_VERSION: 1.1.0
OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN: NO

gdal_ogr_options:
EMPTY_AS_NULL: NO
GDAL_CACHEMAX: 64
# GDAL_HTTP_PROXY: (optional proxy)
# GDAL_PROXY_AUTH: (optional auth for remote WFS)
CPL_DEBUG: NO

crs:
- http://www.opengis.net/def/crs/EPSG/0/4258
- http://www.opengis.net/def/crs/EPSG/0/32632
Expand Down Expand Up @@ -374,14 +374,14 @@ resources:
# target_srs: EPSG:4326
source_capabilities:
paging: True

gdal_ogr_options:
EMPTY_AS_NULL: NO
GDAL_CACHEMAX: 64
# GDAL_HTTP_PROXY: (optional proxy)
# GDAL_PROXY_AUTH: (optional auth for remote WFS)
CPL_DEBUG: NO

id_field: osm_id
layer: poi_portugal

Expand Down Expand Up @@ -414,14 +414,14 @@ resources:
# target_srs: EPSG:4326
source_capabilities:
paging: True

gdal_ogr_options:
EMPTY_AS_NULL: NO
GDAL_CACHEMAX: 64
# GDAL_HTTP_PROXY: (optional proxy)
# GDAL_PROXY_AUTH: (optional auth for remote WFS)
CPL_DEBUG: NO

id_field: id
layer: ne_110m_lakes

Expand Down Expand Up @@ -457,14 +457,14 @@ resources:
# target_srs: EPSG:4326
source_capabilities:
paging: True

gdal_ogr_options:
EMPTY_AS_NULL: NO
GDAL_CACHEMAX: 64
# GDAL_HTTP_PROXY: (optional proxy)
# GDAL_PROXY_AUTH: (optional auth for remote WFS)
CPL_DEBUG: NO

id_field: id
layer: ogrgeojson

Expand Down Expand Up @@ -499,14 +499,14 @@ resources:
# target_srs: EPSG:4326
source_capabilities:
paging: True

gdal_ogr_options:
EMPTY_AS_NULL: NO
GDAL_CACHEMAX: 64
# GDAL_HTTP_PROXY: (optional proxy)
# GDAL_PROXY_AUTH: (optional auth for remote WFS)
CPL_DEBUG: NO

id_field: id
layer: OGRGeoJSON

Expand Down
13 changes: 7 additions & 6 deletions pygeoapi/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Ricardo Garcia Silva <ricardo.garcia.silva@geobeyond.it>
#
# Copyright (c) 2025 Tom Kralidis
# Copyright (c) 2022 Francesco Bartoli
# Copyright (c) 2025 Francesco Bartoli
# Copyright (c) 2022 John A Stevenson and Colin Blackburn
# Copyright (c) 2023 Ricardo Garcia Silva
#
Expand Down Expand Up @@ -212,6 +212,7 @@ def example_method(api: API, request: APIRequest, custom_arg):
:param request: The web platform specific Request instance.
:param supported_locales: List or set of supported Locale instances.
"""

def __init__(self, request, supported_locales):
# Set default request data
self._data = b''
Expand Down Expand Up @@ -336,7 +337,7 @@ def _get_format(self, headers) -> Union[str, None]:

# Format not specified: get from Accept headers (MIME types)
# e.g. format_ = 'text/html'
h = headers.get('accept', headers.get('Accept', '')).strip() # noqa
h = headers.get('accept', headers.get('Accept', '')).strip() # noqa
(fmts, mimes) = zip(*FORMAT_TYPES.items())
# basic support for complex types (i.e. with "q=0.x")
for type_ in (t.split(';')[0].strip() for t in h.split(',') if t):
Expand Down Expand Up @@ -1134,10 +1135,10 @@ def describe_collections(api: API, request: APIRequest,

# OAPIF Part 2 - list supported CRSs and StorageCRS
if collection_data_type in ['edr', 'feature']:
collection['crs'] = get_supported_crs_list(collection_data, DEFAULT_CRS_LIST) # noqa
collection['storageCRS'] = collection_data.get('storage_crs', DEFAULT_STORAGE_CRS) # noqa
collection['crs'] = get_supported_crs_list(collection_data, DEFAULT_CRS_LIST) # noqa
collection['storageCRS'] = collection_data.get('storage_crs', DEFAULT_STORAGE_CRS) # noqa
if 'storage_crs_coordinate_epoch' in collection_data:
collection['storageCrsCoordinateEpoch'] = collection_data.get('storage_crs_coordinate_epoch') # noqa
collection['storageCrsCoordinateEpoch'] = collection_data.get('storage_crs_coordinate_epoch') # noqa

elif collection_data_type == 'coverage':
# TODO: translate
Expand Down Expand Up @@ -1176,7 +1177,7 @@ def describe_collections(api: API, request: APIRequest,
collection['extent']['spatial']['grid'] = [{
'cellsCount': p._coverage_properties['width'],
'resolution': p._coverage_properties['resx']
}, {
}, {
'cellsCount': p._coverage_properties['height'],
'resolution': p._coverage_properties['resy']
}]
Expand Down
6 changes: 3 additions & 3 deletions pygeoapi/api/coverages.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Bernhard Mallinger <bernhard.mallinger@eox.at>
#
# Copyright (c) 2024 Tom Kralidis
# Copyright (c) 2022 Francesco Bartoli
# Copyright (c) 2025 Francesco Bartoli
# Copyright (c) 2022 John A Stevenson and Colin Blackburn
# Copyright (c) 2023 Ricardo Garcia Silva
# Copyright (c) 2024 Bernhard Mallinger
Expand Down Expand Up @@ -161,8 +161,8 @@ def get_collection_coverage(
except (AttributeError, ValueError) as err:
msg = f'Invalid subset: {err}'
return api.get_exception(
HTTPStatus.BAD_REQUEST, headers, format_,
'InvalidParameterValue', msg)
HTTPStatus.BAD_REQUEST, headers, format_,
'InvalidParameterValue', msg)

if not set(subsets.keys()).issubset(p.axes):
msg = 'Invalid axis name'
Expand Down
6 changes: 3 additions & 3 deletions pygeoapi/api/environmental_data_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Bernhard Mallinger <bernhard.mallinger@eox.at>
#
# Copyright (c) 2024 Tom Kralidis
# Copyright (c) 2022 Francesco Bartoli
# Copyright (c) 2025 Francesco Bartoli
# Copyright (c) 2022 John A Stevenson and Colin Blackburn
# Copyright (c) 2023 Ricardo Garcia Silva
# Copyright (c) 2024 Bernhard Mallinger
Expand Down Expand Up @@ -148,7 +148,7 @@ def get_collection_edr_instances(api: API, request: APIRequest, dataset,
'href': f'{uri}/instances/{instance}/{qt}',
'rel': 'data',
'title': f'{qt} query'
}
}
}
instance_dict['data_queries'][qt] = data_query

Expand All @@ -166,7 +166,7 @@ def get_collection_edr_instances(api: API, request: APIRequest, dataset,
'href': f'{links_uri}?f={F_JSON}',
'rel': request.get_linkrel(F_JSON),
'type': 'application/json'
}, {
}, {
'href': f'{links_uri}?f={F_HTML}',
'rel': request.get_linkrel(F_HTML),
'type': 'text/html'
Expand Down
10 changes: 5 additions & 5 deletions pygeoapi/api/itemtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Ricardo Garcia Silva <ricardo.garcia.silva@geobeyond.it>
#
# Copyright (c) 2024 Tom Kralidis
# Copyright (c) 2022 Francesco Bartoli
# Copyright (c) 2025 Francesco Bartoli
# Copyright (c) 2022 John A Stevenson and Colin Blackburn
# Copyright (c) 2023 Ricardo Garcia Silva
#
Expand Down Expand Up @@ -352,7 +352,7 @@ def get_collection_items(
HTTPStatus.BAD_REQUEST, headers, request.format,
'NoApplicableCode', msg)

supported_crs_list = get_supported_crs_list(provider_def, DEFAULT_CRS_LIST) # noqa
supported_crs_list = get_supported_crs_list(provider_def, DEFAULT_CRS_LIST) # noqa
if bbox_crs not in supported_crs_list:
msg = f'bbox-crs {bbox_crs} not supported for this collection'
return api.get_exception(
Expand All @@ -367,7 +367,7 @@ def get_collection_items(
if len(bbox) > 0:
try:
# Get a pyproj CRS instance for the Collection's Storage CRS
storage_crs = provider_def.get('storage_crs', DEFAULT_STORAGE_CRS) # noqa
storage_crs = provider_def.get('storage_crs', DEFAULT_STORAGE_CRS) # noqa

# Do the (optional) Transform to the Storage CRS
bbox = transform_bbox(bbox, bbox_crs, storage_crs)
Expand Down Expand Up @@ -621,8 +621,8 @@ def get_collection_items(
data=content,
options={
'provider_def': get_provider_by_type(
collections[dataset]['providers'],
'feature')
collections[dataset]['providers'],
'feature')
}
)
except FormatterSerializationError:
Expand Down
2 changes: 1 addition & 1 deletion pygeoapi/api/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Bernhard Mallinger <bernhard.mallinger@eox.at>
#
# Copyright (c) 2024 Tom Kralidis
# Copyright (c) 2022 Francesco Bartoli
# Copyright (c) 2025 Francesco Bartoli
# Copyright (c) 2022 John A Stevenson and Colin Blackburn
# Copyright (c) 2023 Ricardo Garcia Silva
# Copyright (c) 2024 Bernhard Mallinger
Expand Down
4 changes: 2 additions & 2 deletions pygeoapi/api/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Francesco Martinelli <francesco.martinelli@ingv.it>
#
# Copyright (c) 2024 Tom Kralidis
# Copyright (c) 2022 Francesco Bartoli
# Copyright (c) 2025 Francesco Bartoli
# Copyright (c) 2022 John A Stevenson and Colin Blackburn
# Copyright (c) 2023 Ricardo Garcia Silva
# Copyright (c) 2024 Bernhard Mallinger
Expand Down Expand Up @@ -65,7 +65,7 @@
LOGGER = logging.getLogger(__name__)

CONFORMANCE_CLASSES = [
'http://www.opengis.net/spec/ogcapi-processes-1/1.0/conf/ogc-process-description', # noqa
'http://www.opengis.net/spec/ogcapi-processes-1/1.0/conf/ogc-process-description', # noqa
'http://www.opengis.net/spec/ogcapi-processes-1/1.0/conf/core',
'http://www.opengis.net/spec/ogcapi-processes-1/1.0/conf/json',
'http://www.opengis.net/spec/ogcapi-processes-1/1.0/conf/oas30',
Expand Down
2 changes: 1 addition & 1 deletion pygeoapi/api/stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Bernhard Mallinger <bernhard.mallinger@eox.at>
#
# Copyright (c) 2024 Tom Kralidis
# Copyright (c) 2022 Francesco Bartoli
# Copyright (c) 2025 Francesco Bartoli
# Copyright (c) 2022 John A Stevenson and Colin Blackburn
# Copyright (c) 2023 Ricardo Garcia Silva
# Copyright (c) 2024 Bernhard Mallinger
Expand Down
14 changes: 7 additions & 7 deletions pygeoapi/api/tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Bernhard Mallinger <bernhard.mallinger@eox.at>
#
# Copyright (c) 2024 Tom Kralidis
# Copyright (c) 2022 Francesco Bartoli
# Copyright (c) 2025 Francesco Bartoli
# Copyright (c) 2022 John A Stevenson and Colin Blackburn
# Copyright (c) 2023 Ricardo Garcia Silva
# Copyright (c) 2024 Bernhard Mallinger
Expand Down Expand Up @@ -95,7 +95,7 @@ def get_collection_tiles(api: API, request: APIRequest,
LOGGER.debug('Loading provider')
try:
t = get_provider_by_type(
api.config['resources'][dataset]['providers'], 'tile')
api.config['resources'][dataset]['providers'], 'tile')
p = load_plugin('provider', t)
except (KeyError, ProviderTypeError):
msg = 'Invalid collection tiles'
Expand Down Expand Up @@ -359,14 +359,14 @@ def tilematrixsets(api: API,
{
"rel": "self",
"type": "text/html",
"title": f"The HTML representation of the {e.tileMatrixSet} tile matrix set", # noqa
"href": f"{api.base_url}/TileMatrixSets/{e.tileMatrixSet}?f=html" # noqa
"title": f"The HTML representation of the {e.tileMatrixSet} tile matrix set", # noqa
"href": f"{api.base_url}/TileMatrixSets/{e.tileMatrixSet}?f=html" # noqa
},
{
"rel": "self",
"type": "application/json",
"title": f"The JSON representation of the {e.tileMatrixSet} tile matrix set", # noqa
"href": f"{api.base_url}/TileMatrixSets/{e.tileMatrixSet}?f=json" # noqa
"title": f"The JSON representation of the {e.tileMatrixSet} tile matrix set", # noqa
"href": f"{api.base_url}/TileMatrixSets/{e.tileMatrixSet}?f=json" # noqa
}
]
})
Expand Down Expand Up @@ -502,7 +502,7 @@ def get_oas_30(cfg: dict, locale: str) -> tuple[list[dict[str, str]], dict[str,
'tags': [k],
'operationId': f'get{k.capitalize()}.collection.{datatype}.getTile', # noqa
'parameters': [
{'$ref': f"{OPENAPI_YAML['oapit']}#/components/parameters/tileMatrixSetId"}, # noqa
{'$ref': f"{OPENAPI_YAML['oapit']}#/components/parameters/tileMatrixSetId"}, # noqa
{'$ref': f"{OPENAPI_YAML['oapit']}#/components/parameters/tileMatrix"}, # noqa
{'$ref': f"{OPENAPI_YAML['oapit']}#/components/parameters/tileRow"}, # noqa
{'$ref': f"{OPENAPI_YAML['oapit']}#/components/parameters/tileCol"}, # noqa
Expand Down
2 changes: 1 addition & 1 deletion pygeoapi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Francesco Bartoli <xbartolone@gmail.com>
#
# Copyright (c) 2022 Tom Kralidis
# Copyright (c) 2024 Francesco Bartoli
# Copyright (c) 2025 Francesco Bartoli
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
Expand Down
Loading