Skip to content

Commit d799d58

Browse files
committed
update titiler and python 3.12
1 parent 294c74f commit d799d58

File tree

7 files changed

+79
-62
lines changed

7 files changed

+79
-62
lines changed

.flake8

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,24 @@ on:
88
- '*'
99
pull_request:
1010
env:
11-
LATEST_PY_VERSION: '3.10'
11+
LATEST_PY_VERSION: '3.12'
1212

1313
jobs:
1414
tests:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version: ['3.8', '3.9', '3.10', '3.11']
18+
python-version:
19+
- '3.8'
20+
- '3.9'
21+
- '3.10'
22+
- '3.11'
23+
- '3.12'
1924

2025
steps:
21-
- uses: actions/checkout@v2
26+
- uses: actions/checkout@v4
2227
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v2
28+
uses: actions/setup-python@v5
2429
with:
2530
python-version: ${{ matrix.python-version }}
2631

@@ -52,34 +57,38 @@ jobs:
5257
runs-on: ubuntu-latest
5358
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
5459
steps:
55-
- uses: actions/checkout@v2
60+
- uses: actions/checkout@v4
5661
- name: Set up Python
57-
uses: actions/setup-python@v1
62+
uses: actions/setup-python@v5
5863
with:
5964
python-version: ${{ env.LATEST_PY_VERSION }}
6065

6166
- name: Install dependencies
6267
run: |
6368
python -m pip install --upgrade pip
64-
python -m pip install flit
65-
python -m pip install .
69+
python -m pip install hatch
70+
python -m hatch build
6671
6772
- name: Set tag version
6873
id: tag
69-
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
70-
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
74+
run: |
75+
echo "version=${GITHUB_REF#refs/*/}"
76+
echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
7177
7278
- name: Set module version
7379
id: module
74-
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
75-
run: echo ::set-output name=version::$(python -c 'from importlib.metadata import version; print(version("rio_viz"))')
80+
run: |
81+
hatch --quiet version
82+
echo "version=$(hatch --quiet version)" >> $GITHUB_OUTPUT
7683
7784
- name: Build and publish
78-
if: steps.tag.outputs.tag == steps.module.outputs.version
85+
if: ${{ steps.tag.outputs.version }} == ${{ steps.module.outputs.version}}
7986
env:
80-
FLIT_USERNAME: ${{ secrets.PYPI_USERNAME }}
81-
FLIT_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
82-
run: flit publish
87+
HATCH_INDEX_USER: ${{ secrets.PYPI_USERNAME }}
88+
HATCH_INDEX_AUTH: ${{ secrets.PYPI_PASSWORD }}
89+
run: |
90+
python -m hatch publish
91+
8392
8493
publish-docker:
8594
needs: [tests]
@@ -104,8 +113,9 @@ jobs:
104113

105114
- name: Set tag version
106115
id: tag
107-
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
108-
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
116+
run: |
117+
echo "version=${GITHUB_REF#refs/*/}"
118+
echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
109119
110120
# Push `latest` when commiting to main
111121
- name: Build and push

.pre-commit-config.yaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,21 @@ repos:
44
hooks:
55
- id: validate-pyproject
66

7-
- repo: https://github.com/psf/black
8-
rev: 22.12.0
9-
hooks:
10-
- id: black
11-
language_version: python
12-
137
- repo: https://github.com/PyCQA/isort
14-
rev: 5.12.0
8+
rev: 5.13.2
159
hooks:
1610
- id: isort
1711
language_version: python
1812

19-
- repo: https://github.com/charliermarsh/ruff-pre-commit
20-
rev: v0.0.238
13+
- repo: https://github.com/astral-sh/ruff-pre-commit
14+
rev: v0.3.5
2115
hooks:
2216
- id: ruff
2317
args: ["--fix"]
18+
- id: ruff-format
2419

2520
- repo: https://github.com/pre-commit/mirrors-mypy
26-
rev: v1.3.0
21+
rev: v1.9.0
2722
hooks:
2823
- id: mypy
2924
language_version: python

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 0.12.2 (2024-04-24)
2+
3+
* update titiler dependency to `>=0.16,<0.19`
4+
* add python 3.12 official support
5+
* change code formatter to `ruff-format`
6+
* switch to Hatch
7+
18
# 0.12.1 (2024-01-12)
29

310
* fix invalid nodata overwriting

