-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
67 changed files
with
11,205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<!--- | ||
Thank you for your soon-to-be pull request. Before you submit this, please | ||
double check to make sure that you've added an entry to CHANGELOG.md. | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Ruff | ||
on: [push, pull_request] | ||
jobs: | ||
ruff: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
- name: Install nox | ||
run: pip install nox | ||
- name: Run ruff linter via nox session | ||
run: nox -s lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# This workflow will install Python dependencies, run tests with a range of Python versions | ||
|
||
name: tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: [ | ||
'3.8', | ||
'3.9', | ||
'3.10', | ||
'3.11', | ||
'3.12', | ||
] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
- name: Install package and dependencies | ||
run: poetry install | ||
- name: Test with pytest | ||
run: poetry run pytest -vs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: check-added-large-files | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version. | ||
rev: v0.3.2 | ||
hooks: | ||
# Run the linter. | ||
- id: ruff | ||
args: [ --fix ] | ||
# Run the formatter. | ||
- id: ruff-format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Changelog | ||
|
||
## v0.1.0 | ||
First release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# OMOP-CDM | ||
|
||
Python SQLAlchemy table definitions of the [OHDSI OMOP CDM](https://ohdsi.github.io/CommonDataModel/). | ||
|
||
## Installation | ||
|
||
Install from PyPI: | ||
```shell | ||
pip install omop-cdm | ||
``` | ||
|
||
## Usage | ||
TODO: | ||
See [User documentation](docs/index.md) | ||
|
||
## Development | ||
|
||
### Setup steps | ||
|
||
- Make sure [Poetry](https://python-poetry.org/docs/#installation) is installed. | ||
- Install the project and dependencies via `poetry install`. | ||
- Set up the pre-commit hook scripts via `poetry run pre-commit install`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import nox # type: ignore | ||
|
||
nox.options.sessions = [ | ||
"tests", | ||
"lint", | ||
] | ||
|
||
python = [ | ||
"3.8", | ||
"3.9", | ||
"3.10", | ||
"3.11", | ||
"3.12", | ||
] | ||
|
||
|
||
@nox.session(python=python) | ||
def tests(session: nox.Session): | ||
"""Run test suite.""" | ||
session.run("poetry", "install", external=True) | ||
session.run("pytest", "--cov=src") | ||
session.notify("coverage") | ||
|
||
|
||
@nox.session | ||
def coverage(session: nox.Session): | ||
"""Generate pytest code coverage report.""" | ||
session.run("coverage", "report", "--show-missing") | ||
|
||
|
||
@nox.session(reuse_venv=True, name="format") | ||
def format_all(session: nox.Session): | ||
"""Format codebase with ruff.""" | ||
session.run("poetry", "install", "--only", "dev", external=True) | ||
session.run("ruff", "format") | ||
# format imports according to isort via ruff check | ||
session.run("ruff", "check", "--select", "I", "--fix") | ||
|
||
|
||
@nox.session(reuse_venv=True) | ||
def lint(session: nox.Session): | ||
"""Run ruff linter.""" | ||
session.run("poetry", "install", "--only", "dev", external=True) | ||
# Run the ruff linter | ||
session.run("ruff", "check") | ||
# Check if any code requires formatting via ruff format | ||
session.run("ruff", "format", "--diff") |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[tool.poetry] | ||
name = "omop-cdm" | ||
version = "0.1.0" | ||
description = "SQLAlchemy ORM of the OHDSI OMOP CDM" | ||
authors = [ | ||
"Spayralbe <[email protected]>", | ||
] | ||
readme = "README.md" | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.8" | ||
sqlalchemy = "^2.0.0" | ||
|
||
|
||
[tool.poetry.group.dev.dependencies] | ||
nox = "^2024.3.2" | ||
ruff = "^0.3.2" | ||
pre-commit = "^3.5.0" | ||
|
||
[tool.poetry.group.test.dependencies] | ||
pytest = "^8.1.1" | ||
pytest-cov = "^4.1.0" | ||
testcontainers = {version = ">=3.7.1", extras = ["postgres"]} | ||
psycopg2-binary = "^2.9.9" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
|
||
[tool.pytest.ini_options] | ||
addopts = "--import-mode=importlib" | ||
pythonpath = [ | ||
".", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
src = ["src", "."] | ||
|
||
[lint] | ||
select = [ | ||
# pycodestyle | ||
"E", | ||
# Pyflakes | ||
"F", | ||
# pyupgrade | ||
"UP", | ||
# flake8-bugbear | ||
"B", | ||
# flake8-simplify | ||
"SIM", | ||
# isort | ||
"I", | ||
] | ||
|
||
[lint.isort] | ||
known-first-party = ["omop_cdm"] | ||
|
||
# Ignore import violations in all `__init__.py` files | ||
[lint.per-file-ignores] | ||
"__init__.py" = ["E402", "F401"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from omop_cdm.constants import NAMING_CONVENTION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Module containing the placeholder schema names as used in the ORM.""" | ||
|
||
# These are the placeholder schema names as used in the ORM table | ||
# definitions. They will be replaced with actual schema names at runtime | ||
# by providing a schema_translate_map to your SQLAlchemy engine. | ||
VOCAB_SCHEMA = "vocabulary_schema" | ||
CDM_SCHEMA = "cdm_schema" | ||
|
||
# Some often used foreign keys are added as variables for convenience. | ||
FK_CONCEPT_ID = f"{VOCAB_SCHEMA}.concept.concept_id" | ||
FK_VOCABULARY_ID = f"{VOCAB_SCHEMA}.vocabulary.vocabulary_id" | ||
FK_DOMAIN_ID = f"{VOCAB_SCHEMA}.domain.domain_id" | ||
FK_CONCEPT_CLASS_ID = f"{VOCAB_SCHEMA}.concept_class.concept_class_id" | ||
FK_PERSON_ID = f"{CDM_SCHEMA}.person.person_id" | ||
FK_VISIT_OCCURRENCE_ID = f"{CDM_SCHEMA}.visit_occurrence.visit_occurrence_id" | ||
FK_VISIT_DETAIL_ID = f"{CDM_SCHEMA}.visit_detail.visit_detail_id" | ||
FK_PROVIDER_ID = f"{CDM_SCHEMA}.provider.provider_id" | ||
FK_CARE_SITE_ID = f"{CDM_SCHEMA}.care_site.care_site_id" | ||
FK_LOCATION_ID = f"{CDM_SCHEMA}.location.location_id" | ||
|
||
# This object should be used to set the naming_convention parameter of | ||
# the SQLAlchemy MetaData object. Using it makes sure that the naming of | ||
# constraints and indexes is deterministic and not left up to the DBMS. | ||
# It's also needed when dropping these, as SQLAlchemy requires that | ||
# they have a name for them to be dropped. See: | ||
# https://docs.sqlalchemy.org/en/20/core/constraints.html#configuring-constraint-naming-conventions | ||
NAMING_CONVENTION = { | ||
"ix": "ix_%(table_name)s_%(column_0_N_name)s", | ||
"uq": "uq_%(table_name)s_%(column_0_name)s", | ||
"ck": "ck_%(table_name)s_%(constraint_name)s", | ||
"fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s", | ||
"pk": "pk_%(table_name)s", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
OMOP CDM Version 5.3.1. | ||
Generated from OMOP CDM release 5.3.1 using sqlacodegen 3.0.0rc5. | ||
DDL from https://github.com/OHDSI/CommonDataModel/tree/v5.3.1. | ||
Deviations from standard model | ||
Removed | ||
attribute_definition | ||
cohort_attribute | ||
Added | ||
stem_table | ||
source_to_concept_map_version | ||
Updated | ||
source_to_concept_map | ||
source_code from VARCHAR(50) --> VARCHAR(1000) | ||
If using a separate vocab schema, STCM is created in the CDM schema | ||
""" |
Oops, something went wrong.