Extending ehr2rl¶
Each extension below lists the files that usually change. Every change follows the same order:
Write a failing test in the matching test file.
Implement until it passes.
Export the object, if it is public, by adding it to
__all__and to thePUBLIC_APIlist intests/test_public_docs.py.Document it on its API page and, if users need to know, in a guide.
Do not add an object to __all__ before it has tests. Once exported, it is
part of the supported API.
Adding features and itemids¶
New state features are new concepts in an itemid map. See Features and itemids.
Change |
Where |
|---|---|
Add the concept and its itemids, with expected labels |
|
Add it to a preset, or add a preset |
|
Test resolution and validation |
|
Document the preset |
|
Always fill in label so live validation can catch relabelled itemids. Check
labels against d_items or d_labitems before committing. The label check
runs against the whole map on every load, so a wrong label breaks every user.
Only chartevents and labevents concepts become states. inputevents
concepts feed actions.
Adding an action representation¶
Change |
Where |
|---|---|
Dose conversion or aggregation |
|
Configuration |
|
Wiring into loading |
|
Tests |
|
Docs |
|
Discrete actions must record metadata["action_sizes"] on every trajectory so
the exporter can declare the full action space. New vasopressor units need an
entry in the unit tables in vasopressors.py and a test. Never return a dose
in an unconverted unit.
Adding a reward¶
Change |
Where |
|---|---|
A |
New module in |
Export |
|
Tests |
|
Docs |
|
compute must return shape (T,) and must not modify the trajectory. Raise
ValueError with the missing key’s name when required metadata is absent, and
document which loaders provide it.
Adding an exporter¶
Change |
Where |
|---|---|
A |
New module in |
Optional dependency |
A new extra in |
Export |
|
Tests |
|
Docs |
A guide in |
Import the library inside the function and raise an ImportError naming the
extra, so the base install and the docs build keep working. Reuse the
to_d3rlpy action handling: integer actions with action_sizes are discrete,
floats are continuous.