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
da13a7db
Commit
da13a7db
authored
Apr 26, 2017
by
Cliff Dyer
Committed by
GitHub
Apr 26, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14982 from edx/neem/batch-size-error
Fix batch size error and kwargification of compute_v2.
parents
38c0fbd6
77f5e2dd
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 @
da13a7db
...
...
@@ -94,12 +94,12 @@ class Command(BaseCommand):
enrollment_count
=
CourseEnrollment
.
objects
.
filter
(
course_id
=
course_key
)
.
count
()
if
enrollment_count
==
0
:
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
# created, the most recent enrollments may not get processed.
# This is an acceptable limitation for our known use cases.
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
=
{
'course_key'
:
six
.
text_type
(
course_key
),
'offset'
:
offset
,
...
...
lms/djangoapps/grades/management/commands/tests/test_compute_grades.py
View file @
da13a7db
...
...
@@ -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 @
da13a7db
...
...
@@ -55,7 +55,7 @@ class _BaseTask(PersistOnFailureTask, LoggedTask): # pylint: disable=abstract-m
@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.
...
...
lms/djangoapps/grades/tests/test_tasks.py
View file @
da13a7db
...
...
@@ -31,7 +31,7 @@ from lms.djangoapps.grades.constants import ScoreDatabaseTableEnum
from
lms.djangoapps.grades.models
import
PersistentCourseGrade
,
PersistentSubsectionGrade
from
lms.djangoapps.grades.signals.signals
import
PROBLEM_WEIGHTED_SCORE_CHANGED
from
lms.djangoapps.grades.tasks
import
(
compute_grades_for_course
,
compute_grades_for_course
_v2
,
recalculate_subsection_grade_v3
,
RECALCULATE_GRADE_DELAY
)
...
...
@@ -378,7 +378,7 @@ class RecalculateSubsectionGradeTest(HasCourseWithProblemsMixin, ModuleStoreTest
@ddt.ddt
class
ComputeGradesForCourseTest
(
HasCourseWithProblemsMixin
,
ModuleStoreTestCase
):
"""
Test compute_grades_for_course task.
Test compute_grades_for_course
_v2
task.
"""
ENABLED_SIGNALS
=
[
'course_published'
,
'pre_publish'
]
...
...
@@ -392,7 +392,7 @@ class ComputeGradesForCourseTest(HasCourseWithProblemsMixin, ModuleStoreTestCase
@ddt.data
(
*
xrange
(
0
,
12
,
3
))
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
),
batch_size
=
batch_size
,
offset
=
4
,
...
...
@@ -412,7 +412,7 @@ class ComputeGradesForCourseTest(HasCourseWithProblemsMixin, ModuleStoreTestCase
per_user_queries
=
17
*
min
(
batch_size
,
6
)
# No more than 6 due to offset
with
self
.
assertNumQueries
(
5
+
per_user_queries
):
with
check_mongo_calls
(
1
):
compute_grades_for_course
.
delay
(
compute_grades_for_course
_v2
.
delay
(
course_key
=
six
.
text_type
(
self
.
course
.
id
),
batch_size
=
batch_size
,
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