This page covers integrating CORE as a library, building from source, running tests, creating executables, and packaging.
CORE is available as a Python package for direct integration into data pipelines.
pip install cdisc-rules-engineThis allows you to:
- Import the rules engine library into your Python projects
- Validate data without requiring XPT format files
- Integrate rules validation into existing pipelines
For implementation details, see PYPI.md.
Python 3.12 is required. Other versions are not supported and may produce unexpected errors or incorrect validation results.
# Check your Python version
python --version
# Clone the repository
git clone https://github.com/cdisc-org/cdisc-rules-engine.git
cd cdisc-rules-engine
# Create a virtual environment
python -m venv venv
# If you have multiple Python versions, be explicit:
# python3.12 -m venv venv
# Activate (Linux/Mac)
source venv/bin/activate
# Activate (Windows)
.\venv\Scripts\Activate
# Install dependencies
python -m pip install -r requirements-dev.txtFrom the project root, run both unit and regression tests:
python -m pytest testsPre-built executables are available on the Releases page. If you need to build your own, see README_Build_Executable.md in the repository root.
For reference, the PyInstaller commands are:
Linux:
pyinstaller core.py \
--add-data=venv/lib/python3.12/site-packages/xmlschema/schemas:xmlschema/schemas \
--add-data=resources/cache:resources/cache \
--add-data=resources/templates:resources/templates \
--add-data=resources/jsonata:resources/jsonataWindows:
pyinstaller core.py ^
--add-data=".venv/Lib/site-packages/xmlschema/schemas;xmlschema/schemas" ^
--add-data="resources/cache;resources/cache" ^
--add-data="resources/templates;resources/templates" ^
--add-data="resources/jsonata;resources/jsonata"The executable is created in the dist/ folder and does not require Python to be installed on the target machine.
All non-Python files must be listed in MANIFEST.in to be included in the distribution.
Unix / Mac:
python3 -m pip install --upgrade build
python3 -m buildInstall locally from the dist/ folder:
pip3 install dist/cdisc_rules_engine-{version}-py3-none-any.whlUpload to PyPI:
python3 -m pip install --upgrade twine
python3 -m twine upload --repository {repository_name} dist/*Windows:
py -m pip install --upgrade build
py -m buildInstall locally:
pip install dist\cdisc_rules_engine-{version}-py3-none-any.whlUpload to PyPI:
py -m pip install --upgrade twine
py -m twine upload --repository {repository_name} dist/*CORE validates against USDM JSON Schema versions 3.0 and 4.0. Schema definitions are stored as .pkl files in resources/cache/:
resources/cache/usdm-3-0-schema.pklresources/cache/usdm-4-0-schema.pkl
These are derived from the OpenAPI specs in cdisc-org/DDF-RA. To update or add a schema version:
-
Extract the OpenAPI spec for the target tag:
git --no-pager --git-dir DDF-RA.git show --format=format:"%B" {tag}:Deliverables/API/USDM_API.json > USDM_API_{version}.json
Example tag:
v3.0.0 -
Convert the OpenAPI spec to JSON Schema:
python scripts/openapi-to-json.py
-
Convert the JSON Schema to
.pkl:python scripts/json_pkl_converter.py
-
Place the resulting
.pklfile inresources/cache/.
When validating a single rule with --local-rules, JSON datasets must match the Dataset-JSON format used by the rule editor:
{
"datasets": [
{
"filename": "cm.xpt",
"label": "Concomitant/Concurrent medications",
"domain": "CM",
"variables": [
{
"name": "STUDYID",
"label": "Study Identifier",
"type": "Char",
"length": 10
}
],
"records": {
"STUDYID": ["CDISC-TEST", "CDISC-TEST", "CDISC-TEST", "CDISC-TEST"]
}
}
]
}