in the problemgradereport currently we must currently hold the entire file in memory before writing it all at once. to avoid out of memory celery issues to resolve a blocking bug for some MIT courses, add a temp waffle flag `instructor_task.use_on_disk_grade_reporting` which when activated uses this new report to (hopefully) allow the report to complete. Additional testing and consideration is required for this approach.
72 lines
2.3 KiB
Python
72 lines
2.3 KiB
Python
"""
|
|
This module contains various configuration settings via
|
|
waffle switches for the instructor_task app.
|
|
"""
|
|
|
|
from edx_toggles.toggles import WaffleSwitch
|
|
|
|
from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag
|
|
|
|
|
|
WAFFLE_NAMESPACE = 'instructor_task'
|
|
|
|
# Waffle switches
|
|
OPTIMIZE_GET_LEARNERS_FOR_COURSE = WaffleSwitch( # lint-amnesty, pylint: disable=toggle-missing-annotation
|
|
f'{WAFFLE_NAMESPACE}.optimize_get_learners_for_course', __name__
|
|
)
|
|
|
|
# Course override flags
|
|
GENERATE_PROBLEM_GRADE_REPORT_VERIFIED_ONLY = CourseWaffleFlag( # lint-amnesty, pylint: disable=toggle-missing-annotation
|
|
f'{WAFFLE_NAMESPACE}.generate_problem_grade_report_verified_only', __name__
|
|
)
|
|
|
|
GENERATE_COURSE_GRADE_REPORT_VERIFIED_ONLY = CourseWaffleFlag( # lint-amnesty, pylint: disable=toggle-missing-annotation
|
|
f'{WAFFLE_NAMESPACE}.generate_course_grade_report_verified_only', __name__
|
|
)
|
|
|
|
# .. toggle_name: instructor_task.use_on_disk_grade_reporting
|
|
# .. toggle_implementation: CourseWaffleFlag
|
|
# .. toggle_default: False
|
|
# .. toggle_description: When generating grade reports, write chunks to disk to avoid out of memory errors.
|
|
# .. toggle_use_cases: temporary
|
|
# .. toggle_creation_date: 2022-12-01
|
|
# .. toggle_target_removal_date: 2022-01-10
|
|
# .. toggle_tickets: AU-926
|
|
USE_ON_DISK_GRADE_REPORTING = CourseWaffleFlag(
|
|
f'{WAFFLE_NAMESPACE}.use_on_disk_grade_reporting', __name__
|
|
)
|
|
|
|
|
|
def optimize_get_learners_switch_enabled():
|
|
"""
|
|
Returns True if optimize get learner switch is enabled, otherwise False.
|
|
"""
|
|
return OPTIMIZE_GET_LEARNERS_FOR_COURSE.is_enabled()
|
|
|
|
|
|
def problem_grade_report_verified_only(course_id):
|
|
"""
|
|
Returns True if problem grade reports should only
|
|
return rows for verified students in the given course,
|
|
False otherwise.
|
|
"""
|
|
return GENERATE_PROBLEM_GRADE_REPORT_VERIFIED_ONLY.is_enabled(course_id)
|
|
|
|
|
|
def course_grade_report_verified_only(course_id):
|
|
"""
|
|
Returns True if problem grade reports should only
|
|
return rows for verified students in the given course,
|
|
False otherwise.
|
|
"""
|
|
return GENERATE_COURSE_GRADE_REPORT_VERIFIED_ONLY.is_enabled(course_id)
|
|
|
|
|
|
def use_on_disk_grade_reporting(course_id):
|
|
"""
|
|
Returns True if problem grade reports should write
|
|
chunks to disk rather than holding all in memory.
|
|
False otherwise.
|
|
"""
|
|
return USE_ON_DISK_GRADE_REPORTING.is_enabled(course_id)
|