meds-algorithm-curiosity 0.1.0__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.
Files changed (31) hide show
  1. meds_algorithm_curiosity-0.1.0/.gitignore +12 -0
  2. meds_algorithm_curiosity-0.1.0/CHANGELOG.md +16 -0
  3. meds_algorithm_curiosity-0.1.0/LICENSE +21 -0
  4. meds_algorithm_curiosity-0.1.0/PKG-INFO +192 -0
  5. meds_algorithm_curiosity-0.1.0/README.md +171 -0
  6. meds_algorithm_curiosity-0.1.0/RELEASING.md +101 -0
  7. meds_algorithm_curiosity-0.1.0/algorithms/zero_shot_materialized/model.yaml +28 -0
  8. meds_algorithm_curiosity-0.1.0/configs/runs/run.yaml +26 -0
  9. meds_algorithm_curiosity-0.1.0/docs/IMPLEMENTATION_GUIDE.md +242 -0
  10. meds_algorithm_curiosity-0.1.0/docs/TESTING.md +70 -0
  11. meds_algorithm_curiosity-0.1.0/pyproject.toml +58 -0
  12. meds_algorithm_curiosity-0.1.0/scripts/check_distribution.sh +20 -0
  13. meds_algorithm_curiosity-0.1.0/scripts/check_release.py +32 -0
  14. meds_algorithm_curiosity-0.1.0/scripts/github-sync.sh +29 -0
  15. meds_algorithm_curiosity-0.1.0/src/curiosity_meds/__init__.py +6 -0
  16. meds_algorithm_curiosity-0.1.0/src/curiosity_meds/__main__.py +65 -0
  17. meds_algorithm_curiosity-0.1.0/src/curiosity_meds/_model.py +236 -0
  18. meds_algorithm_curiosity-0.1.0/src/curiosity_meds/_tokenizer.py +684 -0
  19. meds_algorithm_curiosity-0.1.0/src/curiosity_meds/config.py +163 -0
  20. meds_algorithm_curiosity-0.1.0/src/curiosity_meds/curiosity_meds.py +378 -0
  21. meds_algorithm_curiosity-0.1.0/src/curiosity_meds/datasets/MIMIC-IV.yaml +54 -0
  22. meds_algorithm_curiosity-0.1.0/tests/__init__.py +1 -0
  23. meds_algorithm_curiosity-0.1.0/tests/conftest.py +48 -0
  24. meds_algorithm_curiosity-0.1.0/tests/e2e.py +216 -0
  25. meds_algorithm_curiosity-0.1.0/tests/fixtures/in_icu_mortality.yaml +34 -0
  26. meds_algorithm_curiosity-0.1.0/tests/fixtures/predicates.yaml +6 -0
  27. meds_algorithm_curiosity-0.1.0/tests/test_conformance.py +7 -0
  28. meds_algorithm_curiosity-0.1.0/tests/test_curiosity.py +473 -0
  29. meds_algorithm_curiosity-0.1.0/tests/test_primary_behavior.py +36 -0
  30. meds_algorithm_curiosity-0.1.0/tests/wheel_smoke.py +70 -0
  31. meds_algorithm_curiosity-0.1.0/uv.lock +1838 -0
@@ -0,0 +1,12 @@
1
+ __pycache__/
2
+ .pytest_cache/
3
+ .venv/
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ runs/**/logs/
8
+ runs/**/artifacts/
9
+ runs/**/checkpoints/
10
+
11
+ # Arguments and scheduler outputs are local run products.
12
+ runs/**/command-args/
@@ -0,0 +1,16 @@
1
+ # Changes
2
+
3
+ ## 0.1.0 (unreleased)
4
+
5
+ - Curiosity-0826 (arXiv 2611.15710) as a `zero_shot_materialized` MEDS algorithm, replacing the earlier
6
+ Curiosity-0226 port: BOS-first sequences, age/year at start of timeline with pediatric buckets, birth,
7
+ gestational age and birth weight, death with causes and EOS, right-censoring padding, lab collection markers,
8
+ 30-bucket labs, non-numeric labs, binned vitals, ATC-split medications with attributes and a patient-reported
9
+ flag, and two-stage context extension to 16,384 tokens with unscaled RoPE.
10
+ - Prompts are built from what is recorded at or before each prediction time; prompt-level temporal-invariance
11
+ tests complement the shared future-blind conformance rerun.
12
+ - Model size presets (`size`: small, medium, large, xlarge): Curiosity-0226 S/M/L and a 40-layer ~4.2B model for
13
+ Curiosity-0826-4B.
14
+ - MIMIC-IV category file matches MIMIC-IV-MEDS 0.4.0 (MEDS-DEV's current build) and 0.1.0; race also comes from
15
+ `RACE//` events.
16
+ - `aces-relaxations` from PyPI (0.1.0); `meds-algorithm` with the temporal-leakage conformance (0.4.0a6).
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Florent Pollet
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,192 @@
1
+ Metadata-Version: 2.5
2
+ Name: meds-algorithm-curiosity
3
+ Version: 0.1.0
4
+ Summary: Curiosity-0826 generative medical event model: Qwen2 decoder pretrained on tokenized MEDS timelines, zero-shot task prediction by Monte Carlo generation of future timelines.
5
+ Project-URL: Repository, https://github.com/florian6973/meds-algo-curiosity
6
+ Author-email: Florent Pollet <flo1.raymond@gmail.com>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Requires-Python: >=3.12
10
+ Requires-Dist: aces-relaxations==0.1.0
11
+ Requires-Dist: meds-algorithm[data]==0.4.0a6
12
+ Requires-Dist: numpy>=1.26
13
+ Requires-Dist: pyyaml>=6
14
+ Requires-Dist: torch>=2.6
15
+ Requires-Dist: transformers>=4.51
16
+ Provides-Extra: orchestration
17
+ Requires-Dist: meds-algorithm[orchestration]==0.4.0a6; extra == 'orchestration'
18
+ Provides-Extra: test
19
+ Requires-Dist: meds-algorithm[conformance]==0.4.0a6; extra == 'test'
20
+ Description-Content-Type: text/markdown
21
+
22
+ # Curiosity
23
+
24
+ ## Python API and named command
25
+
26
+ The implementation is `src/curiosity_meds/curiosity_meds.py`, with configuration in `config.py`.
27
+ Both concrete classes are public package exports:
28
+
29
+ ```python
30
+ from curiosity_meds import Curiosity, CuriosityConfig
31
+
32
+ algorithm = Curiosity(CuriosityConfig())
33
+ ```
34
+
35
+ Run typed requests through `meds_algorithm.StepRunner.run(...)` so validation, measurements and
36
+ publication apply. Calling an implementation method directly bypasses that execution contract.
37
+ After installation, the algorithm's own `curiosity-meds` command runs the CLI:
38
+
39
+ ```bash
40
+ curiosity-meds commands --profile zero_shot_materialized
41
+ ```
42
+
43
+ Curiosity-0826 generative medical event model: Qwen2 decoder pretrained on tokenized MEDS timelines, zero-shot task prediction by Monte Carlo generation of future timelines.
44
+
45
+ This repository declares the **`zero_shot_materialized`** profiles under version 4 of the minimal MEDS algorithm
46
+ contract. The contract standardizes MEDS input, command meanings and arguments, artifact envelopes,
47
+ final predictions, measurements, MEDS-DEV packaging, and operational interfaces. The algorithm owns every
48
+ computational choice and every intermediate payload.
49
+
50
+ ## Algorithm profile commands
51
+
52
+ - `zero_shot_materialized`: `preprocess_data → pretrain → infer_trajectories → predict_zero_shot_materialized`
53
+
54
+ ```bash
55
+ curiosity-meds profiles
56
+ curiosity-meds commands --profile zero_shot_materialized
57
+ curiosity-meds <step> --profile <profile> key=value ...
58
+ ```
59
+
60
+ Each profile has `algorithms/<profile>/model.yaml`. Multiple profiles share one Python package and one
61
+ registry; select one explicitly for each run. `STUB_PROFILES` tracks implementation status separately.
62
+ Read [Software contract](SPEC.md) for exact class responsibilities and step inputs.
63
+
64
+ Intermediate artifacts may be tensors, files, databases, external-system references, or any other
65
+ implementation-owned representation. Generic tests inspect only their `manifest.yaml` envelopes. They
66
+ must not assume batches, Lightning, PyTorch, Parquet intermediate data, or iteration order.
67
+
68
+ ## Profile runner (prototype)
69
+
70
+ Install `uv sync --extra orchestration --extra test`, then fill the input paths and new output directory
71
+ in `configs/runs/run.yaml`. Algorithm settings belong under `algorithm`; core validates them using
72
+ this repository's concrete Config class.
73
+
74
+ ```bash
75
+ uv run curiosity-meds run --dry-run
76
+ uv run curiosity-meds run execution=local
77
+ # Use a NEW output_dir and configure your cluster's resources before submission:
78
+ uv run curiosity-meds run execution=slurm output_dir=/runs/new-cluster-run
79
+ ```
80
+
81
+ A dry run prints all resolved arguments, paths, configuration and resources without writing files or
82
+ submitting jobs. Local execution uses fresh subprocesses; Submitit submits separate dependent SLURM
83
+ jobs. See the [shared runner guide](https://meds-algorithm.readthedocs.io/en/latest/running/#profile-runner-prototype)
84
+ for stage subsets, artifact reuse, resource configuration and prototype limitations. The existing
85
+ per-step CLI and shell launcher remain available for comparison. This prototype does not implement
86
+ Hydra multirun, multi-node training or checkpoint/resume.
87
+
88
+ ## Publishing this algorithm
89
+
90
+ Follow [the release guide](RELEASING.md) for package metadata, one-time PyPI Trusted Publisher setup,
91
+ installed-wheel checks, and version-tag publication. All profiles ship in the `meds-algorithm-curiosity`
92
+ distribution. Tests run in CI; publishing is an explicit workflow dispatch after implementation.
93
+
94
+ ## Inputs and predicates
95
+
96
+ - `external_meds_dir` is the standard MEDS dataset boundary.
97
+ - `external_index_dir` supplies only `(subject_id, prediction_time)` to inference and scoring.
98
+ - `external_labels_dir` supplies permitted training targets or explicit in-context examples.
99
+ - `external_evaluation_labels_dir`, when supplied, is used only to attach truth after scores are fixed.
100
+ - `external_predicates_file` supplies dataset-specific predicates when useful. For MIMIC-IV, reuse the
101
+ predicates from MEDS-DEV. This repository decides whether and how to interpret them.
102
+
103
+ A command that consumes predicates records their absolute path and SHA-256 digest in its manifest.
104
+ Predicates do not imply a standard feature representation.
105
+
106
+ ## Implementing the algorithm
107
+
108
+ Read [AGENTS.md](AGENTS.md), [SPEC.md](SPEC.md), and
109
+ [docs/IMPLEMENTATION_GUIDE.md](docs/IMPLEMENTATION_GUIDE.md) completely before changing implementation
110
+ files. The implementation source recorded when this repository was generated is:
111
+
112
+ ```text
113
+ https://arxiv.org/abs/2611.15710v1, building on https://arxiv.org/abs/2508.12104v3 (papers only; no code released)
114
+ ```
115
+
116
+ The algorithm-owned surface is `src/curiosity_meds/curiosity_meds.py` (the typed algorithm), `src/curiosity_meds/config.py`
117
+ (its immutable configuration), `algorithms/<profile>/model.yaml`, and
118
+ `tests/e2e.py`. Implement the selected profile methods, define exact intermediate compatibility checks in
119
+ `validate_inputs`,
120
+ finalize MEDS-DEV command strings, and complete the report. Remove a profile from `STUB_PROFILES` only after it runs end to end. Complete every declared profile.
121
+
122
+ For each generated test and its purpose, read [the test guide](docs/TESTING.md).
123
+
124
+ ## Configuration and execution ownership
125
+
126
+ Declare typed fields/defaults in `CuriosityConfig`, with `validate()` for constraints. Pass
127
+ `config_file=/path/config.yaml` to a step for a JSON/YAML values mapping; unknown fields fail. Core saves
128
+ the complete resolved config and original typed request as `config.json` and `request.json` in each
129
+ published artifact. These JSON envelopes can be reloaded with the corresponding explicit classes.
130
+
131
+ Algorithm methods receive typed requests, write payloads into `request.output.directory` (staging), and
132
+ return `PayloadMetadata`. `create_repository().run(...)` constructs a fresh algorithm and delegates to
133
+ core's runner. It owns measurements, prediction validation, optional post-score truth attachment,
134
+ metadata and publication. Never publish from inside algorithm methods or write the reserved metadata files.
135
+ Reopen fitted artifacts on each step. Test config/request round trips and execution in a fresh process.
136
+
137
+ ## Verification
138
+
139
+ ```bash
140
+ uv run pytest -rs
141
+ uv run pytest -m meds_dev -rs
142
+ uv run pytest -m real_data -rs
143
+ ```
144
+
145
+ - The default suite runs the local end-to-end adapter and contract tests.
146
+ - `meds_dev` registers `algorithms/<profile>/model.yaml`, installs this repository from `requirements.txt` in an isolated
147
+ environment, and executes MEDS-DEV's real command slots.
148
+ - `real_data` runs the full selected algorithm profile on the MEDS-DEV MIMIC-IV demo, the pinned
149
+ `mortality/in_icu/first_24h` task, and MEDS-DEV's
150
+ MIMIC predicates. Set `MEDS_DEMO_DIR` to reuse an existing demo and `MEDS_DEV_DIR` to reuse a checkout.
151
+
152
+ Automatic provisioning pins MEDS-DEV PR #330's tested commit, which has the `{predicates_path}`
153
+ passthrough (PR #325) and the
154
+ `{task_criteria_path}` passthrough this zero-shot algorithm needs. Set `MEDS_DEV_REF` to use another
155
+ revision containing those capabilities. A checkout supplied through `MEDS_DEV_DIR` is checked and fails
156
+ clearly if it cannot populate them.
157
+
158
+ Both integration tiers explicitly `algorithm_stub`-skip until implementation is complete. A completed port
159
+ must have zero `algorithm_stub` skips and must account for every other skip using `-rs` output.
160
+
161
+ These commands are gates, not an unordered checklist. Follow the canonical staged workflow in
162
+ [docs/IMPLEMENTATION_GUIDE.md](docs/IMPLEMENTATION_GUIDE.md): local, MEDS-DEV, pre-demo report and human
163
+ review, MIMIC-IV demo, demo report and human review, authorized full-data run, then final report and GitHub
164
+ synchronization. Full-data cluster jobs run only from a clean, pushed commit and use the reviewed shared
165
+ task bundle for the selected dataset (for example, MIMIC-IV or NWICU in MEDS format), built upstream from
166
+ clinical ACES tasks or randomly sampled code-by-horizon tasks. The provided `real_data` test remains the MIMIC-IV demo regardless of that choice.
167
+
168
+ Final predictions must conform to MEDS evaluation, contain unique `(subject_id, prediction_time)` keys,
169
+ and exactly cover the requested evaluation index. Tests compare the actual key sets; self-reported manifest
170
+ counts are not accepted as evidence. Row order is never an association mechanism.
171
+
172
+ ## Measurements
173
+
174
+ Every command manifest records monotonic wall time and sampled live process-tree memory. On Linux, peak
175
+ PSS from `/proc/*/smaps_rollup` is the primary comparison metric; aggregate RSS is retained as a
176
+ diagnostic. The measurement method and sampling interval are explicit. GPU measurements and SLURM
177
+ `MaxRSS`, when available, are separate metrics. Missing measurements are `null`; observed zero is `0`.
178
+ Time and memory are evidence, not portable test thresholds.
179
+
180
+ ## Cluster execution and GitHub communication
181
+
182
+ ```bash
183
+ $EDITOR slurm/config.sh
184
+ PROFILE=zero_shot_materialized ./slurm/submit.sh --dry-run
185
+ PROFILE=zero_shot_materialized ./slurm/submit.sh
186
+ scripts/github-sync.sh <run-id>
187
+ ```
188
+
189
+ SLURM follows the selected algorithm profile and chains stages by successful dependencies. Structured evidence belongs
190
+ under `runs/<run-id>/`; raw logs, datasets, checkpoints, and credentials do not. GitHub synchronization
191
+ pushes a `runs/curiosity_meds/<run-id>` branch and optionally opens a draft PR. A failed push leaves the
192
+ result committed and recoverable locally.
@@ -0,0 +1,171 @@
1
+ # Curiosity
2
+
3
+ ## Python API and named command
4
+
5
+ The implementation is `src/curiosity_meds/curiosity_meds.py`, with configuration in `config.py`.
6
+ Both concrete classes are public package exports:
7
+
8
+ ```python
9
+ from curiosity_meds import Curiosity, CuriosityConfig
10
+
11
+ algorithm = Curiosity(CuriosityConfig())
12
+ ```
13
+
14
+ Run typed requests through `meds_algorithm.StepRunner.run(...)` so validation, measurements and
15
+ publication apply. Calling an implementation method directly bypasses that execution contract.
16
+ After installation, the algorithm's own `curiosity-meds` command runs the CLI:
17
+
18
+ ```bash
19
+ curiosity-meds commands --profile zero_shot_materialized
20
+ ```
21
+
22
+ Curiosity-0826 generative medical event model: Qwen2 decoder pretrained on tokenized MEDS timelines, zero-shot task prediction by Monte Carlo generation of future timelines.
23
+
24
+ This repository declares the **`zero_shot_materialized`** profiles under version 4 of the minimal MEDS algorithm
25
+ contract. The contract standardizes MEDS input, command meanings and arguments, artifact envelopes,
26
+ final predictions, measurements, MEDS-DEV packaging, and operational interfaces. The algorithm owns every
27
+ computational choice and every intermediate payload.
28
+
29
+ ## Algorithm profile commands
30
+
31
+ - `zero_shot_materialized`: `preprocess_data → pretrain → infer_trajectories → predict_zero_shot_materialized`
32
+
33
+ ```bash
34
+ curiosity-meds profiles
35
+ curiosity-meds commands --profile zero_shot_materialized
36
+ curiosity-meds <step> --profile <profile> key=value ...
37
+ ```
38
+
39
+ Each profile has `algorithms/<profile>/model.yaml`. Multiple profiles share one Python package and one
40
+ registry; select one explicitly for each run. `STUB_PROFILES` tracks implementation status separately.
41
+ Read [Software contract](SPEC.md) for exact class responsibilities and step inputs.
42
+
43
+ Intermediate artifacts may be tensors, files, databases, external-system references, or any other
44
+ implementation-owned representation. Generic tests inspect only their `manifest.yaml` envelopes. They
45
+ must not assume batches, Lightning, PyTorch, Parquet intermediate data, or iteration order.
46
+
47
+ ## Profile runner (prototype)
48
+
49
+ Install `uv sync --extra orchestration --extra test`, then fill the input paths and new output directory
50
+ in `configs/runs/run.yaml`. Algorithm settings belong under `algorithm`; core validates them using
51
+ this repository's concrete Config class.
52
+
53
+ ```bash
54
+ uv run curiosity-meds run --dry-run
55
+ uv run curiosity-meds run execution=local
56
+ # Use a NEW output_dir and configure your cluster's resources before submission:
57
+ uv run curiosity-meds run execution=slurm output_dir=/runs/new-cluster-run
58
+ ```
59
+
60
+ A dry run prints all resolved arguments, paths, configuration and resources without writing files or
61
+ submitting jobs. Local execution uses fresh subprocesses; Submitit submits separate dependent SLURM
62
+ jobs. See the [shared runner guide](https://meds-algorithm.readthedocs.io/en/latest/running/#profile-runner-prototype)
63
+ for stage subsets, artifact reuse, resource configuration and prototype limitations. The existing
64
+ per-step CLI and shell launcher remain available for comparison. This prototype does not implement
65
+ Hydra multirun, multi-node training or checkpoint/resume.
66
+
67
+ ## Publishing this algorithm
68
+
69
+ Follow [the release guide](RELEASING.md) for package metadata, one-time PyPI Trusted Publisher setup,
70
+ installed-wheel checks, and version-tag publication. All profiles ship in the `meds-algorithm-curiosity`
71
+ distribution. Tests run in CI; publishing is an explicit workflow dispatch after implementation.
72
+
73
+ ## Inputs and predicates
74
+
75
+ - `external_meds_dir` is the standard MEDS dataset boundary.
76
+ - `external_index_dir` supplies only `(subject_id, prediction_time)` to inference and scoring.
77
+ - `external_labels_dir` supplies permitted training targets or explicit in-context examples.
78
+ - `external_evaluation_labels_dir`, when supplied, is used only to attach truth after scores are fixed.
79
+ - `external_predicates_file` supplies dataset-specific predicates when useful. For MIMIC-IV, reuse the
80
+ predicates from MEDS-DEV. This repository decides whether and how to interpret them.
81
+
82
+ A command that consumes predicates records their absolute path and SHA-256 digest in its manifest.
83
+ Predicates do not imply a standard feature representation.
84
+
85
+ ## Implementing the algorithm
86
+
87
+ Read [AGENTS.md](AGENTS.md), [SPEC.md](SPEC.md), and
88
+ [docs/IMPLEMENTATION_GUIDE.md](docs/IMPLEMENTATION_GUIDE.md) completely before changing implementation
89
+ files. The implementation source recorded when this repository was generated is:
90
+
91
+ ```text
92
+ https://arxiv.org/abs/2611.15710v1, building on https://arxiv.org/abs/2508.12104v3 (papers only; no code released)
93
+ ```
94
+
95
+ The algorithm-owned surface is `src/curiosity_meds/curiosity_meds.py` (the typed algorithm), `src/curiosity_meds/config.py`
96
+ (its immutable configuration), `algorithms/<profile>/model.yaml`, and
97
+ `tests/e2e.py`. Implement the selected profile methods, define exact intermediate compatibility checks in
98
+ `validate_inputs`,
99
+ finalize MEDS-DEV command strings, and complete the report. Remove a profile from `STUB_PROFILES` only after it runs end to end. Complete every declared profile.
100
+
101
+ For each generated test and its purpose, read [the test guide](docs/TESTING.md).
102
+
103
+ ## Configuration and execution ownership
104
+
105
+ Declare typed fields/defaults in `CuriosityConfig`, with `validate()` for constraints. Pass
106
+ `config_file=/path/config.yaml` to a step for a JSON/YAML values mapping; unknown fields fail. Core saves
107
+ the complete resolved config and original typed request as `config.json` and `request.json` in each
108
+ published artifact. These JSON envelopes can be reloaded with the corresponding explicit classes.
109
+
110
+ Algorithm methods receive typed requests, write payloads into `request.output.directory` (staging), and
111
+ return `PayloadMetadata`. `create_repository().run(...)` constructs a fresh algorithm and delegates to
112
+ core's runner. It owns measurements, prediction validation, optional post-score truth attachment,
113
+ metadata and publication. Never publish from inside algorithm methods or write the reserved metadata files.
114
+ Reopen fitted artifacts on each step. Test config/request round trips and execution in a fresh process.
115
+
116
+ ## Verification
117
+
118
+ ```bash
119
+ uv run pytest -rs
120
+ uv run pytest -m meds_dev -rs
121
+ uv run pytest -m real_data -rs
122
+ ```
123
+
124
+ - The default suite runs the local end-to-end adapter and contract tests.
125
+ - `meds_dev` registers `algorithms/<profile>/model.yaml`, installs this repository from `requirements.txt` in an isolated
126
+ environment, and executes MEDS-DEV's real command slots.
127
+ - `real_data` runs the full selected algorithm profile on the MEDS-DEV MIMIC-IV demo, the pinned
128
+ `mortality/in_icu/first_24h` task, and MEDS-DEV's
129
+ MIMIC predicates. Set `MEDS_DEMO_DIR` to reuse an existing demo and `MEDS_DEV_DIR` to reuse a checkout.
130
+
131
+ Automatic provisioning pins MEDS-DEV PR #330's tested commit, which has the `{predicates_path}`
132
+ passthrough (PR #325) and the
133
+ `{task_criteria_path}` passthrough this zero-shot algorithm needs. Set `MEDS_DEV_REF` to use another
134
+ revision containing those capabilities. A checkout supplied through `MEDS_DEV_DIR` is checked and fails
135
+ clearly if it cannot populate them.
136
+
137
+ Both integration tiers explicitly `algorithm_stub`-skip until implementation is complete. A completed port
138
+ must have zero `algorithm_stub` skips and must account for every other skip using `-rs` output.
139
+
140
+ These commands are gates, not an unordered checklist. Follow the canonical staged workflow in
141
+ [docs/IMPLEMENTATION_GUIDE.md](docs/IMPLEMENTATION_GUIDE.md): local, MEDS-DEV, pre-demo report and human
142
+ review, MIMIC-IV demo, demo report and human review, authorized full-data run, then final report and GitHub
143
+ synchronization. Full-data cluster jobs run only from a clean, pushed commit and use the reviewed shared
144
+ task bundle for the selected dataset (for example, MIMIC-IV or NWICU in MEDS format), built upstream from
145
+ clinical ACES tasks or randomly sampled code-by-horizon tasks. The provided `real_data` test remains the MIMIC-IV demo regardless of that choice.
146
+
147
+ Final predictions must conform to MEDS evaluation, contain unique `(subject_id, prediction_time)` keys,
148
+ and exactly cover the requested evaluation index. Tests compare the actual key sets; self-reported manifest
149
+ counts are not accepted as evidence. Row order is never an association mechanism.
150
+
151
+ ## Measurements
152
+
153
+ Every command manifest records monotonic wall time and sampled live process-tree memory. On Linux, peak
154
+ PSS from `/proc/*/smaps_rollup` is the primary comparison metric; aggregate RSS is retained as a
155
+ diagnostic. The measurement method and sampling interval are explicit. GPU measurements and SLURM
156
+ `MaxRSS`, when available, are separate metrics. Missing measurements are `null`; observed zero is `0`.
157
+ Time and memory are evidence, not portable test thresholds.
158
+
159
+ ## Cluster execution and GitHub communication
160
+
161
+ ```bash
162
+ $EDITOR slurm/config.sh
163
+ PROFILE=zero_shot_materialized ./slurm/submit.sh --dry-run
164
+ PROFILE=zero_shot_materialized ./slurm/submit.sh
165
+ scripts/github-sync.sh <run-id>
166
+ ```
167
+
168
+ SLURM follows the selected algorithm profile and chains stages by successful dependencies. Structured evidence belongs
169
+ under `runs/<run-id>/`; raw logs, datasets, checkpoints, and credentials do not. GitHub synchronization
170
+ pushes a `runs/curiosity_meds/<run-id>` branch and optionally opens a draft PR. A failed push leaves the
171
+ result committed and recoverable locally.
@@ -0,0 +1,101 @@
1
+ # Publishing Curiosity
2
+
3
+ One PyPI distribution, `meds-algorithm-curiosity`, contains all declared profiles. Its Python import is
4
+ `curiosity_meds` and its executable is `curiosity-meds`. Publishing the
5
+ algorithm does not require another release of the shared core or template.
6
+
7
+ ## Prepare once
8
+
9
+ 1. Choose an available PyPI name; edit `[project].name` in `pyproject.toml` if needed. The import and CLI
10
+ names need not match it. Update this guide and the CLI installation hint if changing the name later.
11
+ 2. Set `project.urls.Repository`, choose an SPDX `project.license` expression compatible with your
12
+ implementation and upstream sources, and add the actual `LICENSE` file. Review the authors,
13
+ description and README. The template deliberately does not choose a license for you.
14
+ 3. Declare every runtime dependency in `pyproject.toml`; release dependencies must be installable
15
+ from the package index, without Git/direct URL requirements. Commit `uv.lock` after `uv lock`.
16
+ 4. Complete every declared profile and its scientific tests; remove completed profiles from
17
+ `STUB_PROFILES`. Publication rejects remaining stubs. Passing packaging checks does not establish
18
+ scientific correctness. Extend `tests/wheel_smoke.py` for required algorithm resources/configuration.
19
+ 5. Merge `.github/workflows/publish.yml` into `main`. Create GitHub environments `testpypi` and `pypi`;
20
+ configure release reviewers/tag restrictions as appropriate for your repository.
21
+ 6. On [PyPI](https://pypi.org/manage/account/publishing/) and separately on
22
+ [TestPyPI](https://test.pypi.org/manage/account/publishing/), register a pending GitHub publisher:
23
+
24
+ | Field | Value |
25
+ |---|---|
26
+ | PyPI project name | `meds-algorithm-curiosity` |
27
+ | Owner | Your GitHub user or organization |
28
+ | Repository | This algorithm's GitHub repository name |
29
+ | Workflow filename | `publish.yml` |
30
+ | Environment | `pypi` on PyPI; `testpypi` on TestPyPI |
31
+
32
+ For an existing PyPI project, add the publisher in its Publishing settings instead. No API token
33
+ is needed. See the [official setup guide](https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/).
34
+
35
+ ## Check each release
36
+
37
+ Update `[project].version` and `CHANGELOG.md`, then run these commands from the repository root
38
+ (Bash, with Git and uv installed):
39
+
40
+ ```bash
41
+ uv lock
42
+ uv sync --locked --extra test
43
+ uv run --no-sync pytest -rs
44
+ uv run --no-sync python scripts/check_release.py
45
+ bash scripts/check_distribution.sh
46
+ ```
47
+
48
+ The distribution check builds a wheel from the source archive, validates metadata, installs the base
49
+ wheel in a fresh environment, checks imports/commands/resources from a temporary working directory,
50
+ then installs orchestration and checks a preprocessing dry-run. It runs no training or SLURM jobs.
51
+ It leaves the checked files in `dist/`; move old `dist/` contents elsewhere before repeating it.
52
+ Commit the version, lockfile, changelog and implementation changes; merge passing CI into `main`.
53
+
54
+ ## Tag, rehearse, publish
55
+
56
+ Replace `OWNER/REPOSITORY` below. Set `version` to the exact version in `pyproject.toml`:
57
+
58
+ ```bash
59
+ repository=OWNER/REPOSITORY
60
+ version=0.1.0
61
+ git switch main
62
+ git pull --ff-only
63
+ git tag -a "v$version" -m "Release $version"
64
+ git push origin "v$version"
65
+ gh workflow run publish.yml --repo "$repository" --ref "v$version" -f index=testpypi
66
+ gh run list --repo "$repository" --workflow publish.yml
67
+ ```
68
+
69
+ Wait for success and verify installation from TestPyPI. Install dependencies from PyPI first, then
70
+ replace only this package from TestPyPI, avoiding mixed-index dependency resolution:
71
+
72
+ ```bash
73
+ uv venv /tmp/algorithm-release-check
74
+ uv pip install --python /tmp/algorithm-release-check/bin/python dist/*.whl
75
+ uv pip install --python /tmp/algorithm-release-check/bin/python --reinstall --no-deps \
76
+ --index-url https://test.pypi.org/simple/ "meds-algorithm-curiosity==$version"
77
+ /tmp/algorithm-release-check/bin/python -I tests/wheel_smoke.py
78
+ gh workflow run publish.yml --repo "$repository" --ref "v$version" -f index=pypi
79
+ gh run list --repo "$repository" --workflow publish.yml
80
+ ```
81
+
82
+ The workflow requires the matching version tag on `main` history, a committed lockfile, complete
83
+ profiles, passing tests, and valid installed distributions. A separate job uploads those exact checked
84
+ files using Trusted Publishing. Rehearsal and production runs each build and check their own artifacts
85
+ from the same tag. After success, install `meds-algorithm-curiosity==$version` in a fresh environment and
86
+ repeat the smoke check. Never move a published tag or reuse a published version; increment it for fixes.
87
+
88
+ ## What installation includes
89
+
90
+ `configs/runs/` and `algorithms/` are the single editable source for portable run defaults and MEDS-DEV
91
+ YAMLs. The wheel copies them to `curiosity_meds/resources/` during its build; the source archive
92
+ includes the originals. No second copy is maintained in Git.
93
+
94
+ The runner uses `./configs/runs` when present, otherwise its installed defaults. `--config-dir` explicitly
95
+ selects user configuration. Supply dataset paths and run settings as overrides or external configuration;
96
+ do not put dataset-specific paths, credentials, labels, datasets or fitted weights in bundled defaults.
97
+ The source archive uses an explicit file allowlist; review its contents before publishing.
98
+
99
+ Access installed profile YAMLs with `importlib.resources.files("curiosity_meds") / "resources" /
100
+ "algorithms"`. SLURM shell scripts and implementation reports remain checkout tooling. Large pretrained
101
+ weights should be retrieved as separately versioned artifacts, not silently embedded in a wheel.
@@ -0,0 +1,28 @@
1
+
2
+
3
+
4
+
5
+
6
+ ## MEDS-DEV descriptor for Curiosity. This retains the established command-slot interface.
7
+ ## Each MEDS-DEV run directory {output_dir} holds this run's artifacts as sibling subdirectories (data/,
8
+ ## pretrained/, algorithm/, embeddings/ or trajectories/, predictions/): MEDS-DEV keeps its own cmd.sh and .done marker in
9
+ ## {output_dir}, and artifacts are published by publishing their own destination directory.
10
+ ## Zero-shot commands receive the task itself through {task_criteria_path}, which needs the MEDS-DEV
11
+ ## passthrough described in SPEC.md section 2.4 (the analogue of {predicates_path}).
12
+ metadata:
13
+ description: "Curiosity-0826 generative medical event model: Qwen2 decoder pretrained on tokenized MEDS timelines, zero-shot task prediction by Monte Carlo generation of future timelines."
14
+ contacts:
15
+ - name: "Florent Pollet"
16
+ email: "flo1.raymond@gmail.com"
17
+
18
+ commands:
19
+ unsupervised:
20
+ train: |-
21
+ curiosity-meds preprocess_data --profile zero_shot_materialized external_meds_dir={dataset_dir} output_data_dir={output_dir}/data do_overwrite=true
22
+ curiosity-meds pretrain --profile zero_shot_materialized input_data_dir={output_dir}/data output_pretrained_algorithm_dir={output_dir}/pretrained
23
+ supervised:
24
+ train: null
25
+ predict: |-
26
+ curiosity-meds infer_trajectories --profile zero_shot_materialized input_data_dir={model_initialization_dir}/data input_pretrained_algorithm_dir={model_initialization_dir}/pretrained external_index_dir={labels_dir} splits=[{split}] output_trajectories_dir={output_dir}/trajectories do_overwrite=true
27
+ curiosity-meds predict_zero_shot_materialized --profile zero_shot_materialized input_data_dir={model_initialization_dir}/data external_meds_dir={dataset_dir} input_trajectories_dir={output_dir}/trajectories external_index_dir={labels_dir} external_task_criteria_file={task_criteria_path} external_predicates_file={predicates_path} splits=[{split}] output_predictions_dir={output_dir}/predictions do_overwrite=true external_evaluation_labels_dir={labels_dir}
28
+
@@ -0,0 +1,26 @@
1
+ # Prototype: one config for local subprocesses or dependent Submitit SLURM jobs.
2
+ # Shared field/resource defaults come from meds-algorithm, not a copied schema.
3
+ defaults:
4
+ - meds_run
5
+ - _self_
6
+
7
+ profile: zero_shot_materialized
8
+ execution: local
9
+ output_dir: ??? # New directory for this run; relative paths use the invocation's working directory.
10
+
11
+ inputs:
12
+ meds_dir: null # Required by preprocessing and materialized zero-shot prediction.
13
+ index_dir: null # Required by inference and prediction.
14
+ predicates_file: null # Supply the dataset predicates expected by this algorithm.
15
+ task_criteria_file: null # Required when selecting a zero-shot profile.
16
+
17
+ # Add only algorithm settings that differ from the concrete Config class's defaults.
18
+ algorithm: {}
19
+
20
+ # Optional overrides, e.g. resources.compute.gpus_per_node=1 and its partition/account.
21
+ # Both resource presets default to CPUs; choose resources appropriate for this algorithm.
22
+ # resources:
23
+ # compute:
24
+ # gpus_per_node: 1
25
+ # partition: gpu
26
+ # timeout_min: 240