-
Notifications
You must be signed in to change notification settings - Fork 37
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
Fix bug and Improve error handling in Figures tasks and pipeline #312
Conversation
The pipeline function, bulk_calculate_course_progress_data, does a lot of work and a potential point of failure to fail all the metrics for the course for the day on collecting just one metric. So this commit traps for exceptions when the function "bulk_calculate_course_progress_data" is called and sets the course daily metrics 'average_progress' to None if it fails. Being 'None' helps identify pipeline erors rather than setting progress to zero. Added test to make sure we are logging when it fails
Added exception handling and logging to populate_single_cdm, the call to update_enrollment_data in 'populate_daily_metrics' and exception handling for each site so that one site does not fail the remaining sites in the chain * Updated tests to handle when update_enrollment_data raises an exception * Updated tests to handle when a site level exception is raised
This function is running into 'CourseNotFound' exceptions. Because of a poorly place paranthesis in the logger message, the function then threw a "TypeError: str() takes at most 1 argument (2 given)" which THEN caused the whole daily metrics pipeline to fail because I forgot to wrap the new code in exception handling
Thanks @thraxil ! |
figures/backfill.py
Outdated
' CourseEnrollment ID='.format(str(rec.course_id), | ||
rec.id)) |
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.
Must: An additional {}
is needed. I've added a suggestion to fix the issue.
' CourseEnrollment ID='.format(str(rec.course_id), | |
rec.id)) | |
errors.append( | |
'CourseNotFound for course "{course}". CourseEnrollment ID={rec}'.format( | |
course=str(rec.course_id), | |
rec=rec.id, | |
) | |
) |
figures/backfill.py
Outdated
@@ -67,7 +67,7 @@ def backfill_enrollment_data_for_site(site): | |||
enrollment_data.append((obj, created)) | |||
except CourseNotFound: | |||
errors.append('CourseNotFound for course "{}". ' |
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.
See the related suggestion on the line below.
errors.append('CourseNotFound for course "{}". ' |
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.
@OmarIthawi Thanks, I've got a code cleanup effort to do. When I hit the pipeline logging, adding format vars and making sure all exceptions are tested will be part of that
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.
@OmarIthawi I saw I had a missing '{}' in the string, so adding vars to the format . Thanks!
Tox passed locally, force merging. Maybe I regret it. We'll see |
Fixed the bug, poorly placed parentheses within exception handling in the new code
Add pipeline exception handling - course daily metrics
The pipeline function, bulk_calculate_course_progress_data, does a lot
of work and a potential point of failure to fail all the metrics for the
course for the day on collecting just one metric.
So this commit traps for exceptions when the function
"bulk_calculate_course_progress_data" is called and sets the course daily
metrics 'average_progress' to None if it fails. Being 'None' helps
identify pipeline erors rather than setting progress to zero.
Added test to make sure we are logging when it fails
Added exception handling and logging to populate_single_cdm, the call to
update_enrollment_data in 'populate_daily_metrics' and exception
handling for each site so that one site does not fail the remaining
sites in the chain
https://appsembler.atlassian.net/browse/RED-1709