diff --git a/settings.toml b/settings.toml index f84d438..ef97425 100644 --- a/settings.toml +++ b/settings.toml @@ -1,6 +1,7 @@ dry_run = true s3_bucket = "webgwas-ohio" sqlite_db = "sqlite:///backend.db" -n_workers = 1 +n_workers = 2 +fit_quality_file = "prod_data/fit_quality.parquet" [indirect_gwas] diff --git a/src/webgwas_backend/config.py b/src/webgwas_backend/config.py index f4ac0cb..919431b 100644 --- a/src/webgwas_backend/config.py +++ b/src/webgwas_backend/config.py @@ -1,6 +1,7 @@ from __future__ import annotations import json +from pathlib import Path from typing import Any from dynaconf import Dynaconf @@ -18,6 +19,7 @@ class Settings(BaseSettings): sqlite_db: str indirect_gwas: IndirectGWASSettings n_workers: int + fit_quality_file: Path @classmethod def from_json(cls, json_data: dict[str, Any]) -> Settings: diff --git a/src/webgwas_backend/main.py b/src/webgwas_backend/main.py index 19222ab..4d984a8 100644 --- a/src/webgwas_backend/main.py +++ b/src/webgwas_backend/main.py @@ -4,6 +4,7 @@ from functools import lru_cache from typing import Annotated +import polars as pl import webgwas.phenotype_definitions from fastapi import Depends, FastAPI, HTTPException from fastapi.middleware.cors import CORSMiddleware @@ -35,12 +36,17 @@ init_db() worker: Worker | None = None +fit_quality: list[tuple[float, float]] | None = None @asynccontextmanager async def lifespan(app: FastAPI): # noqa: ARG001 global worker worker = Worker(settings) + global fit_quality + fit_quality = pl.read_parquet(settings.fit_quality_file).to_pandas().values.tolist() + assert fit_quality is not None + fit_quality = [(float(f"{x:.3f}"), float(f"{y:.3f}")) for x, y in fit_quality] yield @@ -171,3 +177,10 @@ def get_igwas_results( request_id: str, worker: Annotated[Worker, Depends(get_worker)] ) -> WebGWASResult: return worker.get_results(request_id) + + +@app.get("/api/static/fit_quality") +def get_fit_quality() -> list[tuple[float, float]]: + if fit_quality is None: + raise HTTPException(status_code=500, detail="Fit quality not loaded") + return fit_quality diff --git a/uv.lock b/uv.lock index a3c396e..333b2ed 100644 --- a/uv.lock +++ b/uv.lock @@ -2,7 +2,7 @@ version = 1 requires-python = ">=3.11" resolution-markers = [ "python_full_version < '3.12'", - "python_full_version == '3.12.*'", + "python_full_version < '3.13'", "python_full_version >= '3.13'", ] @@ -30,39 +30,39 @@ wheels = [ [[package]] name = "boto3" -version = "1.35.8" +version = "1.35.10" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "botocore" }, { name = "jmespath" }, { name = "s3transfer" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/91/64/39a9c9c490ad4201a88a2f3339286eedb9200cf4868b3917c002aef02233/boto3-1.35.8.tar.gz", hash = "sha256:b9587131372a808bf6f99c5ed8b11be55cd113261cc3b437a917b4acc6c30bfe", size = 108616 } +sdist = { url = "https://files.pythonhosted.org/packages/be/01/3e6dce0f2364f1814f735a01c52c3c55d87c079daefeb6569ab7829c2520/boto3-1.35.10.tar.gz", hash = "sha256:189ab1e2b4cd86df56f82438d89b4040eb140c92683f1bda7cb2e62624f20ea5", size = 108652 } wheels = [ - { url = "https://files.pythonhosted.org/packages/d9/cd/db2b57967b189a5fa355887581457df008003671c41725d744ca8b8b507e/boto3-1.35.8-py3-none-any.whl", hash = "sha256:06eac4757de2a9c6020381205cb902f05964caad80b56e58c8931284a133b4cb", size = 139144 }, + { url = "https://files.pythonhosted.org/packages/63/c2/f32fddf5a40456fb0564a32d5d20b37b8ad00c3fe6122aab602be139e459/boto3-1.35.10-py3-none-any.whl", hash = "sha256:add26dd58e076dfd387013da4704716d5cff215cf14f6d4347c4b9b7fc1f0b8e", size = 139159 }, ] [[package]] name = "botocore" -version = "1.35.8" +version = "1.35.10" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "jmespath" }, { name = "python-dateutil" }, { name = "urllib3" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/00/cd/7d9250eb9734ce3c220178a63ad87ae4dd8019c1c48d48a7f014b84b9ead/botocore-1.35.8.tar.gz", hash = "sha256:4b820cf680ab5d778bd2fe4feeef1ff8a2b96d5c535d4638ab30f703ade282f8", size = 12700788 } +sdist = { url = "https://files.pythonhosted.org/packages/71/76/fd28cb2b1ab3b19b0f2602455c1757a0517fededd51356737120e6a29ce8/botocore-1.35.10.tar.gz", hash = "sha256:6c8a1377b6636a0d80218115e1cd41bcceba0a2f050b79c206f4cf8d002c54d7", size = 12709695 } wheels = [ - { url = "https://files.pythonhosted.org/packages/6d/e4/62d781901fa1543f3274b259b15887e957927f3422e379f04244fae1accf/botocore-1.35.8-py3-none-any.whl", hash = "sha256:adf389eb8fd87775f193300e3431d1353f925807ad3a39958172cb644f0d60a1", size = 12491569 }, + { url = "https://files.pythonhosted.org/packages/f4/1d/2265ef470c95ebf0250f442e17f2ebd80113312c715c877e9161816aa8e8/botocore-1.35.10-py3-none-any.whl", hash = "sha256:0d96d023b9b0cea99a0a428a431d011329d3a958730aee6ed6a6fec5d9bfbc03", size = 12497674 }, ] [[package]] name = "certifi" -version = "2024.7.4" +version = "2024.8.30" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/c2/02/a95f2b11e207f68bc64d7aae9666fed2e2b3f307748d5123dffb72a1bbea/certifi-2024.7.4.tar.gz", hash = "sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b", size = 164065 } +sdist = { url = "https://files.pythonhosted.org/packages/b0/ee/9b19140fe824b367c04c5e1b369942dd754c4c5462d5674002f75c4dedc1/certifi-2024.8.30.tar.gz", hash = "sha256:bec941d2aa8195e248a60b31ff9f0558284cf01a52591ceda73ea9afffd69fd9", size = 168507 } wheels = [ - { url = "https://files.pythonhosted.org/packages/1c/d5/c84e1a17bf61d4df64ca866a1c9a913874b4e9bdc131ec689a0ad013fb36/certifi-2024.7.4-py3-none-any.whl", hash = "sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90", size = 162960 }, + { url = "https://files.pythonhosted.org/packages/12/90/3c9ff0512038035f59d279fddeb79f5f1eccd8859f06d6163c58798b9487/certifi-2024.8.30-py3-none-any.whl", hash = "sha256:922820b53db7a7257ffbda3f597266d435245903d80737e34f8a45ff3e3230d8", size = 167321 }, ] [[package]] @@ -317,7 +317,7 @@ wheels = [ [[package]] name = "igwas" version = "0.1.0" -source = { git = "https://github.com/tatonetti-lab/indirect-gwas#e0546ff0fe39624cfab9bd02cec80dcdd14e5af7" } +source = { git = "https://github.com/tatonetti-lab/indirect-gwas#6d86b6e2acba457d63344a1c0520fa8a85a3c827" } dependencies = [ { name = "numpy" }, { name = "pandas" }, @@ -1059,12 +1059,13 @@ wheels = [ [[package]] name = "webgwas" version = "0.2.0" -source = { git = "https://github.com/zietzm/webgwas.git#d4e1e4a9476446a8fe304c43eff7b44ed3dffd62" } +source = { git = "https://github.com/zietzm/webgwas.git#a150739cba412c9760084f907dcd5d00fe2dc910" } dependencies = [ { name = "igwas" }, { name = "numpy" }, { name = "pandas" }, { name = "polars" }, + { name = "pyarrow" }, { name = "pydantic" }, ]