Skip to main content

Taxonomic types, projections and async taxonomy services for Polli-Labs.

Project description

TwitterBanner_SkyHyperpole2_1991

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 viewexpanded_taxa ORM exposes each rank (L10 → L70) on a single row for constant‑time lineage queries.
  • Async servicesPostgresTaxonomyService (ltree) & SQLiteTaxonomyService (fixture) share one interface.
  • Pydantic v2 modelsTaxon, 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.

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)

Developer guide

  • Lint & tests (one‑liner)

    ruff check . && ruff format . && pytest -q
    
  • Format whole repo

    ruff format .
    
  • JSON Schemaspython -m typus.export_schemastypus/schemas/

  • SQLite fixturepython scripts/gen_fixture_sqlite.py

  • Pre‑commit hookspre-commit install


Publishing (maintainers)

See build/typus_publish.md for tag → TestPyPI → PyPI workflow.


License

MIT © 2025 Polli Labs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polli_typus-0.1.9-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

Details for the file polli_typus-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: polli_typus-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 36.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for polli_typus-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 e2bb129d3d649d15275977c3357a0863e04809ca239d18e79d4f3de4d6e93fcd
MD5 39d135ba43f8617aea0eb346a3fbb22f
BLAKE2b-256 1246df4360c7d4b27912797e61381a64ecb34c4cfa8f9224c838426c86a65567

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page