Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
python-version: ['3.11', '3.12', '3.13']
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because titiler.xarray cannot support 3.10, it's just easier to also switch all package to >=3.11


steps:
- uses: actions/checkout@v5
Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ uv run pytest src/titiler/extensions --cov=titiler.extensions --cov-report=xml -
# titiler.mosaic
uv run pytest src/titiler/mosaic --cov=titiler.mosaic --cov-report=xml --cov-append --cov-report=term-missing

# titiler.xarray
uv run pytest src/titiler/xarray --cov=titiler.xarray --cov-report=xml --cov-append --cov-report=term-missing

# titiler.application
uv run pytest src/titiler/application --cov=titiler.application --cov-report=xml --cov-append --cov-report=term-missing
```
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ dev = [
"pytest-cov",
"pytest-asyncio",
"httpx",
"zarr!=3.0.9",
"obstore",
"zarr>=3,<4.0",
"h5netcdf",
"fsspec",
"s3fs",
Expand Down
3 changes: 1 addition & 2 deletions src/titiler/application/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "titiler-application"
description = "A modern dynamic tile server built on top of FastAPI and Rasterio/GDAL."
readme = "README.md"
requires-python = ">=3.10"
requires-python = ">=3.11"
authors = [
{name = "Vincent Sarago", email = "[email protected]"},
]
Expand All @@ -22,7 +22,6 @@ classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
Expand Down
3 changes: 1 addition & 2 deletions src/titiler/core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "titiler-core"
description = "A modern dynamic tile server built on top of FastAPI and Rasterio/GDAL."
readme = "README.md"
requires-python = ">=3.10"
requires-python = ">=3.11"
authors = [
{name = "Vincent Sarago", email = "[email protected]"},
]
Expand All @@ -22,7 +22,6 @@ classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
Expand Down
3 changes: 1 addition & 2 deletions src/titiler/extensions/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "titiler-extensions"
description = "Extensions for TiTiler Factories."
readme = "README.md"
requires-python = ">=3.10"
requires-python = ">=3.11"
authors = [
{name = "Vincent Sarago", email = "[email protected]"},
]
Expand All @@ -22,7 +22,6 @@ classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
Expand Down
3 changes: 1 addition & 2 deletions src/titiler/mosaic/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "titiler-mosaic"
description = "cogeo-mosaic (MosaicJSON) plugin for TiTiler."
readme = "README.md"
requires-python = ">=3.10"
requires-python = ">=3.11"
authors = [
{name = "Vincent Sarago", email = "[email protected]"},
]
Expand All @@ -22,7 +22,6 @@ classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
Expand Down
42 changes: 0 additions & 42 deletions src/titiler/xarray/examples/templates/landing.html

This file was deleted.

22 changes: 5 additions & 17 deletions src/titiler/xarray/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,38 +36,26 @@ dependencies = [
"rio-tiler>=7.6.1,<8.0",
"xarray",
"rioxarray",
"obstore",
"zarr>=3.0,<4.0",
]

[project.optional-dependencies]
full = [
"zarr!=3.0.9",
fs = [
"h5netcdf",
"fsspec",
"s3fs",
"aiohttp",
"gcsfs",
"requests",
]
minimal = [
"zarr!=3.0.9",
"h5netcdf",
"fsspec",
]
gcs = [
"gcsfs",
]
s3 = [
"s3fs",
]
http = [
"aiohttp",
]

[dependency-groups]
test = [
"pytest",
"pytest-cov",
"pytest-asyncio",
"httpx",
"zarr!=3.0.9",
"h5netcdf",
"fsspec",
"s3fs",
Expand Down
150 changes: 148 additions & 2 deletions src/titiler/xarray/tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from titiler.xarray.extensions import DatasetMetadataExtension, VariablesExtension
from titiler.xarray.factory import TilerFactory
from titiler.xarray.io import FsReader, fs_open_dataset

prefix = os.path.join(os.path.dirname(__file__), "fixtures")

Expand Down Expand Up @@ -61,7 +62,30 @@ def test_tiler_factory():
@pytest.fixture
def app():
"""App fixture."""
md = TilerFactory(router_prefix="/md", extensions=[DatasetMetadataExtension()])
md = TilerFactory(
router_prefix="/md",
extensions=[
DatasetMetadataExtension(dataset_opener=fs_open_dataset),
],
reader=FsReader,
)
assert len(md.router.routes) == 22

app = FastAPI()
app.include_router(md.router, prefix="/md")
with TestClient(app) as client:
yield client


@pytest.fixture
def app_zarr():
"""App fixture."""
md = TilerFactory(
router_prefix="/md",
extensions=[
DatasetMetadataExtension(),
],
)
assert len(md.router.routes) == 22

app = FastAPI()
Expand Down Expand Up @@ -393,7 +417,7 @@ def test_zarr_group(group, app):
def test_preview(filename):
"""App fixture."""
with pytest.warns(UserWarning):
md = TilerFactory(add_preview=True)
md = TilerFactory(add_preview=True, reader=FsReader)

app = FastAPI()
app.include_router(md.router)
Expand Down Expand Up @@ -437,3 +461,125 @@ def test_preview(filename):
with mem.open() as dst:
assert dst.width == 1024
assert dst.height == 1024


@pytest.mark.parametrize(
"filename",
[dataset_3d_zarr],
)
def test_app_zarr(filename, app_zarr):
"""Test endpoints with Zarr Reader."""
resp = app_zarr.get("/md/dataset/keys", params={"url": filename})
assert resp.status_code == 200
assert resp.headers["content-type"] == "application/json"
assert resp.json() == ["dataset"]

resp = app_zarr.get("/md/dataset/dict", params={"url": filename})
assert resp.status_code == 200
assert resp.headers["content-type"] == "application/json"
assert resp.json()["data_vars"]["dataset"]

resp = app_zarr.get("/md/dataset/", params={"url": filename})
assert resp.status_code == 200
assert "text/html" in resp.headers["content-type"]

resp = app_zarr.get("/md/bounds", params={"url": filename, "variable": "dataset"})
assert resp.status_code == 200
assert resp.headers["content-type"] == "application/json"

resp = app_zarr.get("/md/info", params={"url": filename, "variable": "dataset"})
assert resp.status_code == 200
assert resp.headers["content-type"] == "application/json"

resp = app_zarr.get(
"/md/tiles/WebMercatorQuad/0/0/0",
params={"url": filename, "variable": "dataset", "rescale": "0,500", "bidx": 1},
)
assert resp.status_code == 200
assert resp.headers["content-type"] == "image/png"

resp = app_zarr.get(
"/md/WebMercatorQuad/tilejson.json",
params={"url": filename, "variable": "dataset", "rescale": "0,500", "bidx": 1},
)
assert resp.status_code == 200
assert resp.headers["content-type"] == "application/json"

resp = app_zarr.get(
"/md/point/0,0", params={"url": filename, "variable": "dataset"}
)
assert resp.status_code == 200
assert resp.headers["content-type"] == "application/json"

feat = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
(-100.0, -25.0),
(40.0, -25.0),
(40.0, 60.0),
(-100.0, 60.0),
(-100.0, -25.0),
]
],
},
}

resp = app_zarr.post(
"/md/statistics", params={"url": filename, "variable": "dataset"}, json=feat
)
assert resp.status_code == 200
assert resp.headers["content-type"] == "application/geo+json"

feat = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
(-100.0, -25.0),
(40.0, -25.0),
(40.0, 60.0),
(-100.0, 60.0),
(-100.0, -25.0),
]
],
},
}

resp = app_zarr.post(
"/md/feature",
params={"url": filename, "variable": "dataset", "rescale": "0,500", "bidx": 1},
json=feat,
)
assert resp.status_code == 200
assert resp.headers["content-type"] == "image/jpeg"


@pytest.mark.parametrize(
"group",
[0, 1, 2],
)
def test_group_open_zarr(group, app_zarr):
"""Test /tiles endpoints."""
resp = app_zarr.get(
f"/md/tiles/WebMercatorQuad/{group}/0/0.tif",
params={"url": zarr_pyramid, "variable": "dataset", "group": str(group)},
)
assert resp.status_code == 200
# see src/titiler/xarray/tests/fixtures/generate_fixtures.ipynb
# for structure of zarr pyramid
with MemoryFile(resp.content) as mem:
with mem.open() as dst:
arr = dst.read(1)
assert arr.max() == group * 2 + 1

resp = app_zarr.get(
"/md/point/0,0",
params={"url": zarr_pyramid, "variable": "dataset", "group": str(group)},
)
assert resp.json()["values"] == [group * 2 + 1]
Loading
Loading