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
58e9384c
Commit
58e9384c
authored
Jun 04, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #401 from edx/will/remove-cache-key-version
Remove cache key versioning
parents
2cb7cae6
a076fd25
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
33 deletions
+5
-33
apps/openassessment/assessment/models/training.py
+3
-9
apps/openassessment/assessment/serializers/base.py
+2
-24
No files found.
apps/openassessment/assessment/models/training.py
View file @
58e9384c
...
@@ -23,10 +23,6 @@ class TrainingExample(models.Model):
...
@@ -23,10 +23,6 @@ class TrainingExample(models.Model):
# SHA1 hash
# SHA1 hash
content_hash
=
models
.
CharField
(
max_length
=
40
,
unique
=
True
,
db_index
=
True
)
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
:
class
Meta
:
app_label
=
"assessment"
app_label
=
"assessment"
...
@@ -102,12 +98,11 @@ class TrainingExample(models.Model):
...
@@ -102,12 +98,11 @@ class TrainingExample(models.Model):
"""
"""
if
attribute
is
None
:
if
attribute
is
None
:
key_template
=
u"TrainingExample.json.
v{version}.
{content_hash}"
key_template
=
u"TrainingExample.json.{content_hash}"
else
:
else
:
key_template
=
u"TrainingExample.{attribute}.json.
v{version}.
{content_hash}"
key_template
=
u"TrainingExample.{attribute}.json.{content_hash}"
cache_key
=
key_template
.
format
(
cache_key
=
key_template
.
format
(
version
=
self
.
CACHE_KEY_VERSION
,
content_hash
=
self
.
content_hash
,
content_hash
=
self
.
content_hash
,
attribute
=
attribute
attribute
=
attribute
)
)
...
@@ -149,8 +144,7 @@ class TrainingExample(models.Model):
...
@@ -149,8 +144,7 @@ class TrainingExample(models.Model):
"""
"""
content_hash
=
cls
.
calculate_hash
(
answer
,
options_selected
,
rubric
)
content_hash
=
cls
.
calculate_hash
(
answer
,
options_selected
,
rubric
)
cache_key
=
u"TrainingExample.model.v{version}.{content_hash}"
.
format
(
cache_key
=
u"TrainingExample.model.{content_hash}"
.
format
(
version
=
cls
.
CACHE_KEY_VERSION
,
content_hash
=
content_hash
content_hash
=
content_hash
)
)
return
cache_key
,
content_hash
return
cache_key
,
content_hash
apps/openassessment/assessment/serializers/base.py
View file @
58e9384c
...
@@ -15,26 +15,6 @@ from openassessment.assessment.models import (
...
@@ -15,26 +15,6 @@ from openassessment.assessment.models import (
logger
=
logging
.
getLogger
(
__name__
)
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
):
class
InvalidRubric
(
Exception
):
"""This can be raised during the deserialization process."""
"""This can be raised during the deserialization process."""
def
__init__
(
self
,
errors
):
def
__init__
(
self
,
errors
):
...
@@ -218,10 +198,8 @@ def full_assessment_dict(assessment, rubric_dict=None):
...
@@ -218,10 +198,8 @@ def full_assessment_dict(assessment, rubric_dict=None):
Returns:
Returns:
dict with keys 'rubric' (serialized Rubric model) and 'parts' (serialized assessment parts)
dict with keys 'rubric' (serialized Rubric model) and 'parts' (serialized assessment parts)
"""
"""
assessment_cache_key
=
_versioned_cache_key
(
assessment_cache_key
=
"assessment.full_assessment_dict.{}.{}.{}"
.
format
(
"assessment.full_assessment_dict.{}.{}.{}"
.
format
(
assessment
.
id
,
assessment
.
submission_uuid
,
assessment
.
scored_at
.
isoformat
()
assessment
.
id
,
assessment
.
submission_uuid
,
assessment
.
scored_at
.
isoformat
()
)
)
)
assessment_dict
=
cache
.
get
(
assessment_cache_key
)
assessment_dict
=
cache
.
get
(
assessment_cache_key
)
if
assessment_dict
:
if
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