From 467ef8cb6ef3cac3d7cda4783c1c569eff3c10c5 Mon Sep 17 00:00:00 2001 From: francastell Date: Mon, 15 Jul 2024 15:03:13 -0400 Subject: [PATCH 1/2] G3-271 system health check udpates --- poetry.lock | 26 +++++++++++------------ pyproject.toml | 4 ++-- src/geneweaver/api/controller/monitors.py | 7 ++++-- tests/controllers/test_monitor.py | 2 +- tests/data/monitors.json | 2 ++ 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/poetry.lock b/poetry.lock index 1d961ba..7ac905f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. [[package]] name = "annotated-types" @@ -465,13 +465,13 @@ files = [ [[package]] name = "exceptiongroup" -version = "1.2.1" +version = "1.2.2" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" files = [ - {file = "exceptiongroup-1.2.1-py3-none-any.whl", hash = "sha256:5258b9ed329c5bbdd31a309f53cbfb0b155341807f6ff7606a1e801a891b29ad"}, - {file = "exceptiongroup-1.2.1.tar.gz", hash = "sha256:a4785e48b045528f5bfe627b6ad554ff32def154f42372786903b7abcfe1aa16"}, + {file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"}, + {file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"}, ] [package.extras] @@ -479,13 +479,13 @@ test = ["pytest (>=6)"] [[package]] name = "fastapi" -version = "0.111.0" +version = "0.111.1" description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production" optional = false python-versions = ">=3.8" files = [ - {file = "fastapi-0.111.0-py3-none-any.whl", hash = "sha256:97ecbf994be0bcbdadedf88c3150252bed7b2087075ac99735403b1b76cc8fc0"}, - {file = "fastapi-0.111.0.tar.gz", hash = "sha256:b9db9dd147c91cb8b769f7183535773d8741dd46f9dc6676cd82eab510228cd7"}, + {file = "fastapi-0.111.1-py3-none-any.whl", hash = "sha256:4f51cfa25d72f9fbc3280832e84b32494cf186f50158d364a8765aabf22587bf"}, + {file = "fastapi-0.111.1.tar.gz", hash = "sha256:ddd1ac34cb1f76c2e2d7f8545a4bcb5463bce4834e81abf0b189e0c359ab2413"}, ] [package.dependencies] @@ -494,7 +494,7 @@ fastapi-cli = ">=0.0.2" httpx = ">=0.23.0" itsdangerous = {version = ">=1.1.0", optional = true, markers = "extra == \"all\""} jinja2 = ">=2.11.2" -orjson = ">=3.2.1" +orjson = {version = ">=3.2.1", optional = true, markers = "extra == \"all\""} pydantic = ">=1.7.4,<1.8 || >1.8,<1.8.1 || >1.8.1,<2.0.0 || >2.0.0,<2.0.1 || >2.0.1,<2.1.0 || >2.1.0,<3.0.0" pydantic-extra-types = {version = ">=2.0.0", optional = true, markers = "extra == \"all\""} pydantic-settings = {version = ">=2.0.0", optional = true, markers = "extra == \"all\""} @@ -502,7 +502,7 @@ python-multipart = ">=0.0.7" pyyaml = {version = ">=5.3.1", optional = true, markers = "extra == \"all\""} starlette = ">=0.37.2,<0.38.0" typing-extensions = ">=4.8.0" -ujson = ">=4.0.1,<4.0.2 || >4.0.2,<4.1.0 || >4.1.0,<4.2.0 || >4.2.0,<4.3.0 || >4.3.0,<5.0.0 || >5.0.0,<5.1.0 || >5.1.0" +ujson = {version = ">=4.0.1,<4.0.2 || >4.0.2,<4.1.0 || >4.1.0,<4.2.0 || >4.2.0,<4.3.0 || >4.3.0,<5.0.0 || >5.0.0,<5.1.0 || >5.1.0", optional = true, markers = "extra == \"all\""} uvicorn = {version = ">=0.12.0", extras = ["standard"]} [package.extras] @@ -546,13 +546,13 @@ requests = ">=2.32.0,<3.0.0" [[package]] name = "geneweaver-db" -version = "0.5.0a12" +version = "0.5.0a13" description = "Database Interaction Services for GeneWeaver" optional = false python-versions = "<4.0,>=3.9" files = [ - {file = "geneweaver_db-0.5.0a12-py3-none-any.whl", hash = "sha256:35e94e2311521cdf46625b37f0e39c56d906f3b8b3f6e77a0cf0702f42aa207d"}, - {file = "geneweaver_db-0.5.0a12.tar.gz", hash = "sha256:566497f0cabcf5ef47f42cb73cdef2dc751a06ee7ee230ba43e1334d98190db8"}, + {file = "geneweaver_db-0.5.0a13-py3-none-any.whl", hash = "sha256:ab90b269555555d99d954a57f4995c523128aa6e63e5552449701305318f9ed8"}, + {file = "geneweaver_db-0.5.0a13.tar.gz", hash = "sha256:1bb07a7fd1fac184fc3e921258da726be2a594c132dd3a91210b164dc6b94fe4"}, ] [package.dependencies] @@ -2209,4 +2209,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "1b310c7168ab32c09189590615093449fc67198301f3293055bc6e3dca638a97" +content-hash = "35fe67531f3c2127075570dbcef3ae8fd72ba563c31dd518f4f478e594dda845" diff --git a/pyproject.toml b/pyproject.toml index 6badaef..2e26861 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "geneweaver-api" -version = "0.7.0a8" +version = "0.7.0a9" description = "The Geneweaver API" authors = [ "Alexander Berger ", @@ -20,7 +20,7 @@ python = "^3.9" geneweaver-core = "^0.10.0a3" fastapi = {extras = ["all"], version = "^0.111.0"} uvicorn = {extras = ["standard"], version = "^0.30.0"} -geneweaver-db = "0.5.0a12" +geneweaver-db = "0.5.0a13" psycopg-pool = "^3.1.7" requests = "^2.32.3" python-jose = {extras = ["cryptography"], version = "^3.3.0"} diff --git a/src/geneweaver/api/controller/monitors.py b/src/geneweaver/api/controller/monitors.py index b0cc37d..39ad504 100644 --- a/src/geneweaver/api/controller/monitors.py +++ b/src/geneweaver/api/controller/monitors.py @@ -6,7 +6,7 @@ from geneweaver.api import dependencies as deps from geneweaver.api.services import monitors as monitors_service from typing_extensions import Annotated - +from datetime import datetime from . import message as api_message router = APIRouter(prefix="/monitors", tags=["monitors"]) @@ -20,7 +20,10 @@ def get_health_check( ] = False, ) -> dict: """Return 200 API response if reachable and optionally check db health.""" - response = {"status": "UP"} + response = {"status": "UP", + "details": "All systems normal.", + "datetime": datetime.utcnow(), + } if db_health_check: db_health_response = monitors_service.check_db_health(cursor) diff --git a/tests/controllers/test_monitor.py b/tests/controllers/test_monitor.py index c4bbec5..90ac327 100644 --- a/tests/controllers/test_monitor.py +++ b/tests/controllers/test_monitor.py @@ -20,4 +20,4 @@ def test_valid_url_req(mock_db_heath_service_call, client): url="/api/monitors/servers/health", params={"db_health_check": True} ) assert response.status_code == 200 - assert response.json() == db_health_status + assert response.json().get("DB_status") == db_health_status.get("DB_status") diff --git a/tests/data/monitors.json b/tests/data/monitors.json index a8c85d8..0bc23ff 100644 --- a/tests/data/monitors.json +++ b/tests/data/monitors.json @@ -1,6 +1,8 @@ { "db_health_status": { "status": "UP", + "details": "All systems normal.", + "datetime": "2024-07-15T18:50:37.318238", "DB_status": { "gene_identifier_last_update": { "gi_date": "2024-06-24T01:54:48.023015+00:00" From 5a21d7ccdd5c8174f8a1fd0ee8f245f0ec18a1df Mon Sep 17 00:00:00 2001 From: francastell Date: Mon, 15 Jul 2024 15:05:48 -0400 Subject: [PATCH 2/2] G3-271 lint checks --- src/geneweaver/api/controller/monitors.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/geneweaver/api/controller/monitors.py b/src/geneweaver/api/controller/monitors.py index 39ad504..40feb9a 100644 --- a/src/geneweaver/api/controller/monitors.py +++ b/src/geneweaver/api/controller/monitors.py @@ -1,12 +1,13 @@ """Endpoints related to system health.""" +from datetime import datetime from typing import Optional from fastapi import APIRouter, Depends, Query from geneweaver.api import dependencies as deps from geneweaver.api.services import monitors as monitors_service from typing_extensions import Annotated -from datetime import datetime + from . import message as api_message router = APIRouter(prefix="/monitors", tags=["monitors"]) @@ -20,10 +21,11 @@ def get_health_check( ] = False, ) -> dict: """Return 200 API response if reachable and optionally check db health.""" - response = {"status": "UP", - "details": "All systems normal.", - "datetime": datetime.utcnow(), - } + response = { + "status": "UP", + "details": "All systems normal.", + "datetime": datetime.utcnow(), + } if db_health_check: db_health_response = monitors_service.check_db_health(cursor)