Spaces:
Sleeping
Sleeping
File size: 933 Bytes
ba4ad33 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | """
Ingestion handler - checks for data and runs ingest.py if needed
"""
import os
import json
import sys
def run_ingestion():
"""
Run the ingestion pipeline if compounds.json doesn't exist.
"""
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ingest_script = os.path.join(base_dir, "ingest.py")
data_file = os.path.join(base_dir, "data", "compounds.json")
if os.path.exists(data_file):
try:
with open(data_file) as f:
data = json.load(f)
if len(data) > 0:
print(f"Data already exists: {len(data)} compounds")
return True
except:
pass
print("Running ingest.py...")
if os.path.exists(ingest_script):
os.system(f"{sys.executable} {ingest_script}")
return True
else:
print(f"ingest.py not found at {ingest_script}")
return False
|