Skip to content

PY: consolidate python-r4 and python-us-core into python-r4-us-core#185

Merged
ryukzak merged 4 commits into
api/python-client-optionfrom
python-example-decouple
Jun 18, 2026
Merged

PY: consolidate python-r4 and python-us-core into python-r4-us-core#185
ryukzak merged 4 commits into
api/python-client-optionfrom
python-example-decouple

Conversation

@ryukzak

@ryukzak ryukzak commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Consolidate the Python examples, mirroring the TypeScript example-decouple work. Stacked on py-mypy-us-core-strict, so this PR targets that branch and shows only the consolidation diff.

Directory changes

Before → after:

examples/                          examples/
├── python-r4/          ──┐        ├── python-r4-us-core/   (merged)
├── python-us-core/     ──┘        └── python-fhirpy/       (unchanged)
└── python-fhirpy/
  • python-r4 + python-us-corepython-r4-us-core — a single generate.ts pulls US Core 8.0.1 (which depends on R4 core) plus the local ExampleTypedBundle SD, so one fhir_types/ tree holds hl7_fhir_r4_core, hl7_fhir_us_core, and example_folder_structures.
  • Drop the byte-identical duplicate test_raw_extension.py and the redundant second R4 type generation.
  • python-fhirpy left as-is (distinct async-client variant).
  • fhir_types/type-schemas/ (introspection debug output) is now gitignored — it was never committed before but wasn't ignored either.

Tests in the merged dir

  • Offline (no server): test_profile_* (US Core profile API), test_bundle.py, test_raw_extension.py — run with mypy under mypy.ini.
  • Live (Aidbox): test_sdk.py — CRUD via the requests-based client.py.

Build & CI

Makefile targets before → after:

generate-python-sdk + generate-python-us-core-sdk  → generate-python-r4-us-core-sdk
python-test-setup + python-us-core-test-setup      → python-r4-us-core-test-setup
test-python-us-core-example                        → test-python-r4-us-core-example  (offline: mypy + profile/bundle/extension tests)
test-python-sdk                                    → live client.py CRUD over the merged dir (Aidbox-gated)
  • CI (sdk-tests.yml): renamed the US Core job to test-python-r4-us-core-example and gave it the fhir_types determinism diff-check (always runs, no Aidbox); the test-python-sdk job runs the live SDK tests; dropped its stale diff-check on the non-existent examples/python/fhir_types.
  • Updated README.md and examples/README.md Python references.

Notes

  • Verified locally: generation succeeds, mypy --config-file mypy.ini passes (41 files), and all 70 offline tests pass (directly and via make test-python-r4-us-core-example). Aidbox SDK tests run in CI.
  • test_sdk.py / client.py are now type-checked under US Core's mypy.ini (strict with a few FHIR-dict error codes disabled) instead of mypy --strict — slightly more lenient, in exchange for one consistent config over the merged dir.

@ryukzak ryukzak force-pushed the python-example-decouple branch from 096841f to 73f4a71 Compare June 18, 2026 13:05
@ryukzak ryukzak force-pushed the py-mypy-us-core-strict branch from 6f26800 to 1a3855d Compare June 18, 2026 13:05
Base automatically changed from py-mypy-us-core-strict to main June 18, 2026 13:14
@ryukzak ryukzak force-pushed the python-example-decouple branch from 73f4a71 to 35130ed Compare June 18, 2026 13:26
Comment thread Makefile Outdated
. venv/bin/activate && \
python -m pytest -v
. venv/bin/activate && \
mypy --strict .

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move it to mypy.ini

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b7063c2 — dropped the --strict/--config-file CLI flags; mypy now reads each example mypy.ini (python-fhirpy/mypy.ini sets strict = True).

Comment thread Makefile Outdated
python -m pytest test_raw_extension.py -v
cd $(PYTHON_R4_US_CORE_EXAMPLE) && \
. venv/bin/activate && \
python -m pytest test_profile_bodyweight.py test_profile_bp.py test_profile_patient.py test_profile_typed_bundle.py test_bundle.py test_raw_extension.py -v

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use wildcard instead of test list.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b7063c2 — replaced the explicit list with pytest --ignore=test_sdk.py -v (auto-discovers offline tests, excludes the Aidbox one).

Comment thread Makefile
ryukzak added 4 commits June 18, 2026 18:03
A single generate.ts pulls US Core 8.0.1 (which depends on R4 core) plus the
local ExampleTypedBundle SD, so one fhir_types tree holds hl7_fhir_r4_core,
hl7_fhir_us_core, and example_folder_structures. Drop the duplicate (identical)
test_raw_extension.py and the redundant second R4 type generation. The merged
dir keeps the offline profile/bundle/extension tests and the live requests
client SDK tests (test_sdk.py); type-schemas debug output is gitignored.
- Makefile: test-python-r4-us-core-example (offline: mypy + profile/bundle/extension
  tests) and test-python-sdk (live client.py CRUD, Aidbox-gated) over the merged dir;
  drop the python-r4 / python-us-core specific generate/setup/test targets
- CI: rename the us-core job to test-python-r4-us-core-example with a fhir_types
  determinism diff-check; the python-sdk job runs the live SDK tests
- Update README and examples README python references
- test-python-r4-us-core-example: pytest --ignore=test_sdk.py (auto-discover) instead of an
  explicit per-file list, so new offline tests are picked up automatically
- drop redundant mypy CLI flags; rely on each example mypy.ini (python-fhirpy/mypy.ini now
  sets strict = True, equivalent to the old --strict flag)
Moving --strict into mypy.ini as a bare `strict = True` turned on strict_optional, which
the old CLI --strict did not (the config relaxation won), breaking client.py list-indexing.
Add strict = True on top of the existing relaxations to match the original behavior.
@ryukzak ryukzak force-pushed the python-example-decouple branch from 50980ed to 9590468 Compare June 18, 2026 16:03
@ryukzak ryukzak changed the base branch from main to api/python-client-option June 18, 2026 16:03
@ryukzak ryukzak merged commit 56fad30 into api/python-client-option Jun 18, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant