lx-data-types
Project description
lx-data-models
lx-dtypes provides strongly typed, Pydantic-powered data models for Lux Group
medical research projects. The package ships opinionated validators, utilities
for ingestion/export, and a common vocabulary so downstream services can reason
about patient examinations, knowledge-base entries, and related clinical data.
Features
- Comprehensive Pydantic models covering patient records, exam findings, and knowledge-base entities.
- Data loaders/encoders that normalize multiple file formats into the same abstractions.
- Utilities for working with Lux Research tooling (paths, logging, export helpers, etc.).
- Ready-to-run pytest suite with coverage and optional type-checking.
Installation
Install the latest release from PyPI (coming soon):
pip install lx-dtypes
For contributors and power users, install with the development extras:
pip install "lx-dtypes[dev]"
Quick Start
from lx_dtypes import __version__
from lx_dtypes.models.patient import Patient
patient = Patient.model_validate({
"id": "1234",
"first_name": "Ada",
"last_name": "Lovelace",
})
print(patient.full_name)
print(__version__)
Development
git clone https://github.com/wg-lux/lx-data-models
cd lx-data-models
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
Migrations
The following command shortcuts are available for managing migratons, see line below for what they do:
mkmigrations
"uv run python manage.py makemigrations ${DJANGO_APP_NAME}";
migrate
"uv run python manage.py migrate";
runserver
"uv run python manage.py runserver";
resetdb
"rm -f db.sqlite3";
resetmigrations
rm -rf ${DJANGO_APP_DIR}/migrations/;
uv run python manage.py makemigrations ${DJANGO_APP_NAME};
Initialized Models
Some pydantic models with ForwardRefs require initialization before use.
Import initialized models from lx_dtypes.utils.initialized_models
If you encounter this error when using a model, you may add it there.
Example for the PatientLedger model which references Examiner. This would cause a circular import, therefore we just use the Examiner model during TYPE_CHECKING in the PatientLedger model file and rebuild the model here.
from lx_dtypes.models.examiner import (
Examiner, # for model rebuild # type: ignore # noqa: F401
)
PatientLedger.model_rebuild()
Test & Lint
pytest
ruff check lx_dtypes tests
mypy lx_dtypes
Documentation
Install the documentation extras (included in .[dev]) and build the HTML site
with Sphinx:
pip install -e ".[docs]"
make -C docs html
# open docs/_build/html/index.html in your browser
Use make -C docs linkcheck to verify outbound references before publishing to
Read the Docs or GitHub Pages.
Release Process
- Update
CHANGELOG.mdand bump the version inpyproject.toml. - Run formatting, linting, type-checking, and the full test suite.
- Build artifacts with
python -m buildand verify withtwine check dist/*. - Trigger the "Publish" GitHub workflow (either via tag/release or manual
dispatch). Trusted Publisher entries for
test.pypi.organdpypi.orgshould already reference thepublish.ymlworkflow and thetestpypi/pypienvironments; approve those environments as needed and the workflow will push to TestPyPI first, then PyPI.
Contributing
See CONTRIBUTING.md for the full workflow, coding standards, and release
guidelines. Bug reports and pull requests are welcome!
License
Distributed under the MIT License. See LICENSE for details.
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
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 lx_dtypes-0.1.1.tar.gz.
File metadata
- Download URL: lx_dtypes-0.1.1.tar.gz
- Upload date:
- Size: 1.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a44e8e1dad958c70340fe38e9e17afb01b56320145616736c267cc2c0a9ac310
|
|
| MD5 |
5f69897e2bf67b785ec5f73363188004
|
|
| BLAKE2b-256 |
0317712455c68279cc644f8ca10540ed60b57eddb398ff37e2ce1ce915be0692
|
Provenance
The following attestation bundles were made for lx_dtypes-0.1.1.tar.gz:
Publisher:
publish.yml on wg-lux/lx-data-models
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lx_dtypes-0.1.1.tar.gz -
Subject digest:
a44e8e1dad958c70340fe38e9e17afb01b56320145616736c267cc2c0a9ac310 - Sigstore transparency entry: 846420811
- Sigstore integration time:
-
Permalink:
wg-lux/lx-data-models@3c3f7c73f216f1c7c1b5fe0e21db698e6ec619fa -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/wg-lux
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3c3f7c73f216f1c7c1b5fe0e21db698e6ec619fa -
Trigger Event:
release
-
Statement type:
File details
Details for the file lx_dtypes-0.1.1-py3-none-any.whl.
File metadata
- Download URL: lx_dtypes-0.1.1-py3-none-any.whl
- Upload date:
- Size: 371.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b3ced59355103d757c50f7f88a32b60e03460569a8cca441806d29582bd90a9
|
|
| MD5 |
2686fee0c822938b6d0809f987878f7f
|
|
| BLAKE2b-256 |
1ee601434a8d0466b51c8cb54952daf1645a6d87b8bbfead6eed1a5a3a83ed28
|
Provenance
The following attestation bundles were made for lx_dtypes-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on wg-lux/lx-data-models
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lx_dtypes-0.1.1-py3-none-any.whl -
Subject digest:
5b3ced59355103d757c50f7f88a32b60e03460569a8cca441806d29582bd90a9 - Sigstore transparency entry: 846420815
- Sigstore integration time:
-
Permalink:
wg-lux/lx-data-models@3c3f7c73f216f1c7c1b5fe0e21db698e6ec619fa -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/wg-lux
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3c3f7c73f216f1c7c1b5fe0e21db698e6ec619fa -
Trigger Event:
release
-
Statement type: