Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-ora2
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-ora2
Commits
a076fd25
Commit
a076fd25
authored
Jun 04, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove cache key versioning
parent
2cb7cae6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
32 deletions
+4
-32
apps/openassessment/assessment/models/training.py
+3
-9
apps/openassessment/assessment/serializers/base.py
+1
-23
No files found.
apps/openassessment/assessment/models/training.py
View file @
a076fd25
...
...
@@ -23,10 +23,6 @@ class TrainingExample(models.Model):
# SHA1 hash
content_hash
=
models
.
CharField
(
max_length
=
40
,
unique
=
True
,
db_index
=
True
)
# Version for models serialized to the cache
# Increment this number whenever you update this model!
CACHE_KEY_VERSION
=
1
class
Meta
:
app_label
=
"assessment"
...
...
@@ -102,12 +98,11 @@ class TrainingExample(models.Model):
"""
if
attribute
is
None
:
key_template
=
u"TrainingExample.json.
v{version}.
{content_hash}"
key_template
=
u"TrainingExample.json.{content_hash}"
else
:
key_template
=
u"TrainingExample.{attribute}.json.
v{version}.
{content_hash}"
key_template
=
u"TrainingExample.{attribute}.json.{content_hash}"
cache_key
=
key_template
.
format
(
version
=
self
.
CACHE_KEY_VERSION
,
content_hash
=
self
.
content_hash
,
attribute
=
attribute
)
...
...
@@ -149,8 +144,7 @@ class TrainingExample(models.Model):
"""
content_hash
=
cls
.
calculate_hash
(
answer
,
options_selected
,
rubric
)
cache_key
=
u"TrainingExample.model.v{version}.{content_hash}"
.
format
(
version
=
cls
.
CACHE_KEY_VERSION
,
cache_key
=
u"TrainingExample.model.{content_hash}"
.
format
(
content_hash
=
content_hash
)
return
cache_key
,
content_hash
apps/openassessment/assessment/serializers/base.py
View file @
a076fd25
...
...
@@ -15,26 +15,6 @@ from openassessment.assessment.models import (
logger
=
logging
.
getLogger
(
__name__
)
# Current version of the models in the cache
# Increment this to ignore assessment models currently in the cache
# when model fields change.
CACHE_VERSION
=
1
def
_versioned_cache_key
(
key
):
"""
Add a version number to a cache key, so we
Args:
key (unicode): The original, unversioned, cache key.
Returns:
unicode: Cache key with the version appended.
"""
return
u"{}.v{}"
.
format
(
key
,
CACHE_VERSION
)
class
InvalidRubric
(
Exception
):
"""This can be raised during the deserialization process."""
def
__init__
(
self
,
errors
):
...
...
@@ -218,11 +198,9 @@ def full_assessment_dict(assessment, rubric_dict=None):
Returns:
dict with keys 'rubric' (serialized Rubric model) and 'parts' (serialized assessment parts)
"""
assessment_cache_key
=
_versioned_cache_key
(
"assessment.full_assessment_dict.{}.{}.{}"
.
format
(
assessment_cache_key
=
"assessment.full_assessment_dict.{}.{}.{}"
.
format
(
assessment
.
id
,
assessment
.
submission_uuid
,
assessment
.
scored_at
.
isoformat
()
)
)
assessment_dict
=
cache
.
get
(
assessment_cache_key
)
if
assessment_dict
:
return
assessment_dict
...
...
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