New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix part of #13162: added schemas for SkillMasteryDataHandler #14395
Conversation
Hi @vojtechjelinek, @aks681 -- could one of you please add the appropriate changelog label to this pull request? Thanks! |
Hi @davisong, the build of this PR is stale and this could result in tests failing in develop. Please update this pull request with the latest changes from develop. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Left a few comments.
core/controllers/skill_mastery.py
Outdated
'validation_method': ( | ||
domain_objects_validator.validate_params_dict) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this schema used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mastery_change_per_skill
is stored as a dictionary of multiple key value pairs, each one representing a different skill and the corresponding degree of mastery. I was unable to find a domain object for that schema so I resorted to using validate_params_dict
as a general method of validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vojtechjelinek PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that makes sense, you should properly validate all the files of this dictionary. validate_params_dict
is used in a case where we don't know the structure at all, but here we should be able to understand the structure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the structure but I'm very confused on how to validate it under the current schema definition. dict
requires static keys to define a name
and associated schema value, but mastery_change_per_skill
could potentially be any skill_id
.
@vojtechjelinek PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, then you might need to write a validator that will take a dict where keys need to have skill ID format and values follow some given format.
Unassigning @vojtechjelinek since the review is done. |
Hi @davisong, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 4 days, it will be automatically closed so that others can take up the issue. |
} | ||
} | ||
}, | ||
'PUT': { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vojtechjelinek Shouldn't def put
use self.normalized_payload
? Also, is there a corresponding normalized_request
for get
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, use self.normalized_payload
instead of self.payload
everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Left a few comments.
Returns: | ||
dict(str, float). Returns mastery_change_per_skill after validation. | ||
""" | ||
for (skill_id, mastery) in mastery_change_per_skill: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (skill_id, mastery) in mastery_change_per_skill: | |
for skill_id, mastery in mastery_change_per_skill: |
} | ||
} | ||
}, | ||
'PUT': { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, use self.normalized_payload
instead of self.payload
everywhere.
'comma_separated_exp_ids': { | ||
'schema': { | ||
'type': 'basestring' | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refactor this to use JsonEncodedInString
see other places to understand how it works.
Unassigning @vojtechjelinek since the review is done. |
Hi @davisong, the build of this PR is stale and this could result in tests failing in develop. Please update this pull request with the latest changes from develop. Thanks! |
Hi @davisong, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 4 days, it will be automatically closed so that others can take up the issue. |
Overview
Adds schema for handler class argument
SkillMasteryDataHandler
Essential Checklist
Proof that changes are correct
2021-12-09.14-43-15.mp4
PR Pointers