Skip to content
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

Merged
merged 4 commits into from
Dec 17, 2020

Conversation

johnbaldwin
Copy link
Contributor

@johnbaldwin johnbaldwin commented Dec 17, 2020

  1. Fixed the bug, poorly placed parentheses within exception handling in the new code

  2. 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

  1. Add figures.tasks exception handling cdm and enrollment data
    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

https://appsembler.atlassian.net/browse/RED-1709

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
@johnbaldwin johnbaldwin changed the title Improve error handling in Figures tasks and pipeline Fix bug and Improve error handling in Figures tasks and pipeline Dec 17, 2020
@johnbaldwin
Copy link
Contributor Author

Thanks @thraxil !

Comment on lines 70 to 71
' CourseEnrollment ID='.format(str(rec.course_id),
rec.id))
Copy link
Contributor

@OmarIthawi OmarIthawi Dec 17, 2020

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.

Suggested change
' 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,
)
)

@@ -67,7 +67,7 @@ def backfill_enrollment_data_for_site(site):
enrollment_data.append((obj, created))
except CourseNotFound:
errors.append('CourseNotFound for course "{}". '
Copy link
Contributor

@OmarIthawi OmarIthawi Dec 17, 2020

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.

Suggested change
errors.append('CourseNotFound for course "{}". '

Copy link
Contributor Author

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

Copy link
Contributor Author

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!

@johnbaldwin johnbaldwin merged commit 6ff2853 into master Dec 17, 2020
@johnbaldwin
Copy link
Contributor Author

Tox passed locally, force merging. Maybe I regret it. We'll see

@johnbaldwin johnbaldwin deleted the john/0.4-pipeline-exception-handling branch December 17, 2020 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants