Files
rarelens/api/app/config.py
T
Kemal Yaylali ae58e33fe2 feat(pipeline): VEP database mode, and a pipeline-specific database URL
Makes a real annotation runnable locally without the 25 GB VEP cache, which is what
the demo needs and what a reviewer can reproduce in minutes.

- params.vep_database (VEP_DATABASE=true) queries Ensembl's public database instead of
  a local cache. Slower per variant and fewer fields, so --everything is swapped for the
  flags the loader actually stores. Its cache placeholder is NO_CACHE, not NO_FILE:
  Nextflow rejects two staged inputs sharing a filename.
- PIPELINE_DATABASE_URL is handed to the pipeline when set. The loader runs inside a
  container, where the API's own localhost URL would point at the container itself.
- README: how to run the UI's annotate button locally against host Nextflow + Docker.

Verified end to end on pipeline/tests/data/tiny.vcf: bcftools norm split the multiallelic
record, VEP 113 annotated 4 variants live, the loader wrote them and marked the job
succeeded, and the UI shows them. The deletion came back as 22:42126611 CT>C with exact
VCF alleles, which is the case the audit's ID-tagging fix exists for.

Tests: api 51, loader 16, stub run 3/3; ruff, mypy clean.
2026-09-12 07:39:19 +01:00

37 lines
1.7 KiB
Python

from pathlib import Path
from pydantic_settings import BaseSettings, SettingsConfigDict
# api/app/config.py -> repo root locally; "/" in the API image, where compose mounts /pipeline.
REPO_ROOT = Path(__file__).resolve().parents[2]
class Settings(BaseSettings):
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
database_url: str = "postgresql+asyncpg://rarelens:rarelens@localhost:5432/rarelens"
mlflow_tracking_uri: str = "http://localhost:5000"
model_name: str = "rarelens-pathogenicity"
# Registry alias set by `rarelens_ml.train --register` (stages are deprecated in MLflow 3).
model_alias: str = "production"
# A model artifact URI (gs://...) scores without an MLflow server running; wins over the registry.
model_uri: str | None = None
gcs_bucket: str | None = None # set in GCP; local uses ./data
pubsub_topic: str | None = None # "vcf-uploaded" in GCP; local runs pipeline inline
# Serverless track: run the Nextflow driver as a Cloud Run job instead of Argo + Pub/Sub.
cloudrun_job: str | None = None
gcp_project: str | None = None # required with pubsub_topic or cloudrun_job
gcp_region: str = "europe-west2"
pipeline_dir: Path = REPO_ROOT / "pipeline"
# Handed to the pipeline when it differs from the API's own: the loader runs inside a
# container, where the API's localhost would be the container itself.
pipeline_database_url: str | None = None
nextflow_profile: str = "docker"
# Local (non-gs://) VCFs must live under this directory.
local_data_root: Path = Path("/data")
# Browsers calling the API cross-origin; behind the ingress the UI is same-origin.
cors_origins: list[str] = ["http://localhost:5173"]
settings = Settings()