Upload config.py with huggingface_hub
Browse files71 unmodified lines72737475767778792 unmodified lines82838485868788899091929394959671 unmodified linesreturn outdef node_property_query(con, column: str = "species") -> str:"""SQL returning (id, <column>) for every node, from whichever source exists.The released dataset ships data/nodes_expected_ge5.parquet, which holds theproperty rows for exactly the nodes in edges_expected_ge5 — enough for every2 unmodified linesacross nodes_ML (MTBLS ids) and nodes_MW (ST ids)."""if NODES_PARQUET.exists():return f"SELECT id, {column} FROM '{NODES_PARQUET}'"if pathlib.Path(NODE_DB_PATH).exists():con.execute(f"ATTACH IF NOT EXISTS '{NODE_DB_PATH}' AS g (READ_ONLY)")return (f"SELECT id, {column} FROM g.nodes_ML "f"UNION ALL SELECT id, {column} FROM g.nodes_MW")raise SystemExit(f"no node properties found: expected {NODES_PARQUET} "f"or {NODE_DB_PATH}")def species_for(con, node_ids: list) -> list:"""species per node id, in node_ids order. Raises if any id is unknown."""by_id = dict(con.execute(node_property_query(con, "species")).fetchall())71 unmodified lines72737475767778792 unmodified lines82838485868788899091929394959697989910071 unmodified linesreturn outdef node_source(con) -> str:"""A SQL relation with the full node property columns, from whatever exists.The released dataset ships data/nodes_expected_ge5.parquet, which holds theproperty rows for exactly the nodes in edges_expected_ge5 — enough for every2 unmodified linesacross nodes_ML (MTBLS ids) and nodes_MW (ST ids)."""if NODES_PARQUET.exists():return f"(SELECT * FROM '{NODES_PARQUET}')"if pathlib.Path(NODE_DB_PATH).exists():con.execute(f"ATTACH IF NOT EXISTS '{NODE_DB_PATH}' AS g (READ_ONLY)")return "(SELECT * FROM g.nodes_ML UNION ALL SELECT * FROM g.nodes_MW)"raise SystemExit(f"no node properties found: expected {NODES_PARQUET} "f"or {NODE_DB_PATH}")def node_property_query(con, column: str = "species") -> str:"""SQL returning (id, <column>) for every node."""return f"SELECT id, {column} FROM {node_source(con)}"def species_for(con, node_ids: list) -> list:"""species per node id, in node_ids order. Raises if any id is unknown."""by_id = dict(con.execute(node_property_query(con, "species")).fetchall())
config.py+9-5