Commit aafd4d9c by Alex Dusenbery Committed by Alex Dusenbery

Turn down grades logging; put policy change regrade behind a waffle killswitch.

parent d8a974b6
......@@ -11,6 +11,7 @@ WAFFLE_NAMESPACE = u'grades'
WRITE_ONLY_IF_ENGAGED = u'write_only_if_engaged'
ASSUME_ZERO_GRADE_IF_ABSENT = u'assume_zero_grade_if_absent'
ESTIMATE_FIRST_ATTEMPTED = u'estimate_first_attempted'
DISABLE_REGRADE_ON_POLICY_CHANGE = u'disable_regrade_on_policy_change'
def waffle():
......
......@@ -154,7 +154,7 @@ class CourseGradeFactory(object):
"""
Returns a ZeroCourseGrade object for the given user and course.
"""
log.info(u'Grades: CreateZero, %s, User: %s', unicode(course_data), user.id)
log.debug(u'Grades: CreateZero, %s, User: %s', unicode(course_data), user.id)
return ZeroCourseGrade(user, course_data)
@staticmethod
......
......@@ -230,12 +230,6 @@ def enqueue_subsection_update(sender, **kwargs): # pylint: disable=unused-argum
),
countdown=RECALCULATE_GRADE_DELAY,
)
log.info(
u'Grades: Request async calculation of subsection grades with args: {}. Task [{}]'.format(
', '.join('{}:{}'.format(arg, kwargs[arg]) for arg in sorted(kwargs)),
getattr(result, 'id', 'N/A'),
)
)
@receiver(SUBSECTION_SCORE_CHANGED)
......
......@@ -26,7 +26,7 @@ from track.event_transaction_utils import set_event_transaction_id, set_event_tr
from util.date_utils import from_timestamp
from xmodule.modulestore.django import modulestore
from .config.waffle import ESTIMATE_FIRST_ATTEMPTED, waffle
from .config.waffle import ESTIMATE_FIRST_ATTEMPTED, DISABLE_REGRADE_ON_POLICY_CHANGE, waffle
from .constants import ScoreDatabaseTableEnum
from .exceptions import DatabaseNotReadyError
from .new.course_grade_factory import CourseGradeFactory
......@@ -58,14 +58,19 @@ def compute_all_grades_for_course(**kwargs):
Kicks off a series of compute_grades_for_course_v2 tasks
to cover all of the students in the course.
"""
course_key = CourseKey.from_string(kwargs.pop('course_key'))
for course_key_string, offset, batch_size in _course_task_args(course_key=course_key, **kwargs):
kwargs.update({
'course_key': course_key_string,
'offset': offset,
'batch_size': batch_size,
})
compute_grades_for_course_v2.apply_async(kwargs=kwargs, routing_key=settings.POLICY_CHANGE_GRADES_ROUTING_KEY)
if waffle().is_enabled(DISABLE_REGRADE_ON_POLICY_CHANGE):
log.debug('Grades: ignoring policy change regrade due to waffle switch')
else:
course_key = CourseKey.from_string(kwargs.pop('course_key'))
for course_key_string, offset, batch_size in _course_task_args(course_key=course_key, **kwargs):
kwargs.update({
'course_key': course_key_string,
'offset': offset,
'batch_size': batch_size,
})
compute_grades_for_course_v2.apply_async(
kwargs=kwargs, routing_key=settings.POLICY_CHANGE_GRADES_ROUTING_KEY
)
@task(base=_BaseTask, bind=True, default_retry_delay=30, max_retries=1)
......
......@@ -727,10 +727,6 @@ class TestCourseGradeLogging(ProblemSubmissionTestMixin, SharedModuleStoreTestCa
enabled_for_course=True
):
with patch('lms.djangoapps.grades.new.course_grade_factory.log') as log_mock:
# returns Zero when no grade, with ASSUME_ZERO_GRADE_IF_ABSENT
with waffle().override(ASSUME_ZERO_GRADE_IF_ABSENT, active=True):
self._create_course_grade_and_check_logging(grade_factory.create, log_mock.info, u'CreateZero')
# read, but not persisted
self._create_course_grade_and_check_logging(grade_factory.create, log_mock.info, u'Update')
......
......@@ -197,28 +197,6 @@ class ScoreChangedSignalRelayTest(TestCase):
expected_set_kwargs['score_deleted'] = False
self.signal_mock.assert_called_with(**expected_set_kwargs)
@patch('lms.djangoapps.grades.signals.handlers.log.info')
def test_subsection_update_logging(self, mocklog):
enqueue_subsection_update(
sender='test',
user_id=1,
course_id=u'course-v1:edX+Demo_Course+DemoX',
usage_id=u'block-v1:block-key',
modified=FROZEN_NOW_DATETIME,
score_db_table=ScoreDatabaseTableEnum.courseware_student_module,
)
log_statement = mocklog.call_args[0][0]
log_statement = UUID_REGEX.sub(u'*UUID*', log_statement)
self.assertEqual(
log_statement,
(
u'Grades: Request async calculation of subsection grades with args: '
u'course_id:course-v1:edX+Demo_Course+DemoX, modified:{time}, '
u'score_db_table:csm, '
u'usage_id:block-v1:block-key, user_id:1. Task [*UUID*]'
).format(time=FROZEN_NOW_DATETIME)
)
@ddt.data(
[score_set, 'lms.djangoapps.grades.signals.handlers.submissions_score_set_handler', SUBMISSION_SET_KWARGS],
[score_reset, 'lms.djangoapps.grades.signals.handlers.submissions_score_reset_handler', SUBMISSION_RESET_KWARGS]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment