cvd-risk 0.1.48__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.

Potentially problematic release.


This version of cvd-risk might be problematic. Click here for more details.

Files changed (207) hide show
  1. cvd_risk-0.1.48/.github/workflows/build-wheels.yml +151 -0
  2. cvd_risk-0.1.48/.github/workflows/ci.yml +60 -0
  3. cvd_risk-0.1.48/.github/workflows/release.yml +92 -0
  4. cvd_risk-0.1.48/.gitignore +142 -0
  5. cvd_risk-0.1.48/.pre-commit-config.yaml +34 -0
  6. cvd_risk-0.1.48/BUILD_README.md +193 -0
  7. cvd_risk-0.1.48/CHANGELOG.md +83 -0
  8. cvd_risk-0.1.48/CITATION.cff +27 -0
  9. cvd_risk-0.1.48/CONTRIBUTING.md +63 -0
  10. cvd_risk-0.1.48/LICENSE +22 -0
  11. cvd_risk-0.1.48/Makefile +51 -0
  12. cvd_risk-0.1.48/PKG-INFO +465 -0
  13. cvd_risk-0.1.48/PROJECT_STATUS.md +121 -0
  14. cvd_risk-0.1.48/README.md +410 -0
  15. cvd_risk-0.1.48/benchmarks/benchmark_models.py +136 -0
  16. cvd_risk-0.1.48/build_script.py +136 -0
  17. cvd_risk-0.1.48/data/edge_case_patients.csv +51 -0
  18. cvd_risk-0.1.48/data/edge_case_patients.json +852 -0
  19. cvd_risk-0.1.48/data/fake_patients.csv +1001 -0
  20. cvd_risk-0.1.48/data/fake_patients.json +15002 -0
  21. cvd_risk-0.1.48/data/reference/README.md +38 -0
  22. cvd_risk-0.1.48/demo/.streamlit/config.toml +10 -0
  23. cvd_risk-0.1.48/demo/README.md +24 -0
  24. cvd_risk-0.1.48/demo/requirements.txt +6 -0
  25. cvd_risk-0.1.48/demo/streamlit_app.py +613 -0
  26. cvd_risk-0.1.48/docs/api/core.rst +26 -0
  27. cvd_risk-0.1.48/docs/api/index.rst +19 -0
  28. cvd_risk-0.1.48/docs/api/models.rst +293 -0
  29. cvd_risk-0.1.48/docs/conf.py +35 -0
  30. cvd_risk-0.1.48/docs/index.rst +20 -0
  31. cvd_risk-0.1.48/docs/installation.rst +50 -0
  32. cvd_risk-0.1.48/docs/pycvdrisk-github-header-banner.png +0 -0
  33. cvd_risk-0.1.48/docs/quickstart.rst +78 -0
  34. cvd_risk-0.1.48/examples/README.md +159 -0
  35. cvd_risk-0.1.48/examples/generate_edge_case_patients.py +481 -0
  36. cvd_risk-0.1.48/examples/generate_fake_patients.py +217 -0
  37. cvd_risk-0.1.48/examples/score2_example.py +159 -0
  38. cvd_risk-0.1.48/examples/validate_edge_cases.py +226 -0
  39. cvd_risk-0.1.48/examples/validate_models_with_fake_data.py +147 -0
  40. cvd_risk-0.1.48/notebooks/README.md +83 -0
  41. cvd_risk-0.1.48/notebooks/ascvd/ASCVD_Example.ipynb +67 -0
  42. cvd_risk-0.1.48/notebooks/framingham/Framingham_Example.ipynb +74 -0
  43. cvd_risk-0.1.48/notebooks/globorisk/Globorisk_Example.ipynb +46 -0
  44. cvd_risk-0.1.48/notebooks/qrisk3/QRISK3_Example.ipynb +51 -0
  45. cvd_risk-0.1.48/notebooks/score2/SCORE2_Example.ipynb +226 -0
  46. cvd_risk-0.1.48/notebooks/smart2/SMART2_Example.ipynb +48 -0
  47. cvd_risk-0.1.48/notebooks/who/WHO_Example.ipynb +46 -0
  48. cvd_risk-0.1.48/pyproject.toml +199 -0
  49. cvd_risk-0.1.48/release.py +197 -0
  50. cvd_risk-0.1.48/src/cvd_risk/__init__.py +84 -0
  51. cvd_risk-0.1.48/src/cvd_risk/core/__init__.py +11 -0
  52. cvd_risk-0.1.48/src/cvd_risk/core/base.py +162 -0
  53. cvd_risk-0.1.48/src/cvd_risk/core/validation.py +324 -0
  54. cvd_risk-0.1.48/src/cvd_risk/models/__init__.py +133 -0
  55. cvd_risk-0.1.48/src/cvd_risk/models/aric_update/__init__.py +3 -0
  56. cvd_risk-0.1.48/src/cvd_risk/models/aric_update/aric_update.py +148 -0
  57. cvd_risk-0.1.48/src/cvd_risk/models/ascvd/README.md +101 -0
  58. cvd_risk-0.1.48/src/cvd_risk/models/ascvd/__init__.py +5 -0
  59. cvd_risk-0.1.48/src/cvd_risk/models/ascvd/ascvd.py +446 -0
  60. cvd_risk-0.1.48/src/cvd_risk/models/assign/README.md +91 -0
  61. cvd_risk-0.1.48/src/cvd_risk/models/assign/__init__.py +5 -0
  62. cvd_risk-0.1.48/src/cvd_risk/models/assign/assign.py +349 -0
  63. cvd_risk-0.1.48/src/cvd_risk/models/cambridge/__init__.py +3 -0
  64. cvd_risk-0.1.48/src/cvd_risk/models/cambridge/cambridge.py +115 -0
  65. cvd_risk-0.1.48/src/cvd_risk/models/cardia/__init__.py +3 -0
  66. cvd_risk-0.1.48/src/cvd_risk/models/cardia/cardia.py +77 -0
  67. cvd_risk-0.1.48/src/cvd_risk/models/cha2ds2_vasc/__init__.py +3 -0
  68. cvd_risk-0.1.48/src/cvd_risk/models/cha2ds2_vasc/cha2ds2_vasc.py +285 -0
  69. cvd_risk-0.1.48/src/cvd_risk/models/chads2/__init__.py +3 -0
  70. cvd_risk-0.1.48/src/cvd_risk/models/chads2/chads2.py +248 -0
  71. cvd_risk-0.1.48/src/cvd_risk/models/dad_score/__init__.py +3 -0
  72. cvd_risk-0.1.48/src/cvd_risk/models/dad_score/dad_score.py +353 -0
  73. cvd_risk-0.1.48/src/cvd_risk/models/dial2/README.md +75 -0
  74. cvd_risk-0.1.48/src/cvd_risk/models/dial2/__init__.py +5 -0
  75. cvd_risk-0.1.48/src/cvd_risk/models/dial2/dial2.py +487 -0
  76. cvd_risk-0.1.48/src/cvd_risk/models/dundee/__init__.py +3 -0
  77. cvd_risk-0.1.48/src/cvd_risk/models/dundee/dundee.py +110 -0
  78. cvd_risk-0.1.48/src/cvd_risk/models/edacs/README.md +77 -0
  79. cvd_risk-0.1.48/src/cvd_risk/models/edacs/__init__.py +5 -0
  80. cvd_risk-0.1.48/src/cvd_risk/models/edacs/edacs.py +350 -0
  81. cvd_risk-0.1.48/src/cvd_risk/models/epic_norfolk/__init__.py +3 -0
  82. cvd_risk-0.1.48/src/cvd_risk/models/epic_norfolk/epic_norfolk.py +84 -0
  83. cvd_risk-0.1.48/src/cvd_risk/models/finrisk/__init__.py +3 -0
  84. cvd_risk-0.1.48/src/cvd_risk/models/finrisk/finrisk.py +287 -0
  85. cvd_risk-0.1.48/src/cvd_risk/models/framingham/README.md +180 -0
  86. cvd_risk-0.1.48/src/cvd_risk/models/framingham/__init__.py +5 -0
  87. cvd_risk-0.1.48/src/cvd_risk/models/framingham/framingham.py +360 -0
  88. cvd_risk-0.1.48/src/cvd_risk/models/globorisk/README.md +91 -0
  89. cvd_risk-0.1.48/src/cvd_risk/models/globorisk/__init__.py +5 -0
  90. cvd_risk-0.1.48/src/cvd_risk/models/globorisk/globorisk.py +508 -0
  91. cvd_risk-0.1.48/src/cvd_risk/models/globorisk/globorisk_data.pkl.xz +0 -0
  92. cvd_risk-0.1.48/src/cvd_risk/models/grace2/README.md +94 -0
  93. cvd_risk-0.1.48/src/cvd_risk/models/grace2/__init__.py +5 -0
  94. cvd_risk-0.1.48/src/cvd_risk/models/grace2/grace2.py +407 -0
  95. cvd_risk-0.1.48/src/cvd_risk/models/gulf_race/__init__.py +3 -0
  96. cvd_risk-0.1.48/src/cvd_risk/models/gulf_race/gulf_race.py +137 -0
  97. cvd_risk-0.1.48/src/cvd_risk/models/has_bled/__init__.py +3 -0
  98. cvd_risk-0.1.48/src/cvd_risk/models/has_bled/has_bled.py +299 -0
  99. cvd_risk-0.1.48/src/cvd_risk/models/heart/README.md +98 -0
  100. cvd_risk-0.1.48/src/cvd_risk/models/heart/__init__.py +5 -0
  101. cvd_risk-0.1.48/src/cvd_risk/models/heart/heart.py +428 -0
  102. cvd_risk-0.1.48/src/cvd_risk/models/heinz_nixdorf/__init__.py +3 -0
  103. cvd_risk-0.1.48/src/cvd_risk/models/heinz_nixdorf/heinz_nixdorf.py +81 -0
  104. cvd_risk-0.1.48/src/cvd_risk/models/interheart/__init__.py +3 -0
  105. cvd_risk-0.1.48/src/cvd_risk/models/interheart/interheart.py +370 -0
  106. cvd_risk-0.1.48/src/cvd_risk/models/jackson_heart/__init__.py +3 -0
  107. cvd_risk-0.1.48/src/cvd_risk/models/jackson_heart/jackson_heart.py +77 -0
  108. cvd_risk-0.1.48/src/cvd_risk/models/lifecvd2/README.md +63 -0
  109. cvd_risk-0.1.48/src/cvd_risk/models/lifecvd2/__init__.py +6 -0
  110. cvd_risk-0.1.48/src/cvd_risk/models/lifecvd2/lifecvd2.py +564 -0
  111. cvd_risk-0.1.48/src/cvd_risk/models/lifecvd2/sample.py +352 -0
  112. cvd_risk-0.1.48/src/cvd_risk/models/malaysian_cvd/__init__.py +3 -0
  113. cvd_risk-0.1.48/src/cvd_risk/models/malaysian_cvd/malaysian_cvd.py +131 -0
  114. cvd_risk-0.1.48/src/cvd_risk/models/new_zealand/__init__.py +3 -0
  115. cvd_risk-0.1.48/src/cvd_risk/models/new_zealand/new_zealand.py +142 -0
  116. cvd_risk-0.1.48/src/cvd_risk/models/predict/__init__.py +3 -0
  117. cvd_risk-0.1.48/src/cvd_risk/models/predict/predict.py +321 -0
  118. cvd_risk-0.1.48/src/cvd_risk/models/prevent/README.md +61 -0
  119. cvd_risk-0.1.48/src/cvd_risk/models/prevent/__init__.py +6 -0
  120. cvd_risk-0.1.48/src/cvd_risk/models/prevent/prevent.py +481 -0
  121. cvd_risk-0.1.48/src/cvd_risk/models/procam/__init__.py +3 -0
  122. cvd_risk-0.1.48/src/cvd_risk/models/procam/procam.py +304 -0
  123. cvd_risk-0.1.48/src/cvd_risk/models/progetto_cuore/__init__.py +3 -0
  124. cvd_risk-0.1.48/src/cvd_risk/models/progetto_cuore/progetto_cuore.py +265 -0
  125. cvd_risk-0.1.48/src/cvd_risk/models/qrisk2/README.md +54 -0
  126. cvd_risk-0.1.48/src/cvd_risk/models/qrisk2/__init__.py +6 -0
  127. cvd_risk-0.1.48/src/cvd_risk/models/qrisk2/qrisk2.py +612 -0
  128. cvd_risk-0.1.48/src/cvd_risk/models/qrisk3/README.md +101 -0
  129. cvd_risk-0.1.48/src/cvd_risk/models/qrisk3/__init__.py +5 -0
  130. cvd_risk-0.1.48/src/cvd_risk/models/qrisk3/qrisk3.py +744 -0
  131. cvd_risk-0.1.48/src/cvd_risk/models/regicor/__init__.py +3 -0
  132. cvd_risk-0.1.48/src/cvd_risk/models/regicor/regicor.py +251 -0
  133. cvd_risk-0.1.48/src/cvd_risk/models/reynolds/__init__.py +3 -0
  134. cvd_risk-0.1.48/src/cvd_risk/models/reynolds/reynolds.py +288 -0
  135. cvd_risk-0.1.48/src/cvd_risk/models/risc_score/__init__.py +3 -0
  136. cvd_risk-0.1.48/src/cvd_risk/models/risc_score/risc_score.py +173 -0
  137. cvd_risk-0.1.48/src/cvd_risk/models/rotterdam_study/__init__.py +3 -0
  138. cvd_risk-0.1.48/src/cvd_risk/models/rotterdam_study/rotterdam_study.py +77 -0
  139. cvd_risk-0.1.48/src/cvd_risk/models/score/README.md +49 -0
  140. cvd_risk-0.1.48/src/cvd_risk/models/score/__init__.py +6 -0
  141. cvd_risk-0.1.48/src/cvd_risk/models/score/score.py +280 -0
  142. cvd_risk-0.1.48/src/cvd_risk/models/score2/README.md +109 -0
  143. cvd_risk-0.1.48/src/cvd_risk/models/score2/__init__.py +5 -0
  144. cvd_risk-0.1.48/src/cvd_risk/models/score2/score2.py +278 -0
  145. cvd_risk-0.1.48/src/cvd_risk/models/score2asia/README.md +84 -0
  146. cvd_risk-0.1.48/src/cvd_risk/models/score2asia/__init__.py +5 -0
  147. cvd_risk-0.1.48/src/cvd_risk/models/score2asia/score2asia.py +614 -0
  148. cvd_risk-0.1.48/src/cvd_risk/models/score2ckd/README.md +54 -0
  149. cvd_risk-0.1.48/src/cvd_risk/models/score2ckd/__init__.py +6 -0
  150. cvd_risk-0.1.48/src/cvd_risk/models/score2ckd/score2ckd.py +688 -0
  151. cvd_risk-0.1.48/src/cvd_risk/models/score2dm/README.md +54 -0
  152. cvd_risk-0.1.48/src/cvd_risk/models/score2dm/__init__.py +6 -0
  153. cvd_risk-0.1.48/src/cvd_risk/models/score2dm/score2dm.py +374 -0
  154. cvd_risk-0.1.48/src/cvd_risk/models/score2op/README.md +53 -0
  155. cvd_risk-0.1.48/src/cvd_risk/models/score2op/__init__.py +6 -0
  156. cvd_risk-0.1.48/src/cvd_risk/models/score2op/score2op.py +277 -0
  157. cvd_risk-0.1.48/src/cvd_risk/models/singapore/__init__.py +3 -0
  158. cvd_risk-0.1.48/src/cvd_risk/models/singapore/singapore.py +101 -0
  159. cvd_risk-0.1.48/src/cvd_risk/models/smart2/README.md +81 -0
  160. cvd_risk-0.1.48/src/cvd_risk/models/smart2/__init__.py +5 -0
  161. cvd_risk-0.1.48/src/cvd_risk/models/smart2/smart2.py +306 -0
  162. cvd_risk-0.1.48/src/cvd_risk/models/smartreach/README.md +63 -0
  163. cvd_risk-0.1.48/src/cvd_risk/models/smartreach/__init__.py +6 -0
  164. cvd_risk-0.1.48/src/cvd_risk/models/smartreach/smartreach.py +415 -0
  165. cvd_risk-0.1.48/src/cvd_risk/models/timi/README.md +87 -0
  166. cvd_risk-0.1.48/src/cvd_risk/models/timi/__init__.py +5 -0
  167. cvd_risk-0.1.48/src/cvd_risk/models/timi/timi.py +263 -0
  168. cvd_risk-0.1.48/src/cvd_risk/models/who/README.md +111 -0
  169. cvd_risk-0.1.48/src/cvd_risk/models/who/WHO_ISH_Scores.csv +1 -0
  170. cvd_risk-0.1.48/src/cvd_risk/models/who/__init__.py +5 -0
  171. cvd_risk-0.1.48/src/cvd_risk/models/who/who.py +307 -0
  172. cvd_risk-0.1.48/src/cvd_risk/utils/__init__.py +2 -0
  173. cvd_risk-0.1.48/src/cvd_risk/validation/__init__.py +6 -0
  174. cvd_risk-0.1.48/src/cvd_risk/validation/validation.py +212 -0
  175. cvd_risk-0.1.48/tests/__init__.py +2 -0
  176. cvd_risk-0.1.48/tests/conftest.py +85 -0
  177. cvd_risk-0.1.48/tests/unit/test_base.py +140 -0
  178. cvd_risk-0.1.48/tests/unit/test_heart.py +251 -0
  179. cvd_risk-0.1.48/tests/unit/test_score2.py +199 -0
  180. cvd_risk-0.1.48/tests/unit/test_score2_batch.py +147 -0
  181. cvd_risk-0.1.48/tests/unit/test_validation.py +125 -0
  182. cvd_risk-0.1.48/tests/unit/test_validation_utils.py +55 -0
  183. cvd_risk-0.1.48/tox.ini +33 -0
  184. cvd_risk-0.1.48/website/.eslintrc.json +4 -0
  185. cvd_risk-0.1.48/website/.gitignore +31 -0
  186. cvd_risk-0.1.48/website/.vercelignore +5 -0
  187. cvd_risk-0.1.48/website/BUILD_SUCCESS.md +60 -0
  188. cvd_risk-0.1.48/website/DEPLOYMENT.md +158 -0
  189. cvd_risk-0.1.48/website/NEXT_STEPS.md +112 -0
  190. cvd_risk-0.1.48/website/QUICK_START.md +30 -0
  191. cvd_risk-0.1.48/website/README.md +81 -0
  192. cvd_risk-0.1.48/website/VERCEL_FIX.md +87 -0
  193. cvd_risk-0.1.48/website/components/Navigation.tsx +83 -0
  194. cvd_risk-0.1.48/website/next.config.js +12 -0
  195. cvd_risk-0.1.48/website/package-lock.json +2205 -0
  196. cvd_risk-0.1.48/website/package.json +29 -0
  197. cvd_risk-0.1.48/website/pages/_app.tsx +7 -0
  198. cvd_risk-0.1.48/website/pages/_document.tsx +18 -0
  199. cvd_risk-0.1.48/website/pages/docs/models/[modelName].tsx +850 -0
  200. cvd_risk-0.1.48/website/pages/index.tsx +716 -0
  201. cvd_risk-0.1.48/website/postcss.config.js +7 -0
  202. cvd_risk-0.1.48/website/public/PyCVDRisk-Logo.png +0 -0
  203. cvd_risk-0.1.48/website/public/favicon.ico +0 -0
  204. cvd_risk-0.1.48/website/public/pycvdrisk-github-header-banner.png:Zone.Identifier +0 -0
  205. cvd_risk-0.1.48/website/styles/globals.css +165 -0
  206. cvd_risk-0.1.48/website/tailwind.config.js +28 -0
  207. cvd_risk-0.1.48/website/tsconfig.json +29 -0
