SEKM Pydantic 2 domain model and Beanie/MongoDB persistence model
Project description
sysnet-sekm-model
Pydantic 2 domain models and Beanie/MongoDB persistence layer for SEKM — the Czech System of Evidence of Contaminated Sites (Systém Evidence Kontaminovaných Míst).
This library is the shared data layer for any service that reads or writes SEKM data
from MongoDB. It has no dependency on Elasticsearch; migration tooling lives in the
companion package sysnet-sekm-migrate.
Installation
pip install sysnet-sekm-model
Requirements
- Python ≥ 3.12
- MongoDB instance (no Elasticsearch required)
.envfile withMONGO_HOST,MONGO_PORT,MONGO_USERNAME,MONGO_PASSWORD,MONGO_DB
Quick start
from sysnet_sekm_model.config import MongoSettings
from sysnet_sekm_model.db import init_mongo, close_mongo
from sysnet_sekm_model.models.persistence import AreaSourceDoc
# Initialise Beanie (reads credentials from .env / environment variables)
settings = MongoSettings()
client = await init_mongo(settings.mongo_uri, settings.mongo_db)
# Query
doc = await AreaSourceDoc.find_one(AreaSourceDoc.sekm_id == "12345678")
# Shutdown
await close_mongo(client)
What's inside
Domain models (sysnet_sekm_model.models.domain)
Pydantic 2 models for all 21 SEKM entities — validation and business logic only, no MongoDB awareness:
| Model | Entity |
|---|---|
AreaSource |
Contaminated site (lokalita) — the central SEKM entity |
AsObject, AsRegion, AsDocument |
Site sub-entities |
Observation |
Field observation record |
Sample, SampleAdvanced |
Environmental measurement (up to 28 M records) |
User, Organisation |
Auth and organisation |
Template |
Document template |
Dictionary, Substance |
Reference data |
HistoryEvent, LockDocument, Approval |
Audit trail |
Region, District, Municipality, … |
Geographic reference data |
Persistence models (sysnet_sekm_model.models.persistence)
Beanie documents backed by sysnet-docversion's VersionedDocument for entities
that carry audit history. Each document stores:
sekm_id— SEKM business key (unique index)current_version— version counter managed bysysnet-docversionmigration_meta— provenance metadata (source ES index, migrated_at, batch ID)
MongoDB connection (sysnet_sekm_model.db)
from sysnet_sekm_model.db import init_mongo, close_mongo, ALL_DOCUMENT_MODELS
init_mongo(uri, db) initialises Beanie with all document models and creates indexes.
Uses pymongo.AsyncMongoClient directly — Motor is not used.
Settings (sysnet_sekm_model.config)
from sysnet_sekm_model.config import MongoSettings
MongoSettings is a Pydantic BaseSettings subclass that reads MONGO_* variables
from the environment or .env.
Documentation
| Document | Contents |
|---|---|
| Data Model | Full domain and persistence model reference |
| Trial Migration Report | Migration results and entity volumes |
| Data Quality Report | Post-migration data quality findings |
License
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 Distribution
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 sysnet_sekm_model-0.2.0.tar.gz.
File metadata
- Download URL: sysnet_sekm_model-0.2.0.tar.gz
- Upload date:
- Size: 28.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","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":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0af0999988a63f2931f4eb23f93167371328ceab5ff7f70b6328bcba5cc773f8
|
|
| MD5 |
3d170ce5eb9a8ea3ec790cd6317257fc
|
|
| BLAKE2b-256 |
ea83ded8ec527fa3e9559413630fc3ea0c73f1fcb0c86fafb3f23feb1a4326dd
|
File details
Details for the file sysnet_sekm_model-0.2.0-py3-none-any.whl.
File metadata
- Download URL: sysnet_sekm_model-0.2.0-py3-none-any.whl
- Upload date:
- Size: 16.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","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":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a988aaa8803318c5396bf1a3d242ae2b25614afce61beab9d8caf546924608f5
|
|
| MD5 |
4f3f08c4ce6d21708814ca3e723ddc1c
|
|
| BLAKE2b-256 |
d1700617e680d0ac2ad523b39dd8751a59d20762ade7f68b9663416270d8dfde
|