Tiles router for xpublish
Project description
xpublish-tiles
Web mapping plugins for Xpublish
Project Overview
This project contains a set of web mapping plugins for Xpublish - a framework for serving xarray datasets via HTTP APIs.
The goal of this project is to transform xarray datasets to raster, vector and other types of tiles, which can then be served via HTTP APIs. To do this, the package implements a set of xpublish plugins:
xpublish_tiles.xpublish.tiles.TilesPlugin: An OGC Tiles conformant plugin for serving raster, vector and other types of tiles.xpublish_tiles.xpublish.wms.WMSPlugin: An OGC Web Map Service conformant plugin for serving raster, vector and other types of tiles.
Development
Sync the environment with uv
uv sync
Run the type checker
uv run ty check
Run the tests
uv run pytest tests
Run setup tests (create local datasets, these can be deployed using the CLI)
uv run pytest --setup
CLI Usage
The package includes a command-line interface for quickly serving datasets with tiles and WMS endpoints:
uv run xpublish-tiles [OPTIONS]
Options
--port PORT: Port to serve on (default: 8080)--dataset DATASET: Dataset to serve (default: global)global: Generated global dataset with synthetic dataair: Tutorial air temperature dataset from xarray tutorialhrrr: High-Resolution Rapid Refresh datasetpara: Parameterized dataseteu3035: European dataset in ETRS89 / LAEA Europe projectioneu3035_hires: High-resolution European datasetifs: Integrated Forecasting System datasetcurvilinear: Curvilinear coordinate datasetsentinel: Sentinel-2 dataset (without coordinates)global-6km: Global dataset at 6km resolutionxarray://<tutorial_name>: Load any xarray tutorial dataset (e.g.,xarray://rasm)local://<dataset_name>: Load dataset from local icechunk repository at/tmp/tiles-icechunk/(datasets created withuv run pytest --setup)local:///path/to/repo::<dataset_name>: Load dataset from custom icechunk repository path- For Arraylake datasets: specify the dataset name in {arraylake_org}/{arraylake_dataset} format (requires Arraylake credentials)
--branch BRANCH: Branch to use for Arraylake or icechunk datasets (default: main)--group GROUP: Group to use for Arraylake datasets (default: '')--cache: Enable icechunk cache for Arraylake and local icechunk datasets (default: enabled)--spy: Run benchmark requests with the specified dataset for performance testing--concurrency INT: Number of concurrent requests for benchmarking (default: 12)--where CHOICE: Where to run benchmark requests (choices: local, local-booth, prod; default: local)local: Start server on localhost and run benchmarks against itlocal-booth: Run benchmarks against existing localhost server (no server startup)prod: Run benchmarks against production server
--log-level LEVEL: Set the logging level for xpublish_tiles (choices: debug, info, warning, error; default: warning)
[!TIP] To use local datasets (e.g.,
local://ifs,local://para_hires), first create them withuv run pytest --setup. This creates icechunk repositories at/tmp/tiles-icechunk/.
Examples
# Serve synthetic global dataset on default port 8080
xpublish-tiles
# Serve air temperature tutorial dataset on port 9000
xpublish-tiles --port 9000 --dataset air
# Serve built-in test datasets
xpublish-tiles --dataset hrrr
xpublish-tiles --dataset para
xpublish-tiles --dataset eu3035_hires
# Load xarray tutorial datasets
xpublish-tiles --dataset xarray://rasm
xpublish-tiles --dataset xarray://ersstv5
# Serve locally stored datasets (first create them with `uv run pytest --setup`)
xpublish-tiles --dataset local://ifs
xpublish-tiles --dataset local://para_hires
# Serve local icechunk data from custom path
xpublish-tiles --dataset local:///path/to/my/repo::my_dataset
# Serve Arraylake dataset with specific branch and group
xpublish-tiles --dataset earthmover-public/aifs-outputs --branch main --group 2025-04-01/12z
# Run benchmark with a specific dataset
xpublish-tiles --dataset local://para_hires --spy
# Run benchmark with custom concurrency and against production
xpublish-tiles --dataset para --spy --concurrency 20 --where prod
# Enable debug logging
xpublish-tiles --dataset hrrr --log-level debug
Benchmarking
The CLI includes a benchmarking feature that can be used to test tile server performance:
# Run benchmark with a specific dataset (starts server automatically)
xpublish-tiles --dataset local://para_hires --spy
# Run benchmark against existing localhost server
xpublish-tiles --dataset para --spy --where local-booth
# Run benchmark against production server with custom concurrency
xpublish-tiles --dataset para --spy --where prod --concurrency 8
The --spy flag enables benchmarking mode. The benchmarking behavior depends on the --where option:
--where local(default): Starts the tile server and automatically runs benchmark requests against it--where local-booth: Runs benchmarks against an existing localhost server (doesn't start a new server)--where prod: Runs benchmarks against a production server
The benchmarking process:
- Warms up the server with initial tile requests
- Makes concurrent tile requests (configurable with
--concurrency, default: 12) to test performance - Uses dataset-specific benchmark tiles or falls back to global tiles
- Automatically exits after completing the benchmark run
- Uses appropriate colorscale ranges based on dataset attributes
Once running, the server provides:
- Tiles API at
http://localhost:8080/tiles/ - WMS API at
http://localhost:8080/wms/ - Interactive API documentation at
http://localhost:8080/docs
An example tile url:
http://localhost:8080/tiles/WebMercatorQuad/4/4/14?variables=2t&style=raster/viridis&colorscalerange=280,300&width=256&height=256&valid_time=2025-04-03T06:00:00
Where 4/4/14 represents the tile coordinates in {z}/{y}/{x}
Integration Examples
Deployment notes
- Make sure to limit
NUMBA_NUM_THREADS; this is used for rendering categorical data with datashader. - The first invocation of a render will block while datashader functions are JIT-compiled. Our attempts to add a precompilation step to remove this have been unsuccessful.
Environment variables
XPUBLISH_TILES_ASYNC_LOAD: [0, 1]- controls whether Xarray's async loading is used.XPUBLISH_TILES_NUM_THREADS: int- controls the size of the threadpoolXPUBLISH_TILES_TRANSFORM_CHUNK_SIZE: int- when transforming coordinates, do so by submitting (NxN) chunks to the threadpool.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xpublish_tiles-0.1.14.tar.gz.
File metadata
- Download URL: xpublish_tiles-0.1.14.tar.gz
- Upload date:
- Size: 4.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23ffd1e2b9cbfff58795a65e42420c73d9db5d18e3d98ddb73fef794588e8b0d
|
|
| MD5 |
ec0ddf53bee5064903fc5955ba5d60d6
|
|
| BLAKE2b-256 |
c011bdef719a48139856f17a5dfa1136c97b67cedb30ec1b598d72e1e9ac0c52
|
Provenance
The following attestation bundles were made for xpublish_tiles-0.1.14.tar.gz:
Publisher:
publish.yml on earth-mover/xpublish-tiles
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xpublish_tiles-0.1.14.tar.gz -
Subject digest:
23ffd1e2b9cbfff58795a65e42420c73d9db5d18e3d98ddb73fef794588e8b0d - Sigstore transparency entry: 450345366
- Sigstore integration time:
-
Permalink:
earth-mover/xpublish-tiles@8ae03eef03026aceafa95f189f32b5940db7ad8e -
Branch / Tag:
refs/tags/0.1.14 - Owner: https://github.com/earth-mover
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8ae03eef03026aceafa95f189f32b5940db7ad8e -
Trigger Event:
push
-
Statement type:
File details
Details for the file xpublish_tiles-0.1.14-py3-none-any.whl.
File metadata
- Download URL: xpublish_tiles-0.1.14-py3-none-any.whl
- Upload date:
- Size: 81.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
baff4ee69c0a38b7a67f56d344b1a36a3a78451ad65c4efa5cfd25a19a8b8515
|
|
| MD5 |
ea625cae21154c7b68f3d6ad83783711
|
|
| BLAKE2b-256 |
286010cc8e9f30b5bed9c2a2dea3af4fafa3ffeb0e834df528e6a7276d1214f6
|
Provenance
The following attestation bundles were made for xpublish_tiles-0.1.14-py3-none-any.whl:
Publisher:
publish.yml on earth-mover/xpublish-tiles
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xpublish_tiles-0.1.14-py3-none-any.whl -
Subject digest:
baff4ee69c0a38b7a67f56d344b1a36a3a78451ad65c4efa5cfd25a19a8b8515 - Sigstore transparency entry: 450345379
- Sigstore integration time:
-
Permalink:
earth-mover/xpublish-tiles@8ae03eef03026aceafa95f189f32b5940db7ad8e -
Branch / Tag:
refs/tags/0.1.14 - Owner: https://github.com/earth-mover
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8ae03eef03026aceafa95f189f32b5940db7ad8e -
Trigger Event:
push
-
Statement type: