Skip to content
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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.7.0
current_version = 0.8.0a0
commit = True
tag = True
tag_name = {new_version}
Expand Down
21 changes: 11 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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**

Expand Down
3 changes: 2 additions & 1 deletion dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
45 changes: 21 additions & 24 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = [
Expand All @@ -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",
Expand All @@ -31,9 +32,6 @@ dependencies = [
]

[project.optional-dependencies]
all = [
"orjson",
]
test = [
"pytest",
"pytest-cov",
Expand All @@ -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",
Expand All @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion timvt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""timvt."""

__version__ = "0.7.0"
__version__ = "0.8.0a0"
11 changes: 3 additions & 8 deletions timvt/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,22 @@

from typing import Any, Optional

import orjson
from buildpg import asyncpg

from timvt.dbmodel import get_table_index
from timvt.settings import PostgresSettings

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"
)


Expand Down
23 changes: 9 additions & 14 deletions timvt/dbmodel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""tifeatures.dbmodel: database events."""
"""timvt.dbmodel: database events."""

from typing import Any, Dict, List, Optional

Expand Down Expand Up @@ -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."""
Expand Down