Skip to content

Commit

Permalink
Merge pull request #216 from stac-utils/feature/lock-and-titiler-version
Browse files Browse the repository at this point in the history
update titiler requirement and add lock to Cache
  • Loading branch information
vincentsarago authored Feb 13, 2025
2 parents f422bd2 + bf27a72 commit 07f4a71
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ classifiers = [
"Topic :: Scientific/Engineering :: GIS",
]
dependencies = [
"titiler.core>=0.20.0,<0.21",
"titiler.mosaic>=0.20.0,<0.21",
"titiler.core>=0.21,<0.22",
"titiler.mosaic>=0.21,<0.22",
"geojson-pydantic~=1.0",
"pydantic>=2.4,<3.0",
"pydantic-settings~=2.0",
Expand Down
2 changes: 2 additions & 0 deletions titiler/pgstac/backend.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""TiTiler.PgSTAC custom Mosaic Backend and Custom STACReader."""

import json
from threading import Lock
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Type

import attr
Expand Down Expand Up @@ -165,6 +166,7 @@ def assets_for_bbox(
@cached( # type: ignore
TTLCache(maxsize=cache_config.maxsize, ttl=cache_config.ttl),
key=lambda self, geom, **kwargs: hashkey(self.input, str(geom), **kwargs),
lock=Lock(),
)
@retry(
tries=retry_config.retry,
Expand Down
3 changes: 3 additions & 0 deletions titiler/pgstac/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import warnings
from dataclasses import dataclass, field
from threading import Lock
from typing import List, Optional, Tuple

import morecantile
Expand Down Expand Up @@ -45,6 +46,7 @@ def SearchIdParams(
str(bbox),
datetime,
),
lock=Lock(),
)
@retry(
tries=retry_config.retry,
Expand Down Expand Up @@ -263,6 +265,7 @@ class PgSTACParams(DefaultDependency):
@cached( # type: ignore
TTLCache(maxsize=cache_config.maxsize, ttl=cache_config.ttl),
key=lambda pool, collection, item: hashkey(collection, item),
lock=Lock(),
)
@retry(
tries=retry_config.retry,
Expand Down
4 changes: 2 additions & 2 deletions titiler/pgstac/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from rio_tiler.constants import MAX_THREADS, WGS84_CRS
from rio_tiler.mosaic.methods.base import MosaicMethodBase
from rio_tiler.types import ColorMapType
from rio_tiler.utils import CRS_to_uri
from rio_tiler.utils import CRS_to_uri, CRS_to_urn
from starlette.datastructures import QueryParams
from starlette.requests import Request
from starlette.responses import HTMLResponse, Response
Expand Down Expand Up @@ -894,7 +894,7 @@ def wmts( # noqa: C901
bbox_crs_uri = "urn:ogc:def:crs:OGC:2:84"
if tms.rasterio_geographic_crs != WGS84_CRS:
bbox_crs_type = "BoundingBox"
bbox_crs_uri = CRS_to_uri(tms.rasterio_geographic_crs)
bbox_crs_uri = CRS_to_urn(tms.rasterio_geographic_crs)
# WGS88BoundingBox is always xy ordered, but BoundingBox must match the CRS order
if crs_axis_inverted(tms.geographic_crs):
# match the bounding box coordinate order to the CRS
Expand Down

0 comments on commit 07f4a71

Please sign in to comment.