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.
  • Offline SQLite loadertypus-load-sqlite CLI 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 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.11-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: polli_typus-0.1.11-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.11-py3-none-any.whl
Algorithm Hash digest
SHA256 6a7062b3673be047cbc56abefab093ba334cca0dc9ed1090567384301cfe778e
MD5 2a24af5f3bb61498a46010c39f5b2991
BLAKE2b-256 75362a0197951a739f4b8643ad32143bacdfb988c08e31a907de4f6b49d720bb

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