@@ -0,0 +1,151 @@
1
+ name: Build Wheels
2
+
3
+ on:
4
+ push:
5
+ branches: [main, develop]
6
+ pull_request:
7
+ branches: [main, develop]
8
+ workflow_dispatch:
9
+ inputs:
10
+ version:
11
+ description: 'Version to build (leave empty for development build)'
12
+ required: false
13
+ type: string
14
+
15
+ jobs:
16
+ build_wheels:
17
+ name: Build wheels on ${{ matrix.os }}
18
+ runs-on: ${{ matrix.os }}
19
+ strategy:
20
+ fail-fast: false
21
+ matrix:
22
+ os: [ubuntu-latest, windows-latest, macos-latest]
23
+ python-version: ["3.10", "3.11", "3.12"]
24
+
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+
28
+ - name: Install system dependencies (macOS)
29
+ if: matrix.os == 'macos-latest'
30
+ run: |
31
+ brew install gettext
32
+ brew link --force gettext
33
+ echo "DYLD_FALLBACK_LIBRARY_PATH=/usr/local/opt/gettext/lib:$DYLD_FALLBACK_LIBRARY_PATH" >> $GITHUB_ENV
34
+
35
+ - name: Set up Python ${{ matrix.python-version }}
36
+ uses: actions/setup-python@v5
37
+ with:
38
+ python-version: ${{ matrix.python-version }}
39
+
40
+ - name: Install build dependencies
41
+ run: |
42
+ python -m pip install --upgrade pip
43
+ pip install build
44
+
45
+ - name: Update version for tagged builds
46
+ if: github.event.inputs.version != ''
47
+ shell: bash
48
+ run: |
49
+ python -c "
50
+ import re
51
+ with open('pyproject.toml', 'r') as f:
52
+ content = f.read()
53
+ new_content = re.sub(r'version = \"[^\"]*\"', f'version = \"${{ github.event.inputs.version }}\"', content)
54
+ with open('pyproject.toml', 'w') as f:
55
+ f.write(new_content)
56
+ print('Updated version to ${{ github.event.inputs.version }}')
57
+ "
58
+
59
+ - name: Build wheels
60
+ run: python -m build --wheel
61
+
62
+ - name: Build source distribution (Ubuntu only)
63
+ if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
64
+ run: python -m build --sdist
65
+
66
+ - name: Upload wheels
67
+ uses: actions/upload-artifact@v4
68
+ with:
69
+ name: wheels-${{ matrix.os }}-${{ matrix.python-version }}
70
+ path: dist/*.whl
71
+ retention-days: 30
72
+
73
+ - name: Upload source distribution
74
+ if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
75
+ uses: actions/upload-artifact@v4
76
+ with:
77
+ name: source-distribution
78
+ path: dist/*.tar.gz
79
+ retention-days: 30
80
+
81
+ test_wheels:
82
+ name: Test wheels on ${{ matrix.os }}
83
+ needs: build_wheels
84
+ runs-on: ${{ matrix.os }}
85
+ strategy:
86
+ matrix:
87
+ os: [ubuntu-latest, windows-latest, macos-latest]
88
+ python-version: ["3.10", "3.11", "3.12"]
89
+
90
+ steps:
91
+ - name: Set up Python ${{ matrix.python-version }}
92
+ uses: actions/setup-python@v5
93
+ with:
94
+ python-version: ${{ matrix.python-version }}
95
+
96
+ - name: Download wheels
97
+ uses: actions/download-artifact@v4
98
+ with:
99
+ name: wheels-${{ matrix.os }}-${{ matrix.python-version }}
100
+ path: dist/
101
+
102
+ - name: Install wheel
103
+ shell: bash
104
+ run: |
105
+ echo "Contents of dist directory:"
106
+ ls -la dist/
107
+ echo "Installing wheel..."
108
+ pip install dist/*.whl
109
+
110
+ - name: Run tests
111
+ shell: bash
112
+ run: |
113
+ set -e # Exit on any error
114
+
115
+ echo "Running wheel tests..."
116
+
117
+ echo "Testing basic import..."
118
+ python -c "import cvd_risk_calculator; print('Package imported successfully')"
119
+
120
+ echo "Testing SCORE2 import..."
121
+ python -c "from cvd_risk_calculator.models.score2 import SCORE2; print('SCORE2 imported successfully')"
122
+
123
+ echo "Testing basic functionality..."
124
+ python -c "
125
+ from cvd_risk_calculator.models.score2 import SCORE2
126
+ from cvd_risk_calculator.core.validation import PatientData
127
+
128
+ # Test data
129
+ patient = PatientData(
130
+ age=55, sex='male', systolic_bp=140.0,
131
+ total_cholesterol=6.0, hdl_cholesterol=1.2,
132
+ smoking=True, region='moderate'
133
+ )
134
+
135
+ # Calculate risk
136
+ model = SCORE2()
137
+ result = model.calculate(patient)
138
+
139
+ # Validate result
140
+ risk_score = result.risk_score
141
+ print(f'Risk calculation successful: {risk_score:.1f}%')
142
+
143
+ if not (0 <= risk_score <= 100):
144
+ print(f'Invalid risk score: {risk_score}')
145
+ import sys
146
+ sys.exit(1)
147
+
148
+ print('All tests passed successfully!')
149
+ "
150
+
151
+ echo "All wheel tests completed successfully!"
@@ -0,0 +1,60 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, develop]
6
+ pull_request:
7
+ branches: [main, develop]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install dependencies
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install -e ".[dev]"
28
+
29
+ - name: Run linters
30
+ run: |
31
+ black --check src tests
32
+ ruff check src tests
33
+ mypy src
34
+
35
+ - name: Run tests with coverage
36
+ run: |
37
+ pytest --cov=src/cvd_risk --cov-report=xml --cov-report=term-missing
38
+
39
+ - name: Upload coverage to Codecov
40
+ uses: codecov/codecov-action@v3
41
+ with:
42
+ file: ./coverage.xml
43
+ fail_ci_if_error: false
44
+
45
+ pre-commit:
46
+ runs-on: ubuntu-latest
47
+ steps:
48
+ - uses: actions/checkout@v4
49
+
50
+ - name: Set up Python
51
+ uses: actions/setup-python@v5
52
+ with:
53
+ python-version: "3.10"
54
+
55
+ - name: Install pre-commit
56
+ run: pip install pre-commit
57
+
58
+ - name: Run pre-commit
59
+ run: pre-commit run --all-files
60
+
@@ -0,0 +1,92 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ build-and-publish:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
13
+
14
+ steps:
15
+ - name: Checkout code
16
+ uses: actions/checkout@v4
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.10"
22
+
23
+ - name: Install build dependencies
24
+ run: |
25
+ python -m pip install --upgrade pip
26
+ pip install build twine
27
+
28
+ - name: Build package
29
+ run: python -m build
30
+
31
+ - name: Test build
32
+ run: |
33
+ # Test that the package can be installed
34
+ pip install --force-reinstall dist/*.whl
35
+ python -c "import cvd_risk; print('Package installed successfully')"
36
+
37
+ - name: Publish to PyPI
38
+ uses: pypa/gh-action-pypi-publish@release/v1
39
+ with:
40
+ print-hash: true
41
+
42
+ create-release:
43
+ runs-on: ubuntu-latest
44
+ needs: build-and-publish
45
+ permissions:
46
+ contents: write
47
+
48
+ steps:
49
+ - name: Checkout code
50
+ uses: actions/checkout@v4
51
+ with:
52
+ fetch-depth: 0
53
+
54
+ - name: Generate changelog
55
+ run: |
56
+ # Extract version from tag
57
+ TAG_NAME=${GITHUB_REF#refs/tags/}
58
+ VERSION=${TAG_NAME#v}
59
+
60
+ # Generate changelog entry
61
+ echo "# Release $VERSION" > release_notes.md
62
+ echo "" >> release_notes.md
63
+
64
+ # Add recent commits since last tag
65
+ echo "## Changes" >> release_notes.md
66
+ echo "" >> release_notes.md
67
+
68
+ # Get commits since last version tag
69
+ LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
70
+ if [ -n "$LAST_TAG" ]; then
71
+ git log --pretty=format:"* %s (%h)" "$LAST_TAG"..HEAD >> release_notes.md
72
+ else
73
+ git log --pretty=format:"* %s (%h)" -10 >> release_notes.md
74
+ fi
75
+
76
+ echo "" >> release_notes.md
77
+ echo "## Installation" >> release_notes.md
78
+ echo "" >> release_notes.md
79
+ echo "\`\`\`bash" >> release_notes.md
80
+ echo "pip install cvd-risk==$VERSION" >> release_notes.md
81
+ echo "\`\`\`" >> release_notes.md
82
+
83
+ - name: Create GitHub release
84
+ uses: actions/create-release@v1
85
+ env:
86
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87
+ with:
88
+ tag_name: ${{ github.ref_name }}
89
+ release_name: Release ${{ github.ref_name }}
90
+ body_path: release_notes.md
91
+ draft: false
92
+ prerelease: false
@@ -0,0 +1,142 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ *.manifest
32
+ *.spec
33
+
34
+ # Unit test / coverage reports
35
+ htmlcov/
36
+ .tox/
37
+ .nox/
38
+ .coverage
39
+ .coverage.*
40
+ .cache
41
+ nosetests.xml
42
+ coverage.xml
43
+ *.cover
44
+ *.py,cover
45
+ .hypothesis/
46
+ .pytest_cache/
47
+
48
+ # Translations
49
+ *.mo
50
+ *.pot
51
+
52
+ # Django stuff:
53
+ *.log
54
+ local_settings.py
55
+ db.sqlite3
56
+ db.sqlite3-journal
57
+
58
+ # Flask stuff:
59
+ instance/
60
+ .webassets-cache
61
+
62
+ # Scrapy stuff:
63
+ .scrapy
64
+
65
+ # Sphinx documentation
66
+ docs/_build/
67
+ docs/.doctrees/
68
+
69
+ # PyBuilder
70
+ target/
71
+
72
+ # Jupyter Notebook
73
+ .ipynb_checkpoints
74
+ *.ipynb_checkpoints
75
+
76
+ # IPython
77
+ profile_default/
78
+ ipython_config.py
79
+
80
+ # pyenv
81
+ .python-version
82
+
83
+ # pipenv
84
+ Pipfile.lock
85
+
86
+ # PEP 582
87
+ __pypackages__/
88
+
89
+ # Celery stuff
90
+ celerybeat-schedule
91
+ celerybeat.pid
92
+
93
+ # SageMath parsed files
94
+ *.sage.py
95
+
96
+ # Environments
97
+ .env
98
+ .venv
99
+ env/
100
+ venv/
101
+ ENV/
102
+ env.bak/
103
+ venv.bak/
104
+
105
+ # Spyder project settings
106
+ .spyderproject
107
+ .spyproject
108
+
109
+ # Rope project settings
110
+ .ropeproject
111
+
112
+ # mkdocs documentation
113
+ /site
114
+
115
+ # mypy
116
+ .mypy_cache/
117
+ .dmypy.json
118
+ dmypy.json
119
+
120
+ # Pyre type checker
121
+ .pyre/
122
+
123
+ # IDE
124
+ .vscode/
125
+ .idea/
126
+ *.swp
127
+ *.swo
128
+ *~
129
+
130
+ # OS
131
+ .DS_Store
132
+ Thumbs.db
133
+
134
+ # Project specific
135
+ data/raw/
136
+ data/processed/
137
+ *.pkl
138
+ *.pickle
139
+ benchmarks/results/
140
+ notebooks/*.ipynb
141
+
142
+ temp/
@@ -0,0 +1,34 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v4.5.0
4
+ hooks:
5
+ - id: trailing-whitespace
6
+ - id: end-of-file-fixer
7
+ - id: check-yaml
8
+ - id: check-added-large-files
9
+ - id: check-merge-conflict
10
+ - id: debug-statements
11
+
12
+ - repo: https://github.com/psf/black
13
+ rev: 23.12.1
14
+ hooks:
15
+ - id: black
16
+ language_version: python3.10
17
+
18
+ - repo: https://github.com/astral-sh/ruff-pre-commit
19
+ rev: v0.1.14
20
+ hooks:
21
+ - id: ruff
22
+ args: [--fix, --exit-non-zero-on-fix]
23
+
24
+ - repo: https://github.com/pre-commit/mirrors-mypy
25
+ rev: v1.8.0
26
+ hooks:
27
+ - id: mypy
28
+ additional_dependencies: [types-all]
29
+ args: [--ignore-missing-imports]
30
+
31
+ - repo: https://github.com/pre-commit/pre-commit-hooks
32
+ rev: v4.5.0
33
+ hooks:
34
+ - id: check-toml
@@ -0,0 +1,193 @@
1
+ # ๐Ÿ—๏ธ Build System Setup
2
+
3
+ This document explains the automated build and release system for the CVD Risk Calculator package.
4
+
5
+ ## ๐Ÿ“ Files Overview
6
+
7
+ ### GitHub Actions Workflows
8
+ - **`.github/workflows/ci.yml`** - Continuous Integration (tests, linting, coverage)
9
+ - **`.github/workflows/release.yml`** - Automated PyPI publishing on releases
10
+ - **`.github/workflows/build-wheels.yml`** - Multi-platform wheel building
11
+
12
+ ### Build Scripts
13
+ - **`build_script.py`** - Local development build utilities
14
+ - **`release.py`** - Version management and release preparation
15
+ - **`tox.ini`** - Multi-environment testing configuration
16
+
17
+ ### Configuration Files
18
+ - **`pyproject.toml`** - Package metadata and build configuration
19
+ - **`.pre-commit-config.yaml`** - Pre-commit hooks for code quality
20
+ - **`tox.ini`** - Testing environments configuration
21
+
22
+ ## ๐Ÿš€ Automated Release Process
23
+
24
+ ### 1. Create a Release
25
+
26
+ ```bash
27
+ # Update version and create release
28
+ python release.py patch # 0.1.0 โ†’ 0.1.1
29
+ python release.py minor # 0.1.0 โ†’ 0.2.0
30
+ python release.py major # 0.1.0 โ†’ 1.0.0
31
+
32
+ # Or set specific version
33
+ python release.py 1.0.0
34
+ ```
35
+
36
+ ### 2. Push to GitHub
37
+
38
+ ```bash
39
+ git push origin main --tags
40
+ ```
41
+
42
+ ### 3. Automated Publishing
43
+
44
+ GitHub Actions will automatically:
45
+ 1. **Build** wheels for multiple platforms (Linux, macOS, Windows)
46
+ 2. **Test** wheels on different Python versions (3.10, 3.11, 3.12)
47
+ 3. **Publish** to PyPI using trusted publishing
48
+ 4. **Create** GitHub release with changelog
49
+
50
+ ## ๐Ÿ”ง Local Development
51
+
52
+ ### Install Development Dependencies
53
+
54
+ ```bash
55
+ pip install -e .[dev]
56
+ ```
57
+
58
+ ### Run Quality Checks
59
+
60
+ ```bash
61
+ # All checks
62
+ python build_script.py check
63
+
64
+ # Individual checks
65
+ python build_script.py lint # Code formatting and linting
66
+ python build_script.py test # Run tests with coverage
67
+
68
+ # Build locally
69
+ python build_script.py build
70
+
71
+ # See all available commands
72
+ python build_script.py --help
73
+ ```
74
+
75
+ ### Multi-Environment Testing
76
+
77
+ ```bash
78
+ # Test with tox (requires Python 3.10, 3.11, 3.12 installed)
79
+ tox
80
+
81
+ # Test specific environment
82
+ tox -e py310
83
+ ```
84
+
85
+ ## ๐Ÿ“ฆ Package Configuration
86
+
87
+ ### pyproject.toml Highlights
88
+
89
+ - **Build system**: Hatchling (modern, fast)
90
+ - **Python versions**: 3.10, 3.11, 3.12
91
+ - **Dependencies**: NumPy, Pandas, Pydantic, SciPy
92
+ - **Optional dependencies**: dev, docs, performance extras
93
+ - **Entry points**: None (pure library)
94
+
95
+ ### Wheel Building
96
+
97
+ The package builds **universal wheels** that work on:
98
+ - **Platforms**: Linux, macOS, Windows
99
+ - **Architectures**: x64, ARM64 (where available)
100
+ - **Python versions**: 3.10, 3.11, 3.12
101
+
102
+ ## ๐Ÿ” PyPI Publishing
103
+
104
+ ### Trusted Publishing
105
+
106
+ Uses GitHub's **Trusted Publishing** (OIDC) for secure PyPI uploads:
107
+ - No API tokens stored in repository
108
+ - Automatic authentication via GitHub Actions
109
+ - Scoped to specific repository only
110
+
111
+ ### Release Workflow
112
+
113
+ 1. **Tag pushed** โ†’ Release workflow triggers
114
+ 2. **Build wheels** โ†’ Multi-platform compilation
115
+ 3. **Test wheels** โ†’ Installation and import verification
116
+ 4. **Publish to PyPI** โ†’ Upload source + wheels
117
+ 5. **Create release** โ†’ GitHub release with auto-generated notes
118
+
119
+ ## ๐Ÿงช Testing Strategy
120
+
121
+ ### CI Pipeline
122
+ - **Unit tests** on Python 3.10, 3.11, 3.12
123
+ - **Code coverage** โ‰ฅ70% requirement
124
+ - **Linting**: Black, Ruff, MyPy
125
+ - **Pre-commit hooks**: Automated quality checks
126
+
127
+ ### Test Categories
128
+ - **Unit tests**: Individual functions and methods
129
+ - **Integration tests**: Model interactions
130
+ - **Validation tests**: Against reference datasets
131
+ - **Performance tests**: Benchmarks and profiling
132
+
133
+ ## ๐Ÿ“‹ Pre-commit Hooks
134
+
135
+ ```bash
136
+ # Install hooks
137
+ pre-commit install
138
+
139
+ # Run on all files
140
+ pre-commit run --all-files
141
+
142
+ # Run on staged files
143
+ pre-commit run
144
+ ```
145
+
146
+ Hooks include:
147
+ - **Trailing whitespace** removal
148
+ - **End-of-file** fixer
149
+ - **YAML validation**
150
+ - **Black** code formatting
151
+ - **Ruff** linting
152
+ - **MyPy** type checking
153
+
154
+ ## ๐Ÿšจ Troubleshooting
155
+
156
+ ### Build Issues
157
+
158
+ **Problem**: `ModuleNotFoundError` during testing
159
+ **Solution**: Ensure test dependencies are installed
160
+ ```bash
161
+ pip install -e .[dev]
162
+ ```
163
+
164
+ **Problem**: Import errors in built package
165
+ **Solution**: Check `src/` directory structure and `pyproject.toml` packages configuration
166
+
167
+ ### Publishing Issues
168
+
169
+ **Problem**: PyPI upload fails
170
+ **Solution**: Check trusted publishing setup and repository permissions
171
+
172
+ **Problem**: Wheel build fails on specific platform
173
+ **Solution**: Check for platform-specific dependencies or compilation issues
174
+
175
+ ### Version Issues
176
+
177
+ **Problem**: Version not updating in built package
178
+ **Solution**: Ensure `pyproject.toml` version is updated before building
179
+
180
+ ## ๐Ÿ“š Additional Resources
181
+
182
+ - [Python Packaging Guide](https://packaging.python.org/)
183
+ - [Hatchling Documentation](https://hatch.pypa.io/latest/)
184
+ - [PyPI Trusted Publishing](https://docs.pypi.org/trusted-publishers/)
185
+ - [GitHub Actions for Python](https://docs.github.com/en/actions/guides/building-and-testing-python)
186
+
187
+ ## ๐ŸŽฏ Next Steps
188
+
189
+ 1. **Test the CI pipeline** by pushing to a feature branch
190
+ 2. **Configure PyPI trusted publishing** in repository settings
191
+ 3. **Set up documentation building** (Read the Docs)
192
+ 4. **Add performance testing** to CI pipeline
193
+ 5. **Configure code coverage** reporting (Codecov)