Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove python 3.8 and add python 3.13 #208

Merged
merged 5 commits into from
Jan 13, 2025
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
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ on:

pull_request:
env:
LATEST_PY_VERSION: '3.12'
LATEST_PY_VERSION: '3.13'

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- '3.13'

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -66,14 +66,14 @@ jobs:
needs: [tests]
runs-on: ubuntu-latest
env:
PGSTAC_VERSION: '0.9.1'
PGSTAC_VERSION: '0.9.2'
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ env.LATEST_PY_VERSION }}
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: ${{ env.LATEST_PY_VERSION }}
python-version: '3.12'

- name: Launch services
run: docker compose up -d tiler-uvicorn
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy_mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
- name: Checkout main
uses: actions/checkout@v4

- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: 3.12

- name: Install dependencies
run: |
Expand Down
13 changes: 4 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,21 @@ repos:
hooks:
- id: validate-pyproject

- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
language_version: python

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
language_version: python

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.290
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.4
hooks:
- id: ruff
args: ["--fix"]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.11.2
hooks:
- id: mypy
language_version: python
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

* Update namespace package from using `.` to `-` as separator to comply with PEP-625 (https://peps.python.org/pep-0625/)

* Remove `python3.8` support

* Add `python3.13` support

## 1.5.0 (2024-11-28)

* update titiler requirement to `>=0.19.0,<0.20`
Expand Down
1 change: 0 additions & 1 deletion benchmark/create_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def _xy(lon, lat):
with lzma.open(FILENAME, "rt") as fin:
reader = csv.reader(fin, delimiter=" ")
for row in reader:

split = row[0].split("/")
z = int(split[0])
x = int(split[1])
Expand Down
52 changes: 36 additions & 16 deletions docs/src/notebooks/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,23 @@
"bounds = (-87.0251, 36.0999, -85.4249, 36.2251)\n",
"\n",
"poly = Polygon.from_bounds(*bounds)\n",
"geojson = Feature(type=\"Feature\", geometry=poly, properties=None).model_dump(exclude_none=True)\n",
"geojson = Feature(type=\"Feature\", geometry=poly, properties=None).model_dump(\n",
" exclude_none=True\n",
")\n",
"\n",
"m = Map(\n",
" tiles=\"OpenStreetMap\",\n",
" location=((bounds[1] + bounds[3]) / 2,(bounds[0] + bounds[2]) / 2),\n",
" zoom_start=8\n",
" location=((bounds[1] + bounds[3]) / 2, (bounds[0] + bounds[2]) / 2),\n",
" zoom_start=8,\n",
")\n",
"\n",
"geo_json = GeoJson(\n",
" data=geojson,\n",
" style_function=lambda x: {\n",
" 'opacity': 1, 'dashArray': '1', 'fillOpacity': 0, 'weight': 1\n",
" \"opacity\": 1,\n",
" \"dashArray\": \"1\",\n",
" \"fillOpacity\": 0,\n",
" \"weight\": 1,\n",
" },\n",
")\n",
"geo_json.add_to(m)\n",
Expand Down Expand Up @@ -214,7 +219,8 @@
"}\n",
"\n",
"response = httpx.post(\n",
" f\"{endpoint}/searches/register\", json=search_request,\n",
" f\"{endpoint}/searches/register\",\n",
" json=search_request,\n",
").json()\n",
"print(response)\n",
"\n",
Expand Down Expand Up @@ -290,7 +296,7 @@
" (search[\"search\"][\"hash\"], search[\"search\"][\"metadata\"].get(\"name\"))\n",
" for search in response[\"searches\"]\n",
" ],\n",
" indent=4,\n",
" indent=4,\n",
" )\n",
")"
]
Expand Down Expand Up @@ -412,7 +418,9 @@
}
],
"source": [
"tj_response = httpx.get(f\"{endpoint}/searches/{searchid}/WebMercatorQuad/tilejson.json?assets=cog\").json()\n",
"tj_response = httpx.get(\n",
" f\"{endpoint}/searches/{searchid}/WebMercatorQuad/tilejson.json?assets=cog\"\n",
").json()\n",
"print(json.dumps(tj_response, indent=4))"
]
},
Expand Down Expand Up @@ -540,14 +548,16 @@
],
"source": [
"m = Map(\n",
" location=((bounds[1] + bounds[3]) / 2,(bounds[0] + bounds[2]) / 2),\n",
" zoom_start=14\n",
" location=((bounds[1] + bounds[3]) / 2, (bounds[0] + bounds[2]) / 2), zoom_start=14\n",
")\n",
"\n",
"geo_json = GeoJson(\n",
" data=geojson,\n",
" style_function=lambda x: {\n",
" 'opacity': 1, 'dashArray': '1', 'fillOpacity': 0, 'weight': 1\n",
" \"opacity\": 1,\n",
" \"dashArray\": \"1\",\n",
" \"fillOpacity\": 0,\n",
" \"weight\": 1,\n",
" },\n",
")\n",
"geo_json.add_to(m)\n",
Expand Down Expand Up @@ -618,7 +628,12 @@
" \"bbox\": bounds,\n",
" \"filter-lang\": \"cql-json\",\n",
" \"metadata\": {\n",
" \"bounds\": [-87.0251, 36.0999, -85.4249, 36.2251], # This is redondant because it's in the bbox filter\n",
" \"bounds\": [\n",
" -87.0251,\n",
" 36.0999,\n",
" -85.4249,\n",
" 36.2251,\n",
" ], # This is redondant because it's in the bbox filter\n",
" \"minzoom\": 14,\n",
" \"maxzoom\": 18,\n",
" \"assets\": [\"cog\"],\n",
Expand All @@ -631,7 +646,8 @@
"}\n",
"\n",
"response = httpx.post(\n",
" f\"{endpoint}/searches/register\", json=search_request,\n",
" f\"{endpoint}/searches/register\",\n",
" json=search_request,\n",
").json()\n",
"print(json.dumps(response, indent=4))\n",
"\n",
Expand Down Expand Up @@ -673,7 +689,9 @@
}
],
"source": [
"tj_response = httpx.get(f\"{endpoint}/searches/{searchid}/WebMercatorQuad/tilejson.json?assets=cog\").json()\n",
"tj_response = httpx.get(\n",
" f\"{endpoint}/searches/{searchid}/WebMercatorQuad/tilejson.json?assets=cog\"\n",
").json()\n",
"print(json.dumps(tj_response, indent=4))"
]
},
Expand Down Expand Up @@ -792,14 +810,16 @@
],
"source": [
"m = Map(\n",
" location=((bounds[1] + bounds[3]) / 2,(bounds[0] + bounds[2]) / 2),\n",
" zoom_start=14\n",
" location=((bounds[1] + bounds[3]) / 2, (bounds[0] + bounds[2]) / 2), zoom_start=14\n",
")\n",
"\n",
"geo_json = GeoJson(\n",
" data=geojson,\n",
" style_function=lambda x: {\n",
" 'opacity': 1, 'dashArray': '1', 'fillOpacity': 0, 'weight': 1\n",
" \"opacity\": 1,\n",
" \"dashArray\": \"1\",\n",
" \"fillOpacity\": 0,\n",
" \"weight\": 1,\n",
" },\n",
")\n",
"geo_json.add_to(m)\n",
Expand Down
11 changes: 7 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "titiler-pgstac"
description = "Connect PgSTAC and TiTiler."
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9"
license = {file = "LICENSE"}
authors = [
{name = "Vincent Sarago", email = "[email protected]"},
Expand All @@ -20,11 +20,11 @@ classifiers = [
"Intended Audience :: Information Technology",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Scientific/Engineering :: GIS",
]
dependencies = [
Expand Down Expand Up @@ -57,7 +57,7 @@ test = [
"pytest-cov",
"pytest-asyncio",
"httpx",
"pypgstac>=0.7,<=0.9.1",
"pypgstac>=0.7,<=0.10",
"pytest-postgresql",
]
docs = [
Expand Down Expand Up @@ -111,7 +111,7 @@ known_third_party = [
]
default_section = "THIRDPARTY"

[tool.ruff]
[tool.ruff.lint]
select = [
"D1", # pydocstyle errors
"E", # pycodestyle errors
Expand All @@ -125,6 +125,9 @@ ignore = [
"B008", # do not perform function calls in argument defaults
"B905", # ignore zip() without an explicit strict= parameter, only support with python >3.10
]
exclude = [
"*.ipynb"
]

[tool.mypy]
no_implicit_optional = true
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def load_json(filepath: str):
params=[
"0.7.10",
"0.8.5",
"0.9.1",
"0.9.2",
],
scope="session",
)
Expand Down
2 changes: 1 addition & 1 deletion titiler/pgstac/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def SearchIdParams(
search_id: Annotated[
str,
Path(description="PgSTAC Search Identifier (Hash)"),
]
],
) -> str:
"""search_id"""
return search_id
Expand Down
12 changes: 5 additions & 7 deletions titiler/pgstac/factory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Custom MosaicTiler Factory for PgSTAC Mosaic Backend."""

import os
import re
import warnings
Expand Down Expand Up @@ -141,9 +142,9 @@ class MosaicTilerFactory(BaseFactory):
tile_dependency: Type[DefaultDependency] = TileParams

# Post Processing Dependencies (algorithm)
process_dependency: Callable[
..., Optional[BaseAlgorithm]
] = available_algorithms.dependency
process_dependency: Callable[..., Optional[BaseAlgorithm]] = (
available_algorithms.dependency
)

# Image rendering Dependencies
rescale_dependency: Callable[..., Optional[RescaleType]] = RescalingParams
Expand Down Expand Up @@ -1327,7 +1328,6 @@ def register_search(request: Request, search_query=Depends(search_dependency)):

with request.app.state.dbpool.connection() as conn:
with conn.cursor(row_factory=dict_row) as cursor:

try:
cursor.execute("SELECT pgstac.readonly()")
if cursor.fetchone()["readonly"]:
Expand Down Expand Up @@ -1515,9 +1515,7 @@ def list_searches( # noqa: C901
def parse_sort_by(sortby: str) -> Generator[sql.Composable, None, None]:
"""Parse SortBy expression."""
for s in sortby.split(","):
parts = re.match(
"^(?P<dir>[+-]?)(?P<prop>.*)$", s.lstrip()
).groupdict() # type:ignore
parts = re.match("^(?P<dir>[+-]?)(?P<prop>.*)$", s.lstrip()).groupdict() # type:ignore

prop = parts["prop"]
if parts["prop"] in ["lastused", "usecount"]:
Expand Down
5 changes: 4 additions & 1 deletion titiler/pgstac/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,14 @@ def pgstac_info(request: Request) -> Dict:
tags=["ColorMaps"],
)


###############################################################################
# Health Check Endpoint
@app.get("/healthz", description="Health Check", tags=["Health Check"])
def ping(
timeout: int = Query(1, description="Timeout getting SQL connection from the pool.")
timeout: int = Query(
1, description="Timeout getting SQL connection from the pool."
),
) -> Dict:
"""Health check."""
try:
Expand Down
1 change: 0 additions & 1 deletion titiler/pgstac/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def retry(

def _decorator(func: Any):
def _newfn(*args: Any, **kwargs: Any):

attempt = 0
while attempt < tries:
try:
Expand Down
Loading