Skip to content

Commit

Permalink
Add logging utility and refactor app structure (#22)
Browse files Browse the repository at this point in the history
* Add logging utility and refactor app structure

* updated test streamlit file
  • Loading branch information
Sfayson1 authored Nov 30, 2024
1 parent 485cb6a commit cd3f1c8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
13 changes: 2 additions & 11 deletions app.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -95,16 +95,7 @@ def get_svg_base64(svg_content):
</style>
""", 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()
Expand Down
1 change: 1 addition & 0 deletions tests/test_streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Empty file added utils/__init__.py
Empty file.
15 changes: 15 additions & 0 deletions utils/logging_utils.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cd3f1c8

Please sign in to comment.