ENCODE / src /backend /paths.py
hiasgnpsadgd's picture
Upload folder using huggingface_hub
21711e7 verified
Raw
History Blame Contribute Delete
2.93 kB
"""Every filesystem path the backend reads, in one place.
Runtime sidecars live in outputs/runtime/; retrieval weights, indexes, and
vectors live in their own outputs subtrees. Build intermediates live in
outputs/build/ and are never loaded here. Each runtime location keeps an
environment override so deployments repoint data without code changes. No
other backend module may build a sidecar path.
"""
from __future__ import annotations
import os
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
def _env_path(name: str, default: Path) -> Path:
return Path(os.environ.get(name, default))
CODE_INDEX_DIR = _env_path("ENCODE_CODE_INDEX_DIR", ROOT / "outputs" / "indexes" / "bge_ft_va")
MODEL_DIR = _env_path("ENCODE_MODEL_DIR", ROOT / "outputs" / "models" / "bge_ft_va")
RUNTIME_DIR = _env_path("ENCODE_RUNTIME_DIR", ROOT / "outputs" / "runtime")
PARTA_EMB_DIR = _env_path("ENCODE_PARTA_EMB_DIR", ROOT / "outputs" / "embeddings" / "bge_ft_va")
ANNOT_DIR = _env_path("ENCODE_ANNOT_DIR", ROOT / "outputs" / "annotations")
# Unified mapping files, one per target vocabulary.
MAPPINGS_DIR = RUNTIME_DIR / "mappings"
LAB_LOINC_MAP = MAPPINGS_DIR / "lab_loinc.jsonl"
ICD_PHECODE_MAP = MAPPINGS_DIR / "icd_phecode.jsonl"
CPT_RBCS_MAP = MAPPINGS_DIR / "cpt_rbcs.jsonl"
MED_RXNORM_MAP = MAPPINGS_DIR / "med_rxnorm.jsonl"
# Per-code ICD versions for the diagnosis index rows that pack an ICD-9 and an
# ICD-10 code under one shared description. Written by
# scripts/build_icd_index_versions.py, which resolves them against the VA
# dimension exports in data/ that the backend itself may not read.
ICD_INDEX_VERSIONS = RUNTIME_DIR / "icd_index_versions.json"
# Vocabulary tables, phenotype sidecars, and the sources registry.
LOINC_TERMS = RUNTIME_DIR / "vocab" / "loinc_terms.jsonl"
CANONICAL_PHENOTYPES = RUNTIME_DIR / "canonical_phenotypes.jsonl"
CODE_DESCRIPTIONS = RUNTIME_DIR / "code_descriptions.jsonl"
ALGORITHM_COMPONENTS = RUNTIME_DIR / "algorithm_components.jsonl"
CIPHER_LINKS = RUNTIME_DIR / "cipher_links.jsonl"
PHENOTYPE_FACETS = RUNTIME_DIR / "phenotype_facets.jsonl"
PHENOTYPE_SUMMARIES = RUNTIME_DIR / "phenotype_summaries.jsonl"
RELATED_BUNDLES = RUNTIME_DIR / "related_bundles.jsonl"
SOURCES = RUNTIME_DIR / "sources.json"
# Index sizes and mapping coverage, written by scripts/report_coverage.py. The
# runtime copy is the one a deployment carries; the eval copy is the standing
# report itself and is read only when a local checkout has no runtime copy.
CORPUS_STATS = RUNTIME_DIR / "corpus_stats.json"
# The lab merge-noise vocabulary, mined from the LOINC crosswalk by
# scripts/build_lab_noise_vocab.py with the evidence for every word. The
# frontend's Merge duplicates option reads it; a deployment without the file
# merges on the fixed rules only.
LAB_NOISE_VOCAB = RUNTIME_DIR / "lab_noise_vocab.json"
COVERAGE_REPORT = ROOT / "outputs" / "eval" / "coverage_report.json"