Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
77f5e2dd
Commit
77f5e2dd
authored
Apr 26, 2017
by
J. Cliff Dyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix batch size error and kwargification of compute_v2.
parent
38c0fbd6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
7 deletions
+33
-7
lms/djangoapps/grades/management/commands/compute_grades.py
+2
-2
lms/djangoapps/grades/management/commands/tests/test_compute_grades.py
+26
-0
lms/djangoapps/grades/tasks.py
+1
-1
lms/djangoapps/grades/tests/test_tasks.py
+4
-4
No files found.
lms/djangoapps/grades/management/commands/compute_grades.py
View file @
77f5e2dd
...
@@ -94,12 +94,12 @@ class Command(BaseCommand):
...
@@ -94,12 +94,12 @@ class Command(BaseCommand):
enrollment_count
=
CourseEnrollment
.
objects
.
filter
(
course_id
=
course_key
)
.
count
()
enrollment_count
=
CourseEnrollment
.
objects
.
filter
(
course_id
=
course_key
)
.
count
()
if
enrollment_count
==
0
:
if
enrollment_count
==
0
:
log
.
warning
(
"No enrollments found for {}"
.
format
(
course_key
))
log
.
warning
(
"No enrollments found for {}"
.
format
(
course_key
))
for
offset
in
six
.
moves
.
range
(
options
[
'start_index'
],
enrollment_count
,
options
[
'batch_size'
]):
batch_size
=
self
.
_latest_settings
()
.
batch_size
if
options
.
get
(
'from_settings'
)
else
options
[
'batch_size'
]
for
offset
in
six
.
moves
.
range
(
options
[
'start_index'
],
enrollment_count
,
batch_size
):
# If the number of enrollments increases after the tasks are
# If the number of enrollments increases after the tasks are
# created, the most recent enrollments may not get processed.
# created, the most recent enrollments may not get processed.
# This is an acceptable limitation for our known use cases.
# This is an acceptable limitation for our known use cases.
task_options
=
{
'routing_key'
:
options
[
'routing_key'
]}
if
options
.
get
(
'routing_key'
)
else
{}
task_options
=
{
'routing_key'
:
options
[
'routing_key'
]}
if
options
.
get
(
'routing_key'
)
else
{}
batch_size
=
self
.
_latest_settings
()
.
batch_size
if
options
.
get
(
'from_settings'
)
else
options
[
'batch_size'
]
kwargs
=
{
kwargs
=
{
'course_key'
:
six
.
text_type
(
course_key
),
'course_key'
:
six
.
text_type
(
course_key
),
'offset'
:
offset
,
'offset'
:
offset
,
...
...
lms/djangoapps/grades/management/commands/tests/test_compute_grades.py
View file @
77f5e2dd
...
@@ -118,3 +118,29 @@ class TestComputeGrades(SharedModuleStoreTestCase):
...
@@ -118,3 +118,29 @@ class TestComputeGrades(SharedModuleStoreTestCase):
},),
},),
],
],
)
)
@patch
(
'lms.djangoapps.grades.tasks.compute_grades_for_course_v2'
)
def
test_tasks_fired_from_settings
(
self
,
mock_task
):
ComputeGradesSetting
.
objects
.
create
(
course_ids
=
self
.
course_keys
[
1
],
batch_size
=
2
)
call_command
(
'compute_grades'
,
'--from_settings'
)
self
.
assertEqual
(
mock_task
.
apply_async
.
call_args_list
,
[
({
'kwargs'
:
{
'course_key'
:
self
.
course_keys
[
1
],
'batch_size'
:
2
,
'offset'
:
0
,
'estimate_first_attempted'
:
True
},
},),
({
'kwargs'
:
{
'course_key'
:
self
.
course_keys
[
1
],
'batch_size'
:
2
,
'offset'
:
2
,
'estimate_first_attempted'
:
True
},
},),
],
)
lms/djangoapps/grades/tasks.py
View file @
77f5e2dd
...
@@ -55,7 +55,7 @@ class _BaseTask(PersistOnFailureTask, LoggedTask): # pylint: disable=abstract-m
...
@@ -55,7 +55,7 @@ class _BaseTask(PersistOnFailureTask, LoggedTask): # pylint: disable=abstract-m
@task
(
base
=
_BaseTask
)
@task
(
base
=
_BaseTask
)
def
compute_grades_for_course_v2
(
course_key
,
offset
,
batch_size
,
**
kwargs
):
def
compute_grades_for_course_v2
(
**
kwargs
):
"""
"""
Compute grades for a set of students in the specified course.
Compute grades for a set of students in the specified course.
...
...
lms/djangoapps/grades/tests/test_tasks.py
View file @
77f5e2dd
...
@@ -31,7 +31,7 @@ from lms.djangoapps.grades.constants import ScoreDatabaseTableEnum
...
@@ -31,7 +31,7 @@ from lms.djangoapps.grades.constants import ScoreDatabaseTableEnum
from
lms.djangoapps.grades.models
import
PersistentCourseGrade
,
PersistentSubsectionGrade
from
lms.djangoapps.grades.models
import
PersistentCourseGrade
,
PersistentSubsectionGrade
from
lms.djangoapps.grades.signals.signals
import
PROBLEM_WEIGHTED_SCORE_CHANGED
from
lms.djangoapps.grades.signals.signals
import
PROBLEM_WEIGHTED_SCORE_CHANGED
from
lms.djangoapps.grades.tasks
import
(
from
lms.djangoapps.grades.tasks
import
(
compute_grades_for_course
,
compute_grades_for_course
_v2
,
recalculate_subsection_grade_v3
,
recalculate_subsection_grade_v3
,
RECALCULATE_GRADE_DELAY
RECALCULATE_GRADE_DELAY
)
)
...
@@ -378,7 +378,7 @@ class RecalculateSubsectionGradeTest(HasCourseWithProblemsMixin, ModuleStoreTest
...
@@ -378,7 +378,7 @@ class RecalculateSubsectionGradeTest(HasCourseWithProblemsMixin, ModuleStoreTest
@ddt.ddt
@ddt.ddt
class
ComputeGradesForCourseTest
(
HasCourseWithProblemsMixin
,
ModuleStoreTestCase
):
class
ComputeGradesForCourseTest
(
HasCourseWithProblemsMixin
,
ModuleStoreTestCase
):
"""
"""
Test compute_grades_for_course task.
Test compute_grades_for_course
_v2
task.
"""
"""
ENABLED_SIGNALS
=
[
'course_published'
,
'pre_publish'
]
ENABLED_SIGNALS
=
[
'course_published'
,
'pre_publish'
]
...
@@ -392,7 +392,7 @@ class ComputeGradesForCourseTest(HasCourseWithProblemsMixin, ModuleStoreTestCase
...
@@ -392,7 +392,7 @@ class ComputeGradesForCourseTest(HasCourseWithProblemsMixin, ModuleStoreTestCase
@ddt.data
(
*
xrange
(
0
,
12
,
3
))
@ddt.data
(
*
xrange
(
0
,
12
,
3
))
def
test_behavior
(
self
,
batch_size
):
def
test_behavior
(
self
,
batch_size
):
result
=
compute_grades_for_course
.
delay
(
result
=
compute_grades_for_course
_v2
.
delay
(
course_key
=
six
.
text_type
(
self
.
course
.
id
),
course_key
=
six
.
text_type
(
self
.
course
.
id
),
batch_size
=
batch_size
,
batch_size
=
batch_size
,
offset
=
4
,
offset
=
4
,
...
@@ -412,7 +412,7 @@ class ComputeGradesForCourseTest(HasCourseWithProblemsMixin, ModuleStoreTestCase
...
@@ -412,7 +412,7 @@ class ComputeGradesForCourseTest(HasCourseWithProblemsMixin, ModuleStoreTestCase
per_user_queries
=
17
*
min
(
batch_size
,
6
)
# No more than 6 due to offset
per_user_queries
=
17
*
min
(
batch_size
,
6
)
# No more than 6 due to offset
with
self
.
assertNumQueries
(
5
+
per_user_queries
):
with
self
.
assertNumQueries
(
5
+
per_user_queries
):
with
check_mongo_calls
(
1
):
with
check_mongo_calls
(
1
):
compute_grades_for_course
.
delay
(
compute_grades_for_course
_v2
.
delay
(
course_key
=
six
.
text_type
(
self
.
course
.
id
),
course_key
=
six
.
text_type
(
self
.
course
.
id
),
batch_size
=
batch_size
,
batch_size
=
batch_size
,
offset
=
6
,
offset
=
6
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment