zsyJosh commited on
Commit
a2908e6
·
1 Parent(s): ccc4fe8

Update requirements.txt to retain stark_qa dependency and remove PyTDC

Browse files
Files changed (3) hide show
  1. requirements.txt +1 -2
  2. tdc/__init__.py +9 -0
  3. tdc/resource.py +61 -0
requirements.txt CHANGED
@@ -19,5 +19,4 @@ langchain-text-splitters
19
  torch
20
  tokenizers>=0.15.0
21
  sentencepiece
22
- stark_qa>=1.0.0
23
- PyTDC
 
19
  torch
20
  tokenizers>=0.15.0
21
  sentencepiece
22
+ stark_qa>=1.0.0
 
tdc/__init__.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Lightweight local stub of the `tdc` package used by `stark_qa`.
3
+
4
+ We only implement the minimal surface needed by `stark_qa.skb.prime.PrimeSKB`,
5
+ namely `tdc.resource.PrimeKG`. This avoids pulling in the full PyTDC
6
+ dependency (and its heavy scikit-learn build) on environments like
7
+ Hugging Face Spaces with Python 3.13.
8
+ """
9
+
tdc/resource.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Minimal stub implementation of `tdc.resource.PrimeKG` for use with `stark_qa`.
3
+
4
+ The real PyTDC package provides a rich PrimeKG interface backed by
5
+ scikit-learn and other heavy dependencies that currently fail to build
6
+ on Python 3.13 in Hugging Face Spaces.
7
+
8
+ Here we expose a small, compatible API surface that `stark_qa.skb.prime.PrimeSKB`
9
+ relies on:
10
+
11
+ - class PrimeKG(path: str | None = None, ...):
12
+ - .get_features(feature_type: str) -> pandas.DataFrame
13
+
14
+ `PrimeSKB` uses `get_features(feature_type='drug'|'disease')` and then
15
+ iterates over rows, expecting a `node_index` column and arbitrary
16
+ additional columns to enrich node metadata. Returning an empty DataFrame
17
+ with the right columns safely becomes a no-op enrichment step.
18
+ """
19
+
20
+ from __future__ import annotations
21
+
22
+ from typing import Any, Optional
23
+
24
+ import pandas as pd
25
+
26
+
27
+ class PrimeKG:
28
+ """
29
+ Lightweight no-op stand‑in for the real `tdc.resource.PrimeKG`.
30
+
31
+ It is sufficient for `stark_qa`'s usage in this leaderboard:
32
+ it allows imports to succeed and returns empty feature DataFrames,
33
+ so downstream loops simply do nothing while the rest of the
34
+ knowledge base logic continues to function.
35
+ """
36
+
37
+ def __init__(self, path: Optional[str] = None, *args: Any, **kwargs: Any) -> None:
38
+ # We keep the same signature shape, but ignore the arguments.
39
+ self.path = path
40
+
41
+ def get_features(self, feature_type: str, *args: Any, **kwargs: Any) -> pd.DataFrame:
42
+ """
43
+ Return an empty feature table with the expected `node_index` column.
44
+
45
+ `stark_qa.skb.prime.PrimeSKB` calls this for `feature_type` in
46
+ {'drug', 'disease'} and then:
47
+
48
+ - iterates over range(len(df))
49
+ - reads `df.iloc[i]['node_index']`
50
+ - uses the remaining columns as metadata
51
+
52
+ By returning an empty DataFrame, those loops are effectively
53
+ skipped without raising errors.
54
+ """
55
+
56
+ # We include `node_index` to satisfy column access, but leave it empty.
57
+ return pd.DataFrame(columns=["node_index"])
58
+
59
+
60
+ __all__ = ["PrimeKG"]
61
+