Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
python-version: ['3.12', '3.13']

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "0.5.*"
version: "0.8.*"
enable-cache: true

- name: Set up Python ${{ matrix.python-version }}
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ target/
# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
2 changes: 1 addition & 1 deletion infrastructure/aws/cdk/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(
id: str,
memory: int = 1024,
timeout: int = 30,
runtime: aws_lambda.Runtime = aws_lambda.Runtime.PYTHON_3_10,
runtime: aws_lambda.Runtime = aws_lambda.Runtime.PYTHON_3_12,
concurrent: Optional[int] = None,
permissions: Optional[List[iam.PolicyStatement]] = None,
environment: Optional[Dict] = None,
Expand Down
24 changes: 9 additions & 15 deletions infrastructure/aws/lambda/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
ARG PYTHON_VERSION=3.11
ARG PYTHON_VERSION=3.12

FROM --platform=linux/amd64 public.ecr.aws/lambda/python:${PYTHON_VERSION}
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

WORKDIR /tmp

# Install system dependencies to compile (numexpr)
RUN yum install -y gcc-c++

COPY pyproject.toml pyproject.toml
COPY LICENSE LICENSE
COPY README.md README.md
COPY src/titiler/ src/titiler/

# Install dependencies
# HACK: aiobotocore has a tight botocore dependency
# https://github.com/aio-libs/aiobotocore/issues/862
# and becaise we NEED to remove both boto3 and botocore to save space for the package
# we have to force using old package version that seems `almost` compatible with Lambda env botocore
# https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html
RUN uv pip install --compile-bytecode . "mangum>=0.10.0" "botocore==1.29.76" "aiobotocore==2.5.0" --target /asset --no-binary pydantic
RUN dnf install -y gcc-c++

COPY uv.lock .python-version pyproject.toml LICENSE README.md ./
COPY src/titiler/ ./src/titiler/

RUN uv export --locked --no-editable --no-dev --extra lambda --format requirements.txt -o requirements.txt && \
uv pip install --compile-bytecode --no-binary pydantic --target /asset -r requirements.txt


# Reduce package size and remove useless files
RUN cd /asset && find . -type f -name '*.pyc' | while read f; do n=$(echo $f | sed 's/__pycache__\///' | sed 's/.cpython-[0-9]*//'); cp $f $n; done;
Expand Down
12 changes: 9 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "titiler-multidim"
description = "TiTiler application extension for titiler.xarray."
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.12"
authors = [
{name = "Vincent Sarago", email = "vincent@developmentseed.com"},
]
Expand All @@ -25,9 +25,11 @@ classifiers = [
]
dynamic = ["version"]
dependencies = [
"titiler.core>=0.21.0,<0.22",
"titiler.xarray>=0.21.0,<0.22",
"titiler.core>=0.23.0,<0.24",
"titiler.xarray>=0.23.0,<0.24",
"aiohttp",
"aiobotocore>=2.24.0",
"boto3>=1.39.0",
"cftime",
"fastapi",
"fsspec",
Expand All @@ -47,6 +49,10 @@ dependencies = [
server = [
"uvicorn"
]
lambda = [
"mangum==0.19.0",
"aiobotocore>=2.24.0,<2.24.2"
]

[dependency-groups]
dev = [
Expand Down
2 changes: 1 addition & 1 deletion src/titiler/multidim/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def histogram(
variable=reader_params.variable,
group=reader_params.group,
decode_times=reader_params.decode_times,
datetime=reader_params.datetime,
sel=reader_params.sel,
) as src_dst:
boolean_mask = ~np.isnan(src_dst.input)
data_values = src_dst.input.values[boolean_mask]
Expand Down
2 changes: 1 addition & 1 deletion src/titiler/multidim/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
)

if api_settings.debug:
app.add_middleware(LoggerMiddleware, headers=True, querystrings=True)
app.add_middleware(LoggerMiddleware)
app.add_middleware(TotalTimeMiddleware)
app.add_middleware(
ServerTimingMiddleware,
Expand Down
3 changes: 1 addition & 2 deletions src/titiler/multidim/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ def __attrs_post_init__(self):
self.input = get_variable(
self.ds,
self.variable,
datetime=self.datetime,
drop_dim=self.drop_dim,
sel=self.sel,
)
super().__attrs_post_init__()

Expand Down
24 changes: 5 additions & 19 deletions tests/fixtures/responses/pyramid_zarr_info.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
{
"bounds": [
-180.0,
-90.0,
180.0,
90.0
],
"bounds": [-180.0, -90.0, 180.0, 90.0],
"crs": "http://www.opengis.net/def/crs/EPSG/0/4326",
"band_metadata": [
[
"b1",
{}
]
],
"band_descriptions": [
[
"b1",
"value"
]
],
"band_metadata": [["b1", {}]],
"band_descriptions": [["b1", "0"]],
"dtype": "float64",
"nodata_type": "Nodata",
"name": "value",
"count": 1,
"width": 250,
"height": 250,
"attrs": {}
"attrs": {},
"dimensions": ["y", "x"]
}
15 changes: 3 additions & 12 deletions tests/fixtures/responses/pyramid_zarr_tilejson.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,10 @@
"version": "1.0.0",
"scheme": "xyz",
"tiles": [
"http://testserver/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?url=tests%2Ffixtures%2Fpyramid.zarr&variable=value&decode_times=false&group=2"
"http://testserver/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?url=tests%2Ffixtures%2Fpyramid.zarr&variable=value&decode_times=false&group=2&sel=time%3D0"
],
"minzoom": 0,
"maxzoom": 0,
"bounds": [
-180.0,
-90.0,
180.0,
90.0
],
"center": [
0.0,
0.0,
0
]
"bounds": [-180.0, -90.0, 180.0, 90.0],
"center": [0.0, 0.0, 0]
}
19 changes: 5 additions & 14 deletions tests/fixtures/responses/test_zarr_store_zarr_info.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
{
"bounds": [-180, -90.0, 180.0, 90.0],
"bounds": [-180.0, -90.0, 180.0, 90.0],
"crs": "http://www.opengis.net/def/crs/EPSG/0/4326",
"band_metadata": [
[
"b1",
{}
]
],
"band_descriptions": [
[
"b1",
"value"
]
],
"band_metadata": [["b1", {}]],
"band_descriptions": [["b1", "0"]],
"dtype": "uint8",
"nodata_type": "None",
"name": "CDD0",
"count": 1,
"width": 72,
"height": 36,
"attrs": {}
"attrs": {},
"dimensions": ["y", "x"]
}
15 changes: 3 additions & 12 deletions tests/fixtures/responses/test_zarr_store_zarr_tilejson.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,10 @@
"version": "1.0.0",
"scheme": "xyz",
"tiles": [
"http://testserver/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?url=tests%2Ffixtures%2Ftest_zarr_store.zarr&variable=CDD0&decode_times=false"
"http://testserver/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?url=tests%2Ffixtures%2Ftest_zarr_store.zarr&variable=CDD0&decode_times=false&sel=time%3D0"
],
"minzoom": 0,
"maxzoom": 0,
"bounds": [
-180.0,
-90.0,
180.0,
90.0
],
"center": [
0.0,
0.0,
0
]
"bounds": [-180.0, -90.0, 180.0, 90.0],
"center": [0.0, 0.0, 0]
}
24 changes: 5 additions & 19 deletions tests/fixtures/responses/testfile_nc_info.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
{
"bounds": [
-180.0,
-90.0,
180.0,
90.0
],
"bounds": [-180.0, -90.0, 180.0, 90.0],
"crs": "http://www.opengis.net/def/crs/EPSG/0/4326",
"band_metadata": [
[
"b1",
{}
]
],
"band_descriptions": [
[
"b1",
"value"
]
],
"band_metadata": [["b1", {}]],
"band_descriptions": [["b1", "0.0"]],
"dtype": "float32",
"nodata_type": "None",
"name": "data",
"count": 1,
"width": 360,
"height": 180,
"attrs": {}
"attrs": {},
"dimensions": ["y", "x"]
}
18 changes: 5 additions & 13 deletions tests/fixtures/responses/testfile_nc_tilejson.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,11 @@
"version": "1.0.0",
"scheme": "xyz",
"tiles": [
"http://testserver/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?url=tests%2Ffixtures%2Ftestfile.nc&variable=data&decode_times=false"
"http://testserver/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?url=tests%2Ffixtures%2Ftestfile.nc&variable=data&decode_times=false&sel=time%3D0"
],
"minzoom": 0,
"maxzoom": 0,
"bounds": [
-180.0,
-90.0,
180.0,
90.0
],
"center": [
0.0,
0.0,
0
]
}
"bounds": [-180.0, -90.0, 180.0, 90.0],
"center": [0.0, 0.0, 0]
}

