Skip to main content

An unofficial implementation of the Camtrap DP 1.0.2 datapackage standard with explicit Python dataclasses and pydantic. Intended to help developers with exporting their data to the Camtrap DP 1.0.2 datapackage format.

Project description

CI

trap-schema

An unofficial, strictly-typed implementation of the Camtrap DP 1.0.2 datapackage standard.

trap-schema uses Python dataclasses and Pydantic to provide robust, schema-aware data structures. It is designed to help developers easily parse, validate, and export camera trap data into the official Frictionless Data format without second-guessing schema constraints or having the documentation open on a second monitor.

Features

  • Strict Validation: Built on pydantic to enforce constraints (e.g., coordinate bounds, unique IDs, valid media types) at instantiation.
  • Ergonomic Tables: Treat tabular data natively. Tables act as columnar data structures but guarantee per-row validation.
  • Auto-Synced Documentation: Docstrings and schema attributes are automatically kept in sync with the official Camtrap DP JSON Schemas using a custom AST transformer.

Installation

This project uses uv for fast and reliable package management. Requires Python 3.14+.

To add trap-schema to your project:

uv add git+https://github.com/asgersvenning/trap-schema.git

To install a specific release (e.g. v0.1.0):

uv add git+https://github.com/asgersvenning/trap-schema.git@v0.1.0

Quick Start

from trap_schema.tables import DeploymentRow, DeploymentTable

# 1. Create validated rows
deployment = DeploymentRow(
    deploymentID="dep_001",
    latitude=56.2,
    longitude=10.4,
    deploymentStart="2026-04-25T10:00:00Z",
    deploymentEnd="2026-05-25T10:00:00Z",
)

# 2. Group into a Table (validates unique keys and types)
table = DeploymentTable(rows=[deployment])

# 3. Export to Camtrap DP standard CSV
table.save("out_dir")

Development

git clone [https://github.com/asgersvenning/trap-schema.git](https://github.com/asgersvenning/trap-schema.git)
cd trap-schema
uv sync --all-groups

Update docstrings

We use libcst and frictionless to seamlessly and automatically integrate the official docstrings for table and metadata fields.

To update these run:

uv run tools/docstrings.py

Linting

[uv] ruff check --ignore E501

Testing

uv run pytest tests

License

MIT

Project details


Download files

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

Source Distribution

trap_schema-0.1.0.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

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

trap_schema-0.1.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file trap_schema-0.1.0.tar.gz.

File metadata

  • Download URL: trap_schema-0.1.0.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for trap_schema-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f058d2550695cfe44d7ff6b7bf97046918745c3e7f6920c7e54cb473023335a2
MD5 31626324bc5fc1fe6dc15cd3b8a372c8
BLAKE2b-256 42d565c848e802c1f394197446fac3d58125573e0d0434af4f6648c6a260decb

See more details on using hashes here.

File details

Details for the file trap_schema-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: trap_schema-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for trap_schema-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 25d84a62b8e396feeab04a7f74c9d01849099199ada9d6f6a89675127a17acaa
MD5 25979d9ee4f333da52e2f9dca8f3866e
BLAKE2b-256 1485a7687aca41136fef442206aee0ee9c204bff08f827f443651e8ca90180f3

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