From d7213716e5fce65832ddaf26d8f805d4fc682c6c Mon Sep 17 00:00:00 2001 From: Sherika Date: Thu, 21 Nov 2024 06:19:05 -0500 Subject: [PATCH 1/2] Add logging utility and refactor app structure --- app.py | 13 ++----------- utils/__init__.py | 0 utils/logging_utils.py | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 utils/__init__.py create mode 100644 utils/logging_utils.py diff --git a/app.py b/app.py index 95040d8..c47951a 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,6 @@ import streamlit as st import os -import logging +from utils.logging_utils import setup_logging from typing import Dict, List from datetime import datetime from dotenv import load_dotenv @@ -93,16 +93,7 @@ def get_svg_base64(svg_content): """, unsafe_allow_html=True) -# Configure logging -logging.basicConfig( - level=logging.INFO, - format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', - handlers=[ - logging.FileHandler('vetsai.log'), - logging.StreamHandler() - ] -) -logger = logging.getLogger(__name__) +logger = setup_logging() # Load environment variables load_dotenv() diff --git a/utils/__init__.py b/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/utils/logging_utils.py b/utils/logging_utils.py new file mode 100644 index 0000000..2c1f91c --- /dev/null +++ b/utils/logging_utils.py @@ -0,0 +1,15 @@ +import logging + +def setup_logging(): + + # Configure logging + logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', + handlers=[ + logging.FileHandler('vetsai.log'), + logging.StreamHandler() + ] + ) + logger = logging.getLogger(__name__) + return logger From 4d34d6a9de54b0129b72259d1b24dadc6d9c5b98 Mon Sep 17 00:00:00 2001 From: Sherika Date: Mon, 25 Nov 2024 20:31:37 -0500 Subject: [PATCH 2/2] updated test streamlit file --- tests/test_streamlit_app.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_streamlit_app.py b/tests/test_streamlit_app.py index 2392b46..98d05b6 100644 --- a/tests/test_streamlit_app.py +++ b/tests/test_streamlit_app.py @@ -147,6 +147,7 @@ def test_translate_military_code_not_found(self, mock_job_codes): assert isinstance(result["data"]["tech_focus"], list) class TestChatFunctionality: + @patch.dict(os.environ, {"OPENAI_API_KEY": "test_api_key"}) @patch('openai.OpenAI') def test_get_chat_response(self, mock_openai): mock_client = MagicMock()