pyproject.toml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ classifiers = [
1515
"Programming Language :: Python :: 3.9",
1616
"Programming Language :: Python :: 3.10",
1717
"Programming Language :: Python :: 3.11",
18+
"Programming Language :: Python :: 3.12",
1819
"Topic :: Scientific/Engineering :: GIS",
1920
]
2021
dynamic = ["version"]
2122
dependencies = [
2223
"braceexpand",
2324
"rio-cogeo>=5.0",
24-
"titiler.core>=0.16.0,<0.17",
25+
"titiler.core>=0.16.0,<0.19",
2526
"starlette-cramjam>=0.3,<0.4",
2627
"uvicorn",
2728
"server-thread>=0.2.0",
@@ -48,19 +49,25 @@ Source = "https://github.com/developmentseed/rio-viz"
4849
viz = "rio_viz.scripts.cli:viz"
4950

5051
[build-system]
51-
requires = ["flit>=3.2,<4"]
52-
build-backend = "flit_core.buildapi"
52+
requires = ["hatchling"]
53+
build-backend = "hatchling.build"
5354

54-
[tool.flit.module]
55-
name = "rio_viz"
55+
[tool.hatch.version]
56+
path = "rio_viz/__init__.py"
5657

57-
[tool.flit.sdist]
58+
[tool.hatch.build.targets.sdist]
5859
exclude = [
59-
"tests/",
60-
"docs/",
61-
".github/",
62-
"CHANGES.md",
63-
"CONTRIBUTING.md",
60+
"/tests",
61+
".ruff_cache/",
62+
"examples/",
63+
".github",
64+
".history",
65+
".bumpversion.cfg",
66+
".gitignore",
67+
"Dockerfile",
68+
".pre-commit-config.yaml",
69+
"CHANGES.md",
70+
"CONTRIBUTING.md",
6471
]
6572

6673
[tool.isort]
@@ -74,15 +81,23 @@ default_section = "THIRDPARTY"
7481
no_strict_optional = true
7582

7683
[tool.ruff]
84+
line-length = 90
85+
86+
[tool.ruff.lint]
7787
select = [
7888
"D1", # pydocstyle errors
7989
"E", # pycodestyle errors
8090
"W", # pycodestyle warnings
91+
"F", # flake8
8192
"C", # flake8-comprehensions
8293
"B", # flake8-bugbear
8394
]
8495
ignore = [
8596
"E501", # line too long, handled by black
8697
"B008", # do not perform function calls in argument defaults
8798
"B905", # ignore zip() without an explicit strict= parameter, only support with python >3.10
99+
"B028",
88100
]
101+
102+
[tool.ruff.lint.mccabe]
103+
max-complexity = 12

rio_viz/app.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""rio_viz app."""
22

3-
import pathlib
43
import urllib.parse
54
from typing import Any, Dict, List, Literal, Optional, Tuple, Type, Union
65

@@ -68,9 +67,9 @@ class viz:
6867
"""Creates a very minimal slippy map tile server using fastAPI + Uvicorn."""
6968

7069
src_path: str = attr.ib()
71-
reader: Union[
72-
Type[BaseReader], Type[MultiBandReader], Type[MultiBaseReader]
73-
] = attr.ib(default=Reader)
70+
reader: Union[Type[BaseReader], Type[MultiBandReader], Type[MultiBaseReader]] = (
71+
attr.ib(default=Reader)
72+
)
7473

7574
app: FastAPI = attr.ib(default=attr.Factory(FastAPI))
7675

@@ -616,9 +615,7 @@ def tilejson(
616615

617616
with self.reader(self.src_path) as src_dst: # type: ignore
618617
bounds = (
619-
self.bounds
620-
if self.bounds is not None
621-
else src_dst.geographic_bounds
618+
self.bounds if self.bounds is not None else src_dst.geographic_bounds
622619
)
623620
minzoom = self.minzoom if self.minzoom is not None else src_dst.minzoom
624621
maxzoom = self.maxzoom if self.maxzoom is not None else src_dst.maxzoom
@@ -678,9 +675,7 @@ def wmts(
678675

679676
with self.reader(self.src_path) as src_dst: # type: ignore
680677
bounds = (
681-
self.bounds
682-
if self.bounds is not None
683-
else src_dst.geographic_bounds
678+
self.bounds if self.bounds is not None else src_dst.geographic_bounds
684679
)
685680
minzoom = self.minzoom if self.minzoom is not None else src_dst.minzoom
686681
maxzoom = self.maxzoom if self.maxzoom is not None else src_dst.maxzoom
@@ -699,9 +694,9 @@ def wmts(
699694
tileMatrix.append(tm)
700695

701696
return templates.TemplateResponse(
702-
"wmts.xml",
703-
{
704-
"request": request,
697+
request,
698+
name="wmts.xml",
699+
context={
705700
"tiles_endpoint": tiles_endpoint,
706701
"bounds": bounds,
707702
"tileMatrix": tileMatrix,
@@ -738,9 +733,9 @@ def map_viewer(
738733
tilejson_url += f"?{request.query_params}"
739734

740735
return templates.TemplateResponse(
736+
request,
741737
name="map.html",
742738
context={
743-
"request": request,
744739
"tilejson_endpoint": tilejson_url,
745740
},
746741
media_type="text/html",
@@ -768,9 +763,9 @@ def viewer(request: Request):
768763
name = "assets.html"
769764

770765
return templates.TemplateResponse(
766+
request,
771767
name=name,
772768
context={
773-
"request": request,
774769
"tilejson_endpoint": str(request.url_for("tilejson")),
775770
"stats_endpoint": str(request.url_for("statistics")),
776771
"info_endpoint": str(request.url_for("info")),

rio_viz/io/mosaic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ def point(
101101
def _reader(asset: str, lon: float, lat: float, **kwargs) -> PointData:
102102
return self.datasets[asset].point(lon, lat, **kwargs)
103103

104-
return mosaic_point_reader(
105-
mosaic_assets, _reader, lon, lat, threads=0, **kwargs
106-
)[0]
104+
return mosaic_point_reader(mosaic_assets, _reader, lon, lat, threads=0, **kwargs)[
105+
0
106+
]
107107

108108
def info(self) -> Info:
109109
"""info."""

0 commit comments

Comments
 (0)