-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add logger to seeder. #82
Conversation
Problem Seeder had no logger. Uses print statements in exceptions. Solution - Added logger to `seed_database.py` - Modified `Dockerfile.seed` to copy API logger config - Updated exceptions to send errors to logger instead of print Ticket URL https://mediform.atlassian.net/browse/MEDI-39 Documentation N/A Tests Run - Built and run seeder using `docker compose up --build seeder`
@@ -83,7 +93,7 @@ def create_user(user: Dict, db: Session) -> User: | |||
print(e) | |||
db.rollback() | |||
db.flush() | |||
print(f"User {user_obj.email} already exists") | |||
logger.error("Error adding user to database.", exc_info=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this changed to not specify the error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above that:
project-ct/app/api/seeder/seed_database.py
Lines 72 to 76 in 2163dbe
# Create user in database if it doesn't exist | |
user_obj = db.query(User).filter(User.email == user["email"]).first() | |
if user_obj: | |
print(f"User {user_obj.email} already exists") | |
return user_obj |
It already checks if the user exists, so the error is probably something else that the stack trace will reveal using exc_info=True.
@@ -176,8 +186,7 @@ def seed_database(): | |||
print(e) | |||
db.rollback() | |||
db.flush() | |||
print(f"ERROR creating patient encounter: {patient_encounter}") | |||
print(f"\tERROR: {e}") | |||
logger.error(f"Error adding patient encounter to db.", exc_info=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stack trace?
Problem
Seeder had no logger. Uses print statements in exceptions.
Solution
seed_database.py
Dockerfile.seed
to copy API logger configTicket URL
https://mediform.atlassian.net/browse/MEDI-39
Documentation
N/A
Tests Run
docker compose up --build seeder