From 37cb406a6e613590b621e5698923ff0952b32401 Mon Sep 17 00:00:00 2001 From: SexyERIC0723 Date: Sun, 22 Mar 2026 22:04:21 +0000 Subject: [PATCH 1/2] feat: add optional dependency groups for graph and NLP extras (#890) Add [project.optional-dependencies] to pyproject.toml so users can install domain-specific dependencies via pip extras: pip install pyhealth[graph] # torch-geometric for GraphCare, KG pip install pyhealth[nlp] # editdistance, rouge_score, nltk The codebase already uses try/except ImportError with HAS_PYG flags for torch-geometric, and the NLP metrics define their required versions in each scorer class. This change exposes those dependencies through standard Python packaging so pip can resolve them. Version pins match the requirements declared in the code: - editdistance~=0.8.1 (pyhealth/nlp/metrics.py:356) - rouge_score~=0.1.2 (pyhealth/nlp/metrics.py:415) - nltk~=3.9.1 (pyhealth/nlp/metrics.py:397) - torch-geometric>=2.6.0 (compatible with PyTorch 2.7) Closes #890 --- pyproject.toml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index c1e0ebcc6..eb710d11d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,16 @@ dependencies = [ "einops>=0.8.0", "linear-attention-transformer>=0.19.1", ] +[project.optional-dependencies] +graph = [ + "torch-geometric>=2.6.0", +] +nlp = [ + "editdistance~=0.8.1", + "rouge_score~=0.1.2", + "nltk~=3.9.1", +] + license = "BSD-3-Clause" license-files = ["LICENSE.md"] keywords = [ From c2e47997718aec85f0de1afe6a8fbca2af720d6b Mon Sep 17 00:00:00 2001 From: SexyERIC0723 Date: Fri, 27 Mar 2026 20:20:40 +0000 Subject: [PATCH 2/2] fix: move optional-dependencies after scalar fields to fix TOML structure Move [project.optional-dependencies] from between dependencies and license (line 49) to after keywords (line 62), before [project.urls]. In TOML, a sub-table header like [project.optional-dependencies] closes the parent [project] table, so placing it before license and keywords caused those fields to be excluded from [project]. This broke CI validation. Verified with tomllib that all project fields (name, license, keywords, optional-dependencies, urls) parse correctly under [project]. --- pyproject.toml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index eb710d11d..456947682 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,16 +46,6 @@ dependencies = [ "einops>=0.8.0", "linear-attention-transformer>=0.19.1", ] -[project.optional-dependencies] -graph = [ - "torch-geometric>=2.6.0", -] -nlp = [ - "editdistance~=0.8.1", - "rouge_score~=0.1.2", - "nltk~=3.9.1", -] - license = "BSD-3-Clause" license-files = ["LICENSE.md"] keywords = [ @@ -69,6 +59,16 @@ keywords = [ "deep learning", ] +[project.optional-dependencies] +graph = [ + "torch-geometric>=2.6.0", +] +nlp = [ + "editdistance~=0.8.1", + "rouge_score~=0.1.2", + "nltk~=3.9.1", +] + [project.urls] Homepage = "https://github.com/sunlabuiuc/PyHealth" Documentation = "https://pyhealth.readthedocs.io/en/latest/about.html"