Fix kg_emb broken import: SampleBaseDataset -> SampleDataset, add pan… - #1192
Fix kg_emb broken import: SampleBaseDataset -> SampleDataset, add pan…#1192userjuma wants to merge 2 commits into
Conversation
…darallel dependency
|
Thanks for this. The I think one step is missing though. The module imports, but Two smaller notes:
Worth saying that #952 asked for the rename across eight files and your PR does I've opened #1202 going after the root cause, and credited you in the |
- Add >>> usage examples to docstrings of SampleKGDataset, split(), KGEBaseModel, TransE, RotatE, DistMult, ComplEx - Fix a separate, pre-existing bug found while verifying the examples: SampleKGDataset called SampleDataset.__init__ with the old in-memory list API, but SampleDataset is now litdata-backed and expects a path to a directory built by SampleBuilder.save(). Set base attributes directly instead and added __len__ (previously inherited, now needed since we no longer call the incompatible super().__init__()) - Document the kg_emb classes in docs/api/medcode.rst - Add a runnable KG embedding example to examples/medcode.py
Closes #952
Fixes the broken import in
kg_embcaused bySampleBaseDatasetbeing renamed toSampleDatasetin PyHealth 2.0. Updated across all 7 affected files (2 inkg_emb/datasets, 5 inkg_emb/models).Also adds
pandarallel(>=1.6.5) topyproject.toml. It is used inkg_emb/datasets/base_kg_dataset.pybut was previously missing from declared dependencies, which caused aModuleNotFoundErrorimmediately after the dataset rename was resolved.Added
tests/core/test_kg_emb.pycovering:1.Clean import of the
kg_embmodule2. Importability of all five
kg_embmodel classes3.A regression check ensuring
TransE's dataset parameter is explicitly typed asSampleDatasetManual verification:
Reproduced the original crash via
python -c "import pyhealth.medcode.pretrained_embeddings"and confirmed it now resolves cleanly end-to-end.