drama / src /load_graph.py
Shravani Prakash Maskar
Add full app source code and configs for Streamlit deployment
c87117f
Raw
History Blame Contribute Delete
1.02 kB
import os
from pathlib import Path
from huggingface_hub import snapshot_download
def download_graph_if_needed():
output_path = Path("graphrag_input/output")
lancedb_path = output_path / "lancedb"
# Check both parquet files AND lancedb exist locally
parquet_ok = output_path.exists() and any(output_path.glob("*.parquet"))
lancedb_ok = lancedb_path.exists() and any(lancedb_path.iterdir())
if parquet_ok and lancedb_ok:
print("Graph + embeddings already exist locally, skipping download")
return
print("Downloading graph index from Hugging Face...")
output_path.mkdir(parents=True, exist_ok=True)
snapshot_download(
repo_id="shrav2324/kdrama-graphrag-index",
repo_type="dataset",
local_dir=str(output_path),
token=os.getenv("HF_TOKEN"),
)
print(f"Download complete. Parquet files: {list(output_path.glob('*.parquet'))}")
print(f"LanceDB tables: {list(lancedb_path.iterdir()) if lancedb_path.exists() else 'missing'}")