From 3d1e5ea7ce2f5121c065aeb28da701ed76a1c5df Mon Sep 17 00:00:00 2001 From: Leonardo Mazzone Date: Mon, 2 Dec 2024 11:14:45 +0000 Subject: [PATCH] Move env vars out of justfile --- justfile | 12 +----------- src/matchbox/server/api.py | 6 ++++++ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/justfile b/justfile index 3b5424cf..eb86e9cc 100644 --- a/justfile +++ b/justfile @@ -1,13 +1,3 @@ -export MB__BATCH_SIZE := "10_000" -export MB__BACKEND_TYPE := "postgres" -export MB__DATASETS_CONFIG := "datasets.toml" -export MB__POSTGRES__HOST := "localhost" -export MB__POSTGRES__PORT := "5432" -export MB__POSTGRES__USER := "matchbox_user" -export MB__POSTGRES__PASSWORD := "matchbox_password" -export MB__POSTGRES__DATABASE := "matchbox" -export MB__POSTGRES__DB_SCHEMA := "mb" - # Make datasets table matchbox: uv run python src/matchbox/admin.py --datasets datasets.toml @@ -29,4 +19,4 @@ test: # Run development version of API api: - uv run fastapi dev src/matchbox/server/api.py \ No newline at end of file + uv run fastapi dev src/matchbox/server/api.py \ No newline at end of file diff --git a/src/matchbox/server/api.py b/src/matchbox/server/api.py index 96757231..ea74242b 100644 --- a/src/matchbox/server/api.py +++ b/src/matchbox/server/api.py @@ -1,11 +1,16 @@ from enum import StrEnum from typing import Annotated +from dotenv import find_dotenv, load_dotenv from fastapi import Depends, FastAPI, HTTPException from pydantic import BaseModel from matchbox.server.base import BackendManager, MatchboxDBAdapter +dotenv_path = find_dotenv(usecwd=True) +load_dotenv(dotenv_path) + + app = FastAPI( title="matchbox API", version="0.1.0", @@ -45,6 +50,7 @@ def get_backend() -> MatchboxDBAdapter: @app.get("/health") async def healthcheck() -> HealthCheck: + """ """ return HealthCheck(status="OK")