24 changes: 5 additions & 19 deletions tests/fixtures/responses/unconsolidated_zarr_info.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
{
"bounds": [
-180.0,
-90.0,
180.0,
90.0
],
"bounds": [-180.0, -90.0, 180.0, 90.0],
"crs": "http://www.opengis.net/def/crs/EPSG/0/4326",
"band_metadata": [
[
"b1",
{}
]
],
"band_descriptions": [
[
"b1",
"value"
]
],
"band_metadata": [["b1", {}]],
"band_descriptions": [["b1", "0"]],
"dtype": "float64",
"nodata_type": "Nodata",
"name": "var1",
"count": 1,
"width": 180,
"height": 90,
"attrs": {}
"attrs": {},
"dimensions": ["y", "x"]
}
15 changes: 3 additions & 12 deletions tests/fixtures/responses/unconsolidated_zarr_tilejson.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,10 @@
"version": "1.0.0",
"scheme": "xyz",
"tiles": [
"http://testserver/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?url=tests%2Ffixtures%2Funconsolidated.zarr&variable=var1&decode_times=false"
"http://testserver/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?url=tests%2Ffixtures%2Funconsolidated.zarr&variable=var1&decode_times=false&sel=time%3D0"
],
"minzoom": 0,
"maxzoom": 0,
"bounds": [
-180.0,
-90.0,
180.0,
90.0
],
"center": [
0.0,
0.0,
0
]
"bounds": [-180.0, -90.0, 180.0, 90.0],
"center": [0.0, 0.0, 0]
}
Loading
Loading