diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 9a12b33..77fcd6d 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.7.0 +current_version = 0.8.0a0 commit = True tag = True tag_name = {new_version} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93c5546..7042b10 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -118,25 +118,26 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install flit - python -m pip install . + python -m pip install hatch + python -m hatch build - name: Set tag version id: tag - # https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions - run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} + run: | + echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT - name: Set module version id: module - # https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions - run: echo ::set-output name=version::$(python -c 'from importlib.metadata import version; print(version("timvt"))') + run: | + echo "version=$(hatch --quiet version)" >> $GITHUB_OUTPUT - name: Build and publish - if: steps.tag.outputs.tag == steps.module.outputs.version + if: ${{ steps.tag.outputs.version }} == ${{ steps.module.outputs.version}} env: - FLIT_USERNAME: ${{ secrets.PYPI_USERNAME }} - FLIT_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: flit publish + HATCH_INDEX_USER: ${{ secrets.PYPI_USERNAME }} + HATCH_INDEX_AUTH: ${{ secrets.PYPI_PASSWORD }} + run: | + python -m hatch publish publish-docker: needs: [tests] diff --git a/CHANGES.md b/CHANGES.md index 79d0b16..374be8a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,6 @@ # Release Notes -## Next (TBD) +## 0.8.0a0 (2022-11-16) * remove `.pbf` extension in tiles endpoints * add `orjson` as an optional dependency (for faster JSON encoding/decoding within the database communication) @@ -15,6 +15,7 @@ * Update dockerfiles to python3.10 and postgres14-postgis3.3 * update FastAPI requirement to >0.87 * remove endpoint Tags +* make orjson a default requirement **breaking changes** diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile index ed1f9a6..f9681f3 100644 --- a/dockerfiles/Dockerfile +++ b/dockerfiles/Dockerfile @@ -5,11 +5,12 @@ FROM ghcr.io/vincentsarago/uvicorn-gunicorn:${PYTHON_VERSION} WORKDIR /tmp COPY README.md README.md +COPY LICENSE LICENSE COPY timvt/ timvt/ COPY pyproject.toml pyproject.toml RUN pip install . --no-cache-dir -RUN rm -rf timvt/ README.md pyproject.toml +RUN rm -rf timvt/ README.md pyproject.toml LICENSE ENV MODULE_NAME timvt.main ENV VARIABLE_NAME app diff --git a/pyproject.toml b/pyproject.toml index f173e7f..b7f3f20 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,11 @@ [project] name = "timvt" description = "A lightweight PostGIS based dynamic vector tile server." -readme = "README.md" requires-python = ">=3.8" license = {file = "LICENSE"} authors = [ - {name = "Vincent Sarago", email = "vincent@developmentseed.com"}, + {name = "Vincent Sarago", email = "vincent@developmentseed.org"}, + {name = "David Bitner", email = "david@developmentseed.org"}, ] keywords = ["FastAPI", "MVT", "POSTGIS"] classifiers = [ @@ -18,8 +18,9 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Topic :: Scientific/Engineering :: GIS", ] -dynamic = ["version"] +dynamic = ["version", "readme"] dependencies = [ + "orjson", "asyncpg>=0.23.0", "buildpg>=0.3", "fastapi>=0.87", @@ -31,9 +32,6 @@ dependencies = [ ] [project.optional-dependencies] -all = [ - "orjson", -] test = [ "pytest", "pytest-cov", @@ -50,7 +48,7 @@ dev = [ "pre-commit", ] server = [ - "uvicorn[standard]>=0.12.0,<0.16.0", + "uvicorn[standard]>=0.12.0,<0.19.0", ] docs = [ "nbconvert", @@ -62,30 +60,29 @@ docs = [ ] [project.urls] +Homepage = "https://developmentseed.org/timvt/" Source = "https://github.com/developmentseed/timvt" Documentation = "https://developmentseed.org/timvt/" -[build-system] -requires = ["flit>=3.2,<4"] -build-backend = "flit_core.buildapi" - -[tool.flit.module] -name = "timvt" +[tool.hatch.version] +path = "timvt/__init__.py" -[tool.flit.sdist] +[tool.hatch.build.targets.sdist] exclude = [ - "tests/", - "docs/", - ".github/", - "CHANGES.md", - "CONTRIBUTING.md", - "dockerfiles", - "demo", - ".env*", - "data/", - "docker-compose.yml", + "/tests", + "/dockerfiles", + "/docs", + "/demo", + "/data", + "docker-compose.yml", + "CONTRIBUTING.md", + "CHANGES.md", ] +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + [tool.isort] profile = "black" known_first_party = ["timvt"] diff --git a/timvt/__init__.py b/timvt/__init__.py index c0aa8bf..4b05b0b 100644 --- a/timvt/__init__.py +++ b/timvt/__init__.py @@ -1,3 +1,3 @@ """timvt.""" -__version__ = "0.7.0" +__version__ = "0.8.0a0" diff --git a/timvt/db.py b/timvt/db.py index a73468f..3c7f086 100644 --- a/timvt/db.py +++ b/timvt/db.py @@ -2,6 +2,7 @@ from typing import Any, Optional +import orjson from buildpg import asyncpg from timvt.dbmodel import get_table_index @@ -9,20 +10,14 @@ from fastapi import FastAPI -try: - import orjson as json - -except ModuleNotFoundError: - import json # type: ignore - async def con_init(conn): """Use json for json returns.""" await conn.set_type_codec( - "json", encoder=json.dumps, decoder=json.loads, schema="pg_catalog" + "json", encoder=orjson.dumps, decoder=orjson.loads, schema="pg_catalog" ) await conn.set_type_codec( - "jsonb", encoder=json.dumps, decoder=json.loads, schema="pg_catalog" + "jsonb", encoder=orjson.dumps, decoder=orjson.loads, schema="pg_catalog" ) diff --git a/timvt/dbmodel.py b/timvt/dbmodel.py index b0186ba..686452f 100644 --- a/timvt/dbmodel.py +++ b/timvt/dbmodel.py @@ -1,4 +1,4 @@ -"""tifeatures.dbmodel: database events.""" +"""timvt.dbmodel: database events.""" from typing import Any, Dict, List, Optional @@ -116,21 +116,16 @@ def id_column_info(self) -> Column: # type: ignore def columns(self, properties: Optional[List[str]] = None) -> List[str]: """Return table columns optionally filtered to only include columns from properties.""" - cols = [c.name for c in self.properties] - if properties is not None: - if self.id_column and self.id_column not in properties: - properties.append(self.id_column) + if properties in [[], [""]]: + return [] - geom_col = self.get_geometry_column() - if geom_col: - properties.append(geom_col.name) + cols = [ + c.name for c in self.properties if c.type not in ["geometry", "geography"] + ] + if properties is None: + return cols - cols = [col for col in cols if col in properties] - - if len(cols) < 1: - raise TypeError("No columns selected") - - return cols + return [c for c in cols if c in properties] def get_column(self, property_name: str) -> Optional[Column]: """Return column info."""