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 typus.services import SQLiteTaxonomyService
svc = SQLiteTaxonomyService()   # uses tests/fixture_typus.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.8-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: polli_typus-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 29.8 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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 c6ae335e5a74b9d9fc4be5a64a031e51438c34f4ec0d522fd54aa2dce56ed7f5
MD5 2aa5ae228bdb375ebdb1cb4c91f749d6
BLAKE2b-256 cdd4f5866ab5fcdad35755b33243e8f580ffacba5903f1719b5cbb788b8d7f33

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