Taxonomic types, projections and async taxonomy services for Polli-Labs.
Project description
Typus
Shared taxonomy & geo‑temporal types for the Polli‑Labs ecological stack
Typus centralises every domain object that the rest of our platform —
linnaeus, pollinalysis-server, dashboards … — needs: taxon records,
clades, hierarchical classification results, projection helpers and async
database services. Anything that speaks taxonomy imports Typus and stays DRY.
Features
- Wide ancestry view –
expanded_taxaORM exposes each rank (L10 → L70) on a single row for constant‑time lineage queries. - Async services –
PostgresTaxonomyService(ltree) &SQLiteTaxonomyService(fixture) share one interface. - Pydantic v2 models –
Taxon,Clade,HierarchicalClassificationResult, all JSON‑Schema‑exportable. - Projection utils – lat/lon ↔ unit‑sphere, cyclical‑time features, multi‑scale elevation sinusoids.
- Optional drivers only when you need them – install
polli-typus[postgres]or[sqlite]; core install stays lightweight. - Offline SQLite loader –
typus-load-sqliteCLI builds and caches the offline dataset
Requirements
- Python ≥ 3.10
Installation
Core (no DB drivers)
uv pip install polli-typus # import typus
With Postgres backend
uv pip install "polli-typus[postgres]" # adds asyncpg
With SQLite only (CI, offline, sandboxes)
uv pip install "polli-typus[sqlite]"
Development / tests / lint
uv pip install -e ".[dev,sqlite]" # pytest, pytest-asyncio, ruff, pre-commit, aiosqlite …
Install with plain pip:
pip install -e ".[dev,sqlite]"
Quick start
from typus import PostgresTaxonomyService, RankLevel, latlon_to_unit_sphere
svc = PostgresTaxonomyService("postgresql+asyncpg://user:pw@host/db")
bee = await svc.get_taxon(630955) # Anthophila
print(bee.scientific_name, bee.rank_level) # Anthophila RankLevel.L32
print(latlon_to_unit_sphere(31.5, -110.4)) # → x, y, z on S²
Offline mode (SQLite fixture)
from pathlib import Path
from typus.services import SQLiteTaxonomyService, load_expanded_taxa
db = Path("expanded_taxa.sqlite")
load_expanded_taxa(db) # downloads if missing
svc = SQLiteTaxonomyService(db)
typus-load-sqlite --sqlite expanded_taxa.sqlite
Developer guide
-
Lint & tests (one‑liner)
ruff check . && ruff format . && pytest -q
-
Format whole repo
ruff format .
-
JSON Schemas –
python -m typus.export_schemas→typus/schemas/ -
SQLite fixture –
python scripts/gen_fixture_sqlite.py -
Pre‑commit hooks –
pre-commit install
Publishing (maintainers)
See build/typus_publish.md for tag → TestPyPI → PyPI workflow.
License
MIT © 2025 Polli Labs
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 Distributions
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 polli_typus-0.2.0-py3-none-any.whl.
File metadata
- Download URL: polli_typus-0.2.0-py3-none-any.whl
- Upload date:
- Size: 37.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
224981f495e6ae7950db2af02a6fc138058739ff7f77208a810c96b156951101
|
|
| MD5 |
f05bb8d9f0e51cca7acb85b0645054b9
|
|
| BLAKE2b-256 |
8153f41a01f5fc8a7a90c1352ce479f8916591f03a29bb88b3103f0bdcae829b
|