openbtk 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openbtk-0.0.1/.gitignore +106 -0
- openbtk-0.0.1/LICENSE +202 -0
- openbtk-0.0.1/PKG-INFO +179 -0
- openbtk-0.0.1/README.md +100 -0
- openbtk-0.0.1/pyproject.toml +244 -0
- openbtk-0.0.1/src/openbtk/__init__.py +35 -0
- openbtk-0.0.1/src/openbtk/cli/__init__.py +1 -0
- openbtk-0.0.1/src/openbtk/core/__init__.py +5 -0
- openbtk-0.0.1/src/openbtk/data/__init__.py +5 -0
- openbtk-0.0.1/src/openbtk/data/clinical_text/__init__.py +3 -0
- openbtk-0.0.1/src/openbtk/data/ehr/__init__.py +4 -0
- openbtk-0.0.1/src/openbtk/deid/__init__.py +5 -0
- openbtk-0.0.1/src/openbtk/deid/recognizers/__init__.py +4 -0
- openbtk-0.0.1/src/openbtk/embeddings/__init__.py +1 -0
- openbtk-0.0.1/src/openbtk/eval/__init__.py +3 -0
- openbtk-0.0.1/src/openbtk/guardrails/__init__.py +5 -0
- openbtk-0.0.1/src/openbtk/integrations/__init__.py +1 -0
- openbtk-0.0.1/src/openbtk/integrations/langchain/__init__.py +6 -0
- openbtk-0.0.1/src/openbtk/llms/__init__.py +3 -0
- openbtk-0.0.1/src/openbtk/pipelines/__init__.py +4 -0
- openbtk-0.0.1/src/openbtk/py.typed +0 -0
- openbtk-0.0.1/src/openbtk/retrieval/__init__.py +1 -0
- openbtk-0.0.1/src/openbtk/terminology/__init__.py +4 -0
- openbtk-0.0.1/tests/packaging/test_install.py +151 -0
openbtk-0.0.1/.gitignore
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
.eggs/
|
|
11
|
+
.installed.cfg
|
|
12
|
+
*.egg
|
|
13
|
+
|
|
14
|
+
# Virtual environments
|
|
15
|
+
.venv/
|
|
16
|
+
venv/
|
|
17
|
+
env/
|
|
18
|
+
ENV/
|
|
19
|
+
|
|
20
|
+
# Testing / coverage
|
|
21
|
+
.pytest_cache/
|
|
22
|
+
.coverage
|
|
23
|
+
.coverage.*
|
|
24
|
+
htmlcov/
|
|
25
|
+
.mypy_cache/
|
|
26
|
+
.ruff_cache/
|
|
27
|
+
|
|
28
|
+
# IDE
|
|
29
|
+
.vscode/
|
|
30
|
+
.idea/
|
|
31
|
+
*.swp
|
|
32
|
+
*.swo
|
|
33
|
+
|
|
34
|
+
# Jupyter
|
|
35
|
+
.ipynb_checkpoints/
|
|
36
|
+
|
|
37
|
+
# Secrets / credentials — NEVER commit these
|
|
38
|
+
*.env
|
|
39
|
+
.env.*
|
|
40
|
+
*.key
|
|
41
|
+
*.pem
|
|
42
|
+
secrets.yaml
|
|
43
|
+
credentials.json
|
|
44
|
+
.secrets.baseline
|
|
45
|
+
|
|
46
|
+
# ---------------------------------------------------------------------------
|
|
47
|
+
# Biomedical data files — NEVER commit real or even synthetic large data
|
|
48
|
+
# ---------------------------------------------------------------------------
|
|
49
|
+
# Leading slash matters: an unanchored "data/" matches at ANY depth, so it also
|
|
50
|
+
# excluded src/data/ and would exclude src/openbtk/data/. That silently kept the
|
|
51
|
+
# entire v1 clinical_text module out of version control. Keep this anchored.
|
|
52
|
+
/data/
|
|
53
|
+
*.csv
|
|
54
|
+
*.tsv
|
|
55
|
+
*.parquet
|
|
56
|
+
|
|
57
|
+
# Clinical text / EHR
|
|
58
|
+
*.cda
|
|
59
|
+
*.hl7
|
|
60
|
+
|
|
61
|
+
# Imaging
|
|
62
|
+
*.dcm
|
|
63
|
+
*.dicom
|
|
64
|
+
*.nii
|
|
65
|
+
*.nii.gz
|
|
66
|
+
*.svs
|
|
67
|
+
|
|
68
|
+
# Biosignals
|
|
69
|
+
*.edf
|
|
70
|
+
*.bdf
|
|
71
|
+
*.hea
|
|
72
|
+
*.dat
|
|
73
|
+
*.wav
|
|
74
|
+
|
|
75
|
+
# Genomics
|
|
76
|
+
*.vcf
|
|
77
|
+
*.vcf.gz
|
|
78
|
+
*.bam
|
|
79
|
+
*.sam
|
|
80
|
+
*.bcf
|
|
81
|
+
*.fastq
|
|
82
|
+
*.fastq.gz
|
|
83
|
+
*.fasta
|
|
84
|
+
*.h5ad
|
|
85
|
+
*.loom
|
|
86
|
+
|
|
87
|
+
# Video
|
|
88
|
+
*.mp4
|
|
89
|
+
*.avi
|
|
90
|
+
*.mov
|
|
91
|
+
|
|
92
|
+
# Model artifacts / caches
|
|
93
|
+
*.pt
|
|
94
|
+
*.pth
|
|
95
|
+
*.bin
|
|
96
|
+
*.safetensors
|
|
97
|
+
.cache/
|
|
98
|
+
models/
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
# Exceptions — allow small fixture files explicitly added
|
|
102
|
+
!tests/fixtures/**/*.json
|
|
103
|
+
!tests/fixtures/**/sample_*.txt
|
|
104
|
+
|
|
105
|
+
# Build artefacts
|
|
106
|
+
site/
|
openbtk-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 OpenBTK Contributors
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
openbtk-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: openbtk
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: The open-source layer between biomedical data and modern AI: de-identified, auditable, model-ready inputs with clinical guardrails.
|
|
5
|
+
Project-URL: Homepage, https://github.com/openbtk/openbtk
|
|
6
|
+
Project-URL: Repository, https://github.com/openbtk/openbtk
|
|
7
|
+
Project-URL: Issues, https://github.com/openbtk/openbtk/issues
|
|
8
|
+
Author: OpenBTK Contributors
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: biomedical,clinical-nlp,de-identification,ehr,fhir,healthcare,hipaa,llm,omop,phi,rag
|
|
12
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
13
|
+
Classifier: Intended Audience :: Healthcare Industry
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Requires-Dist: httpx>=0.27
|
|
24
|
+
Requires-Dist: numpy>=1.26
|
|
25
|
+
Requires-Dist: pydantic>=2.5
|
|
26
|
+
Requires-Dist: pyyaml>=6.0
|
|
27
|
+
Requires-Dist: structlog>=24.0
|
|
28
|
+
Requires-Dist: typing-extensions>=4.12
|
|
29
|
+
Provides-Extra: all
|
|
30
|
+
Requires-Dist: anthropic>=0.30; extra == 'all'
|
|
31
|
+
Requires-Dist: chromadb>=0.5; extra == 'all'
|
|
32
|
+
Requires-Dist: faiss-cpu>=1.8; extra == 'all'
|
|
33
|
+
Requires-Dist: fhir-resources>=7.1; extra == 'all'
|
|
34
|
+
Requires-Dist: hl7apy>=1.3; extra == 'all'
|
|
35
|
+
Requires-Dist: langchain-core>=0.3; extra == 'all'
|
|
36
|
+
Requires-Dist: medspacy>=1.0; extra == 'all'
|
|
37
|
+
Requires-Dist: openai>=1.30; extra == 'all'
|
|
38
|
+
Requires-Dist: pandas>=2.2; extra == 'all'
|
|
39
|
+
Requires-Dist: presidio-analyzer>=2.2; extra == 'all'
|
|
40
|
+
Requires-Dist: presidio-anonymizer>=2.2; extra == 'all'
|
|
41
|
+
Requires-Dist: pyarrow>=16.0; extra == 'all'
|
|
42
|
+
Requires-Dist: scispacy>=0.5; extra == 'all'
|
|
43
|
+
Requires-Dist: transformers>=4.40; extra == 'all'
|
|
44
|
+
Provides-Extra: dev
|
|
45
|
+
Requires-Dist: faker>=25.0; extra == 'dev'
|
|
46
|
+
Requires-Dist: hypothesis>=6.100; extra == 'dev'
|
|
47
|
+
Requires-Dist: import-linter>=2.0; extra == 'dev'
|
|
48
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
49
|
+
Requires-Dist: pre-commit>=3.7; extra == 'dev'
|
|
50
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
51
|
+
Requires-Dist: pytest-mock>=3.14; extra == 'dev'
|
|
52
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
53
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
54
|
+
Requires-Dist: types-pyyaml>=6.0; extra == 'dev'
|
|
55
|
+
Provides-Extra: docs
|
|
56
|
+
Requires-Dist: mike>=2.1; extra == 'docs'
|
|
57
|
+
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
|
|
58
|
+
Requires-Dist: mkdocstrings[python]>=0.25; extra == 'docs'
|
|
59
|
+
Provides-Extra: ehr
|
|
60
|
+
Requires-Dist: fhir-resources>=7.1; extra == 'ehr'
|
|
61
|
+
Requires-Dist: hl7apy>=1.3; extra == 'ehr'
|
|
62
|
+
Requires-Dist: pandas>=2.2; extra == 'ehr'
|
|
63
|
+
Requires-Dist: pyarrow>=16.0; extra == 'ehr'
|
|
64
|
+
Provides-Extra: langchain
|
|
65
|
+
Requires-Dist: langchain-core>=0.3; extra == 'langchain'
|
|
66
|
+
Provides-Extra: llms
|
|
67
|
+
Requires-Dist: anthropic>=0.30; extra == 'llms'
|
|
68
|
+
Requires-Dist: openai>=1.30; extra == 'llms'
|
|
69
|
+
Provides-Extra: retrieval
|
|
70
|
+
Requires-Dist: chromadb>=0.5; extra == 'retrieval'
|
|
71
|
+
Requires-Dist: faiss-cpu>=1.8; extra == 'retrieval'
|
|
72
|
+
Provides-Extra: text
|
|
73
|
+
Requires-Dist: medspacy>=1.0; extra == 'text'
|
|
74
|
+
Requires-Dist: presidio-analyzer>=2.2; extra == 'text'
|
|
75
|
+
Requires-Dist: presidio-anonymizer>=2.2; extra == 'text'
|
|
76
|
+
Requires-Dist: scispacy>=0.5; extra == 'text'
|
|
77
|
+
Requires-Dist: transformers>=4.40; extra == 'text'
|
|
78
|
+
Description-Content-Type: text/markdown
|
|
79
|
+
|
|
80
|
+
# OpenBTK — Open Toolkit for Biomedical AI
|
|
81
|
+
|
|
82
|
+
[](LICENSE)
|
|
83
|
+
|
|
84
|
+
**The open-source layer between biomedical data and modern AI.**
|
|
85
|
+
|
|
86
|
+
OpenBTK turns EHR and clinical text into model-ready, **de-identified**, **auditable**
|
|
87
|
+
inputs — and wraps model outputs in **clinical guardrails**. It runs on your laptop or
|
|
88
|
+
behind your firewall, works with any LLM provider, and emits the audit trail your
|
|
89
|
+
regulator and your IRB will ask for.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
> ## 🚧 Status: pre-implementation
|
|
94
|
+
>
|
|
95
|
+
> **`0.0.1` on PyPI is a placeholder. It installs and imports; it does nothing.**
|
|
96
|
+
> It exists to reserve the name and to exercise the release pipeline. Do not
|
|
97
|
+
> build on it.
|
|
98
|
+
>
|
|
99
|
+
> The project is being rebuilt from scratch. A previous attempt produced ~5,200 lines
|
|
100
|
+
> that were never executable — three conflicting package names coexisted in one
|
|
101
|
+
> repository, and no test was ever run against an installed dependency. That code is
|
|
102
|
+
> preserved on the `legacy/v1-snapshot` branch.
|
|
103
|
+
>
|
|
104
|
+
> Specification, architecture and planning are complete; the core framework is next.
|
|
105
|
+
> This README will list features when features exist, and not before.
|
|
106
|
+
> See [CHANGELOG.md](CHANGELOG.md).
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Why
|
|
111
|
+
|
|
112
|
+
Building a clinical RAG pipeline in 2026 means six weeks of undifferentiated plumbing:
|
|
113
|
+
a note parser, a PHI de-identifier that actually catches MRNs, chunking that doesn't
|
|
114
|
+
split the Assessment from the Plan, entity linking, code validation, and an audit
|
|
115
|
+
trail you'll be asked for later. Every team rebuilds it. Most get de-identification
|
|
116
|
+
wrong, or pay a vendor.
|
|
117
|
+
|
|
118
|
+
The existing tools each solve one slice. MONAI owns imaging. medspaCy owns rule-based
|
|
119
|
+
clinical text. PyHealth owns predictive modelling over EHR. LangChain owns
|
|
120
|
+
orchestration but treats a FHIR bundle and a blog post as the same thing. Commercial
|
|
121
|
+
platforms solve most of it, behind a licence that excludes academia and early-stage
|
|
122
|
+
teams.
|
|
123
|
+
|
|
124
|
+
**Nothing joins them, and nothing open-source addresses the two things that actually
|
|
125
|
+
gate deployment: is the PHI really gone, and can you prove what happened.**
|
|
126
|
+
|
|
127
|
+
Those two are what OpenBTK is for.
|
|
128
|
+
|
|
129
|
+
## Design commitments
|
|
130
|
+
|
|
131
|
+
- **Domain-aware by default** — chunking that respects clinical sections, retrieval
|
|
132
|
+
that knows two strings can be the same SNOMED concept.
|
|
133
|
+
- **Wrap, don't reinvent** — thin, consistent adapters over medspaCy, scispaCy,
|
|
134
|
+
presidio, `fhir.resources`; net-new code only where nothing adequate exists.
|
|
135
|
+
- **Streaming by default** — memory is `O(batch)`, not `O(corpus)`. Target: stream
|
|
136
|
+
10M notes in under 4 GB RSS.
|
|
137
|
+
- **Light core** — six dependencies, no ML framework. Reading a clinical note should
|
|
138
|
+
not require installing PyTorch.
|
|
139
|
+
- **Safe and provable by construction** — de-identification, guardrails and a run
|
|
140
|
+
manifest are structural, not optional middleware.
|
|
141
|
+
|
|
142
|
+
## Planned scope
|
|
143
|
+
|
|
144
|
+
**v1 — clinical text and EHR/FHIR, taken to production quality.** Loading,
|
|
145
|
+
de-identification, section-aware chunking, entity linking, terminology resolution,
|
|
146
|
+
embedding and LLM providers, retrieval with concept reranking, clinical guardrails,
|
|
147
|
+
evaluation harness, run provenance, config-driven pipelines, CLI.
|
|
148
|
+
|
|
149
|
+
**v2 — imaging, biosignals, genomics, video, audio.** These will **wrap** MONAI, wfdb,
|
|
150
|
+
MNE, pysam and librosa rather than compete with them, and are gated until v1 ships
|
|
151
|
+
with published benchmarks.
|
|
152
|
+
|
|
153
|
+
**Never** — a model zoo, a serving platform, a clinical decision-support system, or a
|
|
154
|
+
dataset distributor.
|
|
155
|
+
|
|
156
|
+
## Documentation
|
|
157
|
+
|
|
158
|
+
Design documents — market research, PRD, architecture, API contract, security and
|
|
159
|
+
compliance, test charter, roadmap and ADRs — are maintained outside this repository
|
|
160
|
+
and are not published here. Public documentation ships with the v0.1 release.
|
|
161
|
+
|
|
162
|
+
## Contributing
|
|
163
|
+
|
|
164
|
+
Not yet open for contributions — the foundation is still being laid.
|
|
165
|
+
Contributions open at **v0.1**.
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
Apache 2.0 — see [LICENSE](LICENSE).
|
|
170
|
+
|
|
171
|
+
## Disclaimer
|
|
172
|
+
|
|
173
|
+
OpenBTK is a software toolkit. It is **not a medical device**, **not a clinical
|
|
174
|
+
decision-support system**, and provides **no medical advice**. It does not make its
|
|
175
|
+
users HIPAA- or EU AI Act-compliant — it provides technical controls supporting a
|
|
176
|
+
compliance programme its users own.
|
|
177
|
+
|
|
178
|
+
Datasets requiring credentialed access (MIMIC, eICU, n2c2, TCGA) are **not bundled**.
|
|
179
|
+
Users must obtain their own authorized access.
|
openbtk-0.0.1/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# OpenBTK — Open Toolkit for Biomedical AI
|
|
2
|
+
|
|
3
|
+
[](LICENSE)
|
|
4
|
+
|
|
5
|
+
**The open-source layer between biomedical data and modern AI.**
|
|
6
|
+
|
|
7
|
+
OpenBTK turns EHR and clinical text into model-ready, **de-identified**, **auditable**
|
|
8
|
+
inputs — and wraps model outputs in **clinical guardrails**. It runs on your laptop or
|
|
9
|
+
behind your firewall, works with any LLM provider, and emits the audit trail your
|
|
10
|
+
regulator and your IRB will ask for.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
> ## 🚧 Status: pre-implementation
|
|
15
|
+
>
|
|
16
|
+
> **`0.0.1` on PyPI is a placeholder. It installs and imports; it does nothing.**
|
|
17
|
+
> It exists to reserve the name and to exercise the release pipeline. Do not
|
|
18
|
+
> build on it.
|
|
19
|
+
>
|
|
20
|
+
> The project is being rebuilt from scratch. A previous attempt produced ~5,200 lines
|
|
21
|
+
> that were never executable — three conflicting package names coexisted in one
|
|
22
|
+
> repository, and no test was ever run against an installed dependency. That code is
|
|
23
|
+
> preserved on the `legacy/v1-snapshot` branch.
|
|
24
|
+
>
|
|
25
|
+
> Specification, architecture and planning are complete; the core framework is next.
|
|
26
|
+
> This README will list features when features exist, and not before.
|
|
27
|
+
> See [CHANGELOG.md](CHANGELOG.md).
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Why
|
|
32
|
+
|
|
33
|
+
Building a clinical RAG pipeline in 2026 means six weeks of undifferentiated plumbing:
|
|
34
|
+
a note parser, a PHI de-identifier that actually catches MRNs, chunking that doesn't
|
|
35
|
+
split the Assessment from the Plan, entity linking, code validation, and an audit
|
|
36
|
+
trail you'll be asked for later. Every team rebuilds it. Most get de-identification
|
|
37
|
+
wrong, or pay a vendor.
|
|
38
|
+
|
|
39
|
+
The existing tools each solve one slice. MONAI owns imaging. medspaCy owns rule-based
|
|
40
|
+
clinical text. PyHealth owns predictive modelling over EHR. LangChain owns
|
|
41
|
+
orchestration but treats a FHIR bundle and a blog post as the same thing. Commercial
|
|
42
|
+
platforms solve most of it, behind a licence that excludes academia and early-stage
|
|
43
|
+
teams.
|
|
44
|
+
|
|
45
|
+
**Nothing joins them, and nothing open-source addresses the two things that actually
|
|
46
|
+
gate deployment: is the PHI really gone, and can you prove what happened.**
|
|
47
|
+
|
|
48
|
+
Those two are what OpenBTK is for.
|
|
49
|
+
|
|
50
|
+
## Design commitments
|
|
51
|
+
|
|
52
|
+
- **Domain-aware by default** — chunking that respects clinical sections, retrieval
|
|
53
|
+
that knows two strings can be the same SNOMED concept.
|
|
54
|
+
- **Wrap, don't reinvent** — thin, consistent adapters over medspaCy, scispaCy,
|
|
55
|
+
presidio, `fhir.resources`; net-new code only where nothing adequate exists.
|
|
56
|
+
- **Streaming by default** — memory is `O(batch)`, not `O(corpus)`. Target: stream
|
|
57
|
+
10M notes in under 4 GB RSS.
|
|
58
|
+
- **Light core** — six dependencies, no ML framework. Reading a clinical note should
|
|
59
|
+
not require installing PyTorch.
|
|
60
|
+
- **Safe and provable by construction** — de-identification, guardrails and a run
|
|
61
|
+
manifest are structural, not optional middleware.
|
|
62
|
+
|
|
63
|
+
## Planned scope
|
|
64
|
+
|
|
65
|
+
**v1 — clinical text and EHR/FHIR, taken to production quality.** Loading,
|
|
66
|
+
de-identification, section-aware chunking, entity linking, terminology resolution,
|
|
67
|
+
embedding and LLM providers, retrieval with concept reranking, clinical guardrails,
|
|
68
|
+
evaluation harness, run provenance, config-driven pipelines, CLI.
|
|
69
|
+
|
|
70
|
+
**v2 — imaging, biosignals, genomics, video, audio.** These will **wrap** MONAI, wfdb,
|
|
71
|
+
MNE, pysam and librosa rather than compete with them, and are gated until v1 ships
|
|
72
|
+
with published benchmarks.
|
|
73
|
+
|
|
74
|
+
**Never** — a model zoo, a serving platform, a clinical decision-support system, or a
|
|
75
|
+
dataset distributor.
|
|
76
|
+
|
|
77
|
+
## Documentation
|
|
78
|
+
|
|
79
|
+
Design documents — market research, PRD, architecture, API contract, security and
|
|
80
|
+
compliance, test charter, roadmap and ADRs — are maintained outside this repository
|
|
81
|
+
and are not published here. Public documentation ships with the v0.1 release.
|
|
82
|
+
|
|
83
|
+
## Contributing
|
|
84
|
+
|
|
85
|
+
Not yet open for contributions — the foundation is still being laid.
|
|
86
|
+
Contributions open at **v0.1**.
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
Apache 2.0 — see [LICENSE](LICENSE).
|
|
91
|
+
|
|
92
|
+
## Disclaimer
|
|
93
|
+
|
|
94
|
+
OpenBTK is a software toolkit. It is **not a medical device**, **not a clinical
|
|
95
|
+
decision-support system**, and provides **no medical advice**. It does not make its
|
|
96
|
+
users HIPAA- or EU AI Act-compliant — it provides technical controls supporting a
|
|
97
|
+
compliance programme its users own.
|
|
98
|
+
|
|
99
|
+
Datasets requiring credentialed access (MIMIC, eICU, n2c2, TCGA) are **not bundled**.
|
|
100
|
+
Users must obtain their own authorized access.
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# ---------------------------------------------------------------------------
|
|
2
|
+
# Build
|
|
3
|
+
# ---------------------------------------------------------------------------
|
|
4
|
+
[build-system]
|
|
5
|
+
requires = ["hatchling>=1.25", "hatch-vcs>=0.4"]
|
|
6
|
+
build-backend = "hatchling.build"
|
|
7
|
+
|
|
8
|
+
[project]
|
|
9
|
+
name = "openbtk"
|
|
10
|
+
dynamic = ["version"]
|
|
11
|
+
description = "The open-source layer between biomedical data and modern AI: de-identified, auditable, model-ready inputs with clinical guardrails."
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
license = "Apache-2.0"
|
|
14
|
+
license-files = ["LICENSE"]
|
|
15
|
+
requires-python = ">=3.11"
|
|
16
|
+
authors = [{ name = "OpenBTK Contributors" }]
|
|
17
|
+
keywords = [
|
|
18
|
+
"biomedical", "healthcare", "clinical-nlp", "de-identification",
|
|
19
|
+
"phi", "ehr", "fhir", "omop", "llm", "rag", "hipaa",
|
|
20
|
+
]
|
|
21
|
+
classifiers = [
|
|
22
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
23
|
+
"Intended Audience :: Healthcare Industry",
|
|
24
|
+
"Intended Audience :: Science/Research",
|
|
25
|
+
"License :: OSI Approved :: Apache Software License",
|
|
26
|
+
"Programming Language :: Python :: 3.11",
|
|
27
|
+
"Programming Language :: Python :: 3.12",
|
|
28
|
+
"Programming Language :: Python :: 3.13",
|
|
29
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
30
|
+
"Topic :: Scientific/Engineering :: Medical Science Apps.",
|
|
31
|
+
"Typing :: Typed",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
# ---------------------------------------------------------------------------
|
|
35
|
+
# Core dependencies -- HARD LIMIT OF SIX. A seventh requires an ADR.
|
|
36
|
+
# Deliberately absent: langchain, langgraph, torch, transformers, spacy.
|
|
37
|
+
# Reading a clinical note must not require an ML framework. See ADR-0001.
|
|
38
|
+
# ---------------------------------------------------------------------------
|
|
39
|
+
dependencies = [
|
|
40
|
+
"pydantic>=2.5",
|
|
41
|
+
"numpy>=1.26",
|
|
42
|
+
"structlog>=24.0",
|
|
43
|
+
"pyyaml>=6.0",
|
|
44
|
+
"httpx>=0.27",
|
|
45
|
+
"typing-extensions>=4.12",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[project.optional-dependencies]
|
|
49
|
+
text = [
|
|
50
|
+
"scispacy>=0.5",
|
|
51
|
+
"medspacy>=1.0",
|
|
52
|
+
"presidio-analyzer>=2.2",
|
|
53
|
+
"presidio-anonymizer>=2.2",
|
|
54
|
+
"transformers>=4.40",
|
|
55
|
+
]
|
|
56
|
+
ehr = [
|
|
57
|
+
"fhir.resources>=7.1",
|
|
58
|
+
"pyarrow>=16.0",
|
|
59
|
+
"pandas>=2.2",
|
|
60
|
+
"hl7apy>=1.3",
|
|
61
|
+
]
|
|
62
|
+
retrieval = [
|
|
63
|
+
"faiss-cpu>=1.8",
|
|
64
|
+
"chromadb>=0.5",
|
|
65
|
+
]
|
|
66
|
+
llms = [
|
|
67
|
+
"openai>=1.30",
|
|
68
|
+
"anthropic>=0.30",
|
|
69
|
+
]
|
|
70
|
+
# First candidate for carve-out into its own distribution: its version must be
|
|
71
|
+
# free to track langchain-core independently of ours. See ADR-0002.
|
|
72
|
+
langchain = [
|
|
73
|
+
"langchain-core>=0.3",
|
|
74
|
+
]
|
|
75
|
+
all = ["openbtk[text,ehr,retrieval,llms,langchain]"]
|
|
76
|
+
dev = [
|
|
77
|
+
"pytest>=8.0",
|
|
78
|
+
"pytest-cov>=5.0",
|
|
79
|
+
"pytest-mock>=3.14",
|
|
80
|
+
"hypothesis>=6.100",
|
|
81
|
+
"mypy>=1.10",
|
|
82
|
+
"ruff>=0.6",
|
|
83
|
+
"import-linter>=2.0",
|
|
84
|
+
"pre-commit>=3.7",
|
|
85
|
+
"faker>=25.0",
|
|
86
|
+
"types-PyYAML>=6.0",
|
|
87
|
+
]
|
|
88
|
+
docs = [
|
|
89
|
+
"mkdocs-material>=9.5",
|
|
90
|
+
"mkdocstrings[python]>=0.25",
|
|
91
|
+
"mike>=2.1",
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
[project.urls]
|
|
95
|
+
Homepage = "https://github.com/openbtk/openbtk"
|
|
96
|
+
Repository = "https://github.com/openbtk/openbtk"
|
|
97
|
+
Issues = "https://github.com/openbtk/openbtk/issues"
|
|
98
|
+
|
|
99
|
+
[project.entry-points."openbtk.providers"]
|
|
100
|
+
# Third-party packages register components here in their own pyproject.toml.
|
|
101
|
+
|
|
102
|
+
# ---------------------------------------------------------------------------
|
|
103
|
+
# Versioning -- derived from git tags. There is no version string to forget
|
|
104
|
+
# to bump, and none that can drift from the tag. See docs/08_CICD_RELEASE.md.
|
|
105
|
+
# ---------------------------------------------------------------------------
|
|
106
|
+
[tool.hatch.version]
|
|
107
|
+
source = "vcs"
|
|
108
|
+
fallback-version = "0.0.0"
|
|
109
|
+
|
|
110
|
+
[tool.hatch.build.targets.wheel]
|
|
111
|
+
packages = ["src/openbtk"]
|
|
112
|
+
|
|
113
|
+
[tool.hatch.build.targets.sdist]
|
|
114
|
+
include = ["src/openbtk", "tests", "README.md", "LICENSE"]
|
|
115
|
+
|
|
116
|
+
# ---------------------------------------------------------------------------
|
|
117
|
+
# Ruff
|
|
118
|
+
# ---------------------------------------------------------------------------
|
|
119
|
+
[tool.ruff]
|
|
120
|
+
line-length = 88
|
|
121
|
+
target-version = "py311"
|
|
122
|
+
src = ["src", "tests"]
|
|
123
|
+
|
|
124
|
+
[tool.ruff.lint]
|
|
125
|
+
select = [
|
|
126
|
+
"E", "W", # pycodestyle
|
|
127
|
+
"F", # pyflakes
|
|
128
|
+
"I", # isort
|
|
129
|
+
"N", # pep8-naming
|
|
130
|
+
"UP", # pyupgrade
|
|
131
|
+
"ANN", # flake8-annotations
|
|
132
|
+
"B", # flake8-bugbear
|
|
133
|
+
"SIM", # flake8-simplify
|
|
134
|
+
"TC", # flake8-type-checking
|
|
135
|
+
"RUF", # ruff-specific
|
|
136
|
+
"PTH", # flake8-use-pathlib
|
|
137
|
+
"RET", # flake8-return
|
|
138
|
+
"ARG", # flake8-unused-arguments
|
|
139
|
+
"C4", # flake8-comprehensions
|
|
140
|
+
"DTZ", # flake8-datetimez -- naive clinical timestamps are a real bug class
|
|
141
|
+
"T20", # flake8-print -- no print() in library code
|
|
142
|
+
]
|
|
143
|
+
ignore = [
|
|
144
|
+
"ANN401", # Any permitted where documented in docs/04_API_DESIGN.md section 11.4
|
|
145
|
+
]
|
|
146
|
+
|
|
147
|
+
[tool.ruff.lint.per-file-ignores]
|
|
148
|
+
"tests/**" = ["ANN", "ARG"]
|
|
149
|
+
"src/openbtk/cli/**" = ["T20"] # the CLI prints legitimately
|
|
150
|
+
|
|
151
|
+
[tool.ruff.lint.isort]
|
|
152
|
+
known-first-party = ["openbtk"]
|
|
153
|
+
|
|
154
|
+
[tool.ruff.lint.pydocstyle]
|
|
155
|
+
convention = "google"
|
|
156
|
+
|
|
157
|
+
# ---------------------------------------------------------------------------
|
|
158
|
+
# Mypy
|
|
159
|
+
# ---------------------------------------------------------------------------
|
|
160
|
+
[tool.mypy]
|
|
161
|
+
python_version = "3.11"
|
|
162
|
+
strict = true
|
|
163
|
+
warn_unreachable = true
|
|
164
|
+
files = ["src/openbtk"]
|
|
165
|
+
|
|
166
|
+
[[tool.mypy.overrides]]
|
|
167
|
+
module = [
|
|
168
|
+
"scispacy.*", "medspacy.*", "spacy.*",
|
|
169
|
+
"presidio_analyzer.*", "presidio_anonymizer.*",
|
|
170
|
+
"transformers.*", "fhir.*", "hl7apy.*",
|
|
171
|
+
"faiss.*", "chromadb.*",
|
|
172
|
+
]
|
|
173
|
+
ignore_missing_imports = true
|
|
174
|
+
|
|
175
|
+
# ---------------------------------------------------------------------------
|
|
176
|
+
# Import boundaries -- makes the layering in docs/03_ARCHITECTURE.md section 2
|
|
177
|
+
# executable rather than aspirational.
|
|
178
|
+
# ---------------------------------------------------------------------------
|
|
179
|
+
[tool.importlinter]
|
|
180
|
+
root_package = "openbtk"
|
|
181
|
+
# Required so the forbidden-modules contract can see external packages.
|
|
182
|
+
include_external_packages = true
|
|
183
|
+
|
|
184
|
+
[[tool.importlinter.contracts]]
|
|
185
|
+
name = "Layered architecture -- imports go strictly downward"
|
|
186
|
+
type = "layers"
|
|
187
|
+
layers = [
|
|
188
|
+
"openbtk.cli",
|
|
189
|
+
"openbtk.pipelines",
|
|
190
|
+
"openbtk.data",
|
|
191
|
+
"openbtk.deid",
|
|
192
|
+
"openbtk.core",
|
|
193
|
+
]
|
|
194
|
+
|
|
195
|
+
[[tool.importlinter.contracts]]
|
|
196
|
+
name = "Modalities are independent of one another"
|
|
197
|
+
type = "independence"
|
|
198
|
+
modules = [
|
|
199
|
+
"openbtk.data.clinical_text",
|
|
200
|
+
"openbtk.data.ehr",
|
|
201
|
+
]
|
|
202
|
+
|
|
203
|
+
[[tool.importlinter.contracts]]
|
|
204
|
+
name = "LangChain confined to its adapter (ADR-0001)"
|
|
205
|
+
type = "forbidden"
|
|
206
|
+
source_modules = [
|
|
207
|
+
"openbtk.core",
|
|
208
|
+
"openbtk.data",
|
|
209
|
+
"openbtk.deid",
|
|
210
|
+
"openbtk.pipelines",
|
|
211
|
+
"openbtk.guardrails",
|
|
212
|
+
"openbtk.terminology",
|
|
213
|
+
"openbtk.cli",
|
|
214
|
+
]
|
|
215
|
+
forbidden_modules = ["langchain", "langchain_core", "langgraph"]
|
|
216
|
+
|
|
217
|
+
# ---------------------------------------------------------------------------
|
|
218
|
+
# Pytest
|
|
219
|
+
# ---------------------------------------------------------------------------
|
|
220
|
+
[tool.pytest.ini_options]
|
|
221
|
+
minversion = "8.0"
|
|
222
|
+
testpaths = ["tests"]
|
|
223
|
+
addopts = "-ra --strict-markers --strict-config"
|
|
224
|
+
markers = [
|
|
225
|
+
"slow: requires model downloads (skipped unless OPENBTK_SLOW_TESTS=1)",
|
|
226
|
+
"network: requires network access",
|
|
227
|
+
"gpu: requires CUDA",
|
|
228
|
+
"benchmark: performance test, nightly only",
|
|
229
|
+
"credentialed: needs user-supplied restricted data (i2b2/MIMIC); always skipped in CI",
|
|
230
|
+
]
|
|
231
|
+
filterwarnings = ["error", "ignore::DeprecationWarning"]
|
|
232
|
+
|
|
233
|
+
[tool.coverage.run]
|
|
234
|
+
source = ["openbtk"]
|
|
235
|
+
branch = true
|
|
236
|
+
|
|
237
|
+
[tool.coverage.report]
|
|
238
|
+
show_missing = true
|
|
239
|
+
exclude_lines = [
|
|
240
|
+
"pragma: no cover",
|
|
241
|
+
"raise NotImplementedError",
|
|
242
|
+
"if TYPE_CHECKING:",
|
|
243
|
+
"@abstractmethod",
|
|
244
|
+
]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""OpenBTK -- the open-source layer between biomedical data and modern AI.
|
|
2
|
+
|
|
3
|
+
Turns EHR and clinical text into model-ready, de-identified, auditable inputs,
|
|
4
|
+
and wraps model outputs in clinical guardrails.
|
|
5
|
+
|
|
6
|
+
This module is deliberately minimal. It must import in under 500ms with zero
|
|
7
|
+
optional dependencies installed, so it pulls in no modality module and nothing
|
|
8
|
+
heavy. Reach everything else through submodules::
|
|
9
|
+
|
|
10
|
+
from openbtk.deid import DeidEngine
|
|
11
|
+
from openbtk.data.clinical_text import SectionAwareChunker
|
|
12
|
+
|
|
13
|
+
Public API surface is defined in docs/04_API_DESIGN.md. Registry keys are part
|
|
14
|
+
of that surface and are permanent once released.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
__all__ = ["__version__"]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _detect_version() -> str:
|
|
23
|
+
"""Resolve the installed package version from distribution metadata.
|
|
24
|
+
|
|
25
|
+
Falls back to a sentinel for a source tree that has never been installed.
|
|
26
|
+
"""
|
|
27
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
28
|
+
|
|
29
|
+
try:
|
|
30
|
+
return version("openbtk")
|
|
31
|
+
except PackageNotFoundError:
|
|
32
|
+
return "0.0.0.dev0+unknown"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
__version__: str = _detect_version()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Command-line interface."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Embedding providers, biomedical and general."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Optional interoperability adapters."""
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Vector stores and rerankers, including concept-aware reranking."""
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"""Installation and import integrity.
|
|
2
|
+
|
|
3
|
+
These tests exist because the v1 codebase was never importable: three package
|
|
4
|
+
names coexisted (the directory ``src/``, imports of ``openbtk.*``, and
|
|
5
|
+
``opentbtk.*`` -- a typo appearing 79 times), and ``pyproject.toml`` declared a
|
|
6
|
+
wheel package that was absent from disk. Nothing caught it because the only
|
|
7
|
+
verification ever run was ``py_compile``, which resolves no imports.
|
|
8
|
+
|
|
9
|
+
Every test here would have failed on the v1 tree. See ADR-0003.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import importlib
|
|
15
|
+
import subprocess
|
|
16
|
+
import sys
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
|
|
19
|
+
import pytest
|
|
20
|
+
|
|
21
|
+
REPO_ROOT = Path(__file__).resolve().parents[2]
|
|
22
|
+
|
|
23
|
+
# Every package that must import with ZERO optional dependencies installed.
|
|
24
|
+
PUBLIC_MODULES = [
|
|
25
|
+
"openbtk",
|
|
26
|
+
"openbtk.core",
|
|
27
|
+
"openbtk.deid",
|
|
28
|
+
"openbtk.deid.recognizers",
|
|
29
|
+
"openbtk.data",
|
|
30
|
+
"openbtk.data.clinical_text",
|
|
31
|
+
"openbtk.data.ehr",
|
|
32
|
+
"openbtk.terminology",
|
|
33
|
+
"openbtk.embeddings",
|
|
34
|
+
"openbtk.llms",
|
|
35
|
+
"openbtk.retrieval",
|
|
36
|
+
"openbtk.guardrails",
|
|
37
|
+
"openbtk.pipelines",
|
|
38
|
+
"openbtk.eval",
|
|
39
|
+
"openbtk.integrations",
|
|
40
|
+
"openbtk.cli",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def test_package_imports() -> None:
|
|
45
|
+
"""The package imports at all. This is not a trivial assertion here."""
|
|
46
|
+
import openbtk
|
|
47
|
+
|
|
48
|
+
assert openbtk is not None
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_version_is_a_string() -> None:
|
|
52
|
+
import openbtk
|
|
53
|
+
|
|
54
|
+
assert isinstance(openbtk.__version__, str)
|
|
55
|
+
assert openbtk.__version__
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@pytest.mark.parametrize("module_name", PUBLIC_MODULES)
|
|
59
|
+
def test_public_module_imports_with_zero_extras(module_name: str) -> None:
|
|
60
|
+
"""Importing any public module must not require an optional dependency.
|
|
61
|
+
|
|
62
|
+
A heavy import at module scope (``import torch``, ``import spacy``) breaks
|
|
63
|
+
the zero-extras install. Heavy imports belong inside methods, behind
|
|
64
|
+
``openbtk.core._lazy.require()``.
|
|
65
|
+
"""
|
|
66
|
+
module = importlib.import_module(module_name)
|
|
67
|
+
assert module.__doc__, f"{module_name} is missing a module docstring"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def test_package_is_installed_not_path_relative() -> None:
|
|
71
|
+
"""The imported package comes from an installation, not the CWD.
|
|
72
|
+
|
|
73
|
+
Run from outside the repository (as CI does), a path-relative import cannot
|
|
74
|
+
satisfy this -- which is the entire point of the src/ layout.
|
|
75
|
+
"""
|
|
76
|
+
import openbtk
|
|
77
|
+
|
|
78
|
+
location = Path(openbtk.__file__).resolve()
|
|
79
|
+
assert location.name == "__init__.py"
|
|
80
|
+
assert location.parent.name == "openbtk"
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def test_imports_from_a_different_working_directory(tmp_path: Path) -> None:
|
|
84
|
+
"""Import succeeds with the CWD outside the repository."""
|
|
85
|
+
result = subprocess.run(
|
|
86
|
+
[sys.executable, "-c", "import openbtk; print(openbtk.__version__)"],
|
|
87
|
+
cwd=tmp_path,
|
|
88
|
+
capture_output=True,
|
|
89
|
+
text=True,
|
|
90
|
+
check=False,
|
|
91
|
+
)
|
|
92
|
+
assert result.returncode == 0, result.stderr
|
|
93
|
+
assert result.stdout.strip()
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def test_py_typed_marker_is_present() -> None:
|
|
97
|
+
"""PEP 561 marker, so downstream mypy sees our annotations."""
|
|
98
|
+
import openbtk
|
|
99
|
+
|
|
100
|
+
assert (Path(openbtk.__file__).parent / "py.typed").is_file()
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def test_no_forbidden_package_names() -> None:
|
|
104
|
+
"""No ``opentbtk`` typo, no ``src.`` imports. The v1 killer.
|
|
105
|
+
|
|
106
|
+
A pre-commit hook and a CI step enforce this too; this test makes it fail
|
|
107
|
+
in the suite as well, so it cannot be bypassed with --no-verify.
|
|
108
|
+
"""
|
|
109
|
+
self_path = Path(__file__).resolve()
|
|
110
|
+
offenders: list[str] = []
|
|
111
|
+
for path in REPO_ROOT.rglob("*.py"):
|
|
112
|
+
if any(
|
|
113
|
+
part in {".git", ".venv", "build", "dist", "__pycache__"}
|
|
114
|
+
for part in path.parts
|
|
115
|
+
):
|
|
116
|
+
continue
|
|
117
|
+
if path.resolve() == self_path:
|
|
118
|
+
continue # this file names the forbidden strings in order to detect them
|
|
119
|
+
text = path.read_text(encoding="utf-8", errors="replace")
|
|
120
|
+
for lineno, line in enumerate(text.splitlines(), 1):
|
|
121
|
+
if "opentbtk" in line or "from src." in line or "import src." in line:
|
|
122
|
+
offenders.append(
|
|
123
|
+
f"{path.relative_to(REPO_ROOT)}:{lineno}: {line.strip()}"
|
|
124
|
+
)
|
|
125
|
+
assert not offenders, "Forbidden package names found:\n" + "\n".join(offenders)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def test_core_dependency_budget() -> None:
|
|
129
|
+
"""Core declares at most six dependencies. A seventh requires an ADR.
|
|
130
|
+
|
|
131
|
+
Guards the promise that reading a clinical note does not pull in an ML
|
|
132
|
+
framework. See docs/09_CODING_STANDARDS.md section 2 and ADR-0001.
|
|
133
|
+
"""
|
|
134
|
+
import tomllib
|
|
135
|
+
|
|
136
|
+
pyproject = tomllib.loads(
|
|
137
|
+
(REPO_ROOT / "pyproject.toml").read_text(encoding="utf-8")
|
|
138
|
+
)
|
|
139
|
+
deps = pyproject["project"]["dependencies"]
|
|
140
|
+
assert len(deps) <= 6, f"Core dependency budget exceeded: {deps}"
|
|
141
|
+
|
|
142
|
+
banned = {
|
|
143
|
+
"langchain",
|
|
144
|
+
"langchain-core",
|
|
145
|
+
"langgraph",
|
|
146
|
+
"torch",
|
|
147
|
+
"transformers",
|
|
148
|
+
"spacy",
|
|
149
|
+
}
|
|
150
|
+
names = {d.split(">")[0].split("=")[0].split("[")[0].strip().lower() for d in deps}
|
|
151
|
+
assert not (names & banned), f"Heavy dependency in core: {names & banned}"
|