Skip to content

Commit 465018a

Browse files
authored
Support icechunk (#101)
1 parent 31c20aa commit 465018a

File tree

629 files changed

+3466
-1410
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

629 files changed

+3466
-1410
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ jobs:
4949
- name: run pre-commit
5050
if: ${{ matrix.python-version == env.LATEST_PY_VERSION }}
5151
run: |
52-
uv run pre-commit run --all-files
52+
uv run pre-commit run --all-files --verbose --show-diff-on-failure
5353
5454
- name: Run tests
55-
run: uv run pytest
55+
run: uv run pytest -n auto
5656

5757
cdk-checks:
5858
needs: [tests]

.github/workflows/deploy-dev.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ jobs:
3131
TITILER_MULTIDIM_PYTHONWARNINGS: ignore
3232
TITILER_MULTIDIM_DEBUG: true
3333
TITILER_MULTIDIM_READER_ROLE_ARN: ${{ vars.TITILER_MULTIDIM_READER_ROLE_ARN }}
34+
TITILER_MULTIDIM_AUTHORIZED_CHUNK_ACCESS: '{"s3://nasa-waterinsight/NLDAS3/forcing/daily/": {"anonymous": true}, "s3://podaac-ops-cumulus-protected/MUR-JPL-L4-GLOB-v4.1/": {"from_env": true}, "s3://nasa-waterinsight/RASI/": {"anonymous": true}}'
35+
3436

3537
steps:
3638
- name: Determine branch to deploy

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,7 @@ cdk.out/
105105
node_modules
106106
cdk.context.json
107107
*.nc
108+
.DS_Store
108109

109110
.test-deploy-env
111+
.vscode/settings.json

.pre-commit-config.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ repos:
99
hooks:
1010
- id: ruff
1111
args: ["--fix"]
12+
exclude: ^notebooks/
1213
- id: ruff-format
14+
exclude: ^notebooks/
1315

1416
- repo: https://github.com/pre-commit/mirrors-mypy
15-
rev: v0.991
17+
rev: v1.13.0
1618
hooks:
1719
- id: mypy
18-
language_version: python
20+
language_version: python3.12
1921
exclude: tests/.*
2022
additional_dependencies:
2123
- types-attrs
24+
- types-redis
25+
- types-requests
26+
- boto3-stubs
27+
- types-aiobotocore

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Example of application built with `titiler.xarray` [package](https://development
1414
# It's recommended to install dependencies in a virtual environment
1515
uv sync --dev
1616
export TEST_ENVIRONMENT=true # set this when running locally to mock redis
17+
#optional: Disable caching
18+
#export TITILER_MULTIDIM_ENABLE_CACHE=false
1719
uv run uvicorn titiler.multidim.main:app --reload
1820
```
1921

@@ -94,3 +96,4 @@ The following steps detail how to to setup and deploy the CDK stack from your lo
9496

9597
In AWS Lambda environment we need to have specific version of botocore, S3FS, FSPEC and other libraries.
9698
To make sure the application will both work locally and in AWS Lambda environment you can install the dependencies using `python -m pip install -r infrastructure/aws/requirement-lambda.txt`
99+

infrastructure/aws/cdk/config.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,20 @@ class AppSettings(BaseSettings):
9696
description="Optional root path for all api endpoints",
9797
)
9898

99+
# Authorization config for icechunk virtual chunks
100+
# This will be passed through to the Lambda as an environment variable
101+
authorized_chunk_access: Optional[str] = Field(
102+
None,
103+
description="JSON string for authorizing virtual chunk access in icechunk datasets",
104+
)
105+
106+
def model_post_init(self, __context):
107+
"""Add authorized_chunk_access to additional_env if set."""
108+
if self.authorized_chunk_access:
109+
self.additional_env["TITILER_MULTIDIM_AUTHORIZED_CHUNK_ACCESS"] = (
110+
self.authorized_chunk_access
111+
)
112+
99113
class Config:
100114
"""model config"""
101115

infrastructure/aws/lambda/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ EOF
1515
FROM public.ecr.aws/lambda/python:${PYTHON_VERSION} AS builder
1616
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
1717

18-
RUN dnf install -y gcc-c++ && dnf clean all
18+
RUN dnf install -y gcc-c++ git && dnf clean all
1919

2020
WORKDIR /build
2121

pyproject.toml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ classifiers = [
2525
]
2626
dynamic = ["version"]
2727
dependencies = [
28-
"titiler.core>=0.23.0,<0.24",
29-
"titiler.xarray>=0.23.0,<0.24",
28+
"titiler-core>=0.25.0,<0.26",
29+
"titiler-xarray>=0.25.0,<0.26",
3030
"aiohttp",
3131
"aiobotocore>=2.24.0",
3232
"boto3>=1.39.0",
@@ -41,8 +41,9 @@ dependencies = [
4141
"requests",
4242
"rioxarray",
4343
"s3fs",
44-
"xarray",
45-
"zarr>=2,<3",
44+
"xarray>=2025.10.1",
45+
"zarr>3.1.0",
46+
"icechunk>=1.1.9",
4647
]
4748

4849
[project.optional-dependencies]
@@ -56,6 +57,7 @@ lambda = [
5657

5758
[dependency-groups]
5859
dev = [
60+
"dask>=2025.9.1",
5961
"fakeredis>=2.23.5",
6062
"httpx",
6163
"ipykernel>=6.30.1",
@@ -65,15 +67,23 @@ dev = [
6567
"pytest-asyncio>=0.24.0",
6668
"pytest-cov>=5.0.0",
6769
"pytest>=8.3.2",
70+
"pytest-xdist",
6871
"uvicorn>=0.34.0",
6972
"yappi>=1.6.0",
73+
"virtualizarr",
74+
"obstore",
7075
]
7176
deployment = [
7277
"aws-cdk-lib~=2.177.0",
7378
"constructs>=10.4.2",
7479
"pydantic-settings~=2.0",
7580
"python-dotenv>=1.0.1",
7681
]
82+
notebooks = [
83+
"folium",
84+
"httpx",
85+
"matplotlib",
86+
]
7787

7888
[project.urls]
7989
Homepage = "https://github.com/developmentseed/titiler-multidim"
@@ -97,6 +107,8 @@ known_first_party = ["titiler"]
97107
default_section = "THIRDPARTY"
98108

99109
[tool.ruff]
110+
111+
[tool.ruff.lint]
100112
select = [
101113
"D1", # pydocstyle errors
102114
"E", # pycodestyle errors
@@ -111,7 +123,7 @@ ignore = [
111123
"B905", # ignore zip() without an explicit strict= parameter, only support with python >3.10
112124
]
113125

114-
[tool.ruff.per-file-ignores]
126+
[tool.ruff.lint.per-file-ignores]
115127
"tests/test_app.py" = ["D1"]
116128
"tests/fixtures/generate_test_zarr.py" = ["D1"]
117129
"tests/fixtures/generate_test_reference.py" = ["D1"]
@@ -126,8 +138,6 @@ explicit_package_bases = true
126138
requires = ["pdm-backend"]
127139
build-backend = "pdm.backend"
128140

129-
130-
131141
[tool.pdm.version]
132142
source = "file"
133143
path = "src/titiler/multidim/__init__.py"
@@ -142,3 +152,4 @@ excludes = ["tests/", "**/.mypy_cache", "**/.DS_Store"]
142152

143153
[tool.pytest.ini_options]
144154
addopts = "--cov=titiler.multidim --cov-report term-missing -s -vv"
155+
pythonpath = ["src", "tests"]

src/titiler/multidim/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
app.add_middleware(
9191
ServerTimingMiddleware,
9292
calls_to_track={
93-
"1-xarray-open_dataset": (reader.xarray_open_dataset,),
93+
"1-xarray-open_dataset": (reader.guess_opener,),
9494
"2-rioxarray-reproject": (rioxarray.raster_array.RasterArray.reproject,),
9595
},
9696
)

0 commit comments

Comments
 (0)