Skip to content
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

Closed
wants to merge 6 commits into from

Conversation

davisong
Copy link

@davisong davisong commented Dec 9, 2021

Overview

  1. This PR fixes or fixes part of Write schemas for handler class arguments #13162.
  2. This PR does the following:

Adds schema for handler class argument SkillMasteryDataHandler

Essential Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The linter/Karma presubmit checks have passed locally on your machine.
  • "Allow edits from maintainers" is checked. (See here for instructions on how to enable it.)
    • This lets reviewers restart your CircleCI tests for you.
  • The PR is made from a branch that's not called "develop".

Proof that changes are correct

2021-12-09.14-43-15.mp4

Screenshot 2021-12-09 143157

PR Pointers

  • Make sure to follow the instructions for making a code change.
  • Oppiabot will notify you when you don't add a PR_CHANGELOG label. If you are unable to do so, please @-mention a code owner (who will be in the Reviewers list), or ask on Gitter.
  • For what code owners will expect, see the Code Owner's wiki page.
  • Make sure your PR follows conventions in the style guide, otherwise this will lead to review delays.
  • Never force push. If you do, your PR will be closed.
  • Oppiabot can assign anyone for review/help if you leave a comment like the following: "{{Question/comment}} @{{reviewer_username}} PTAL"
  • Some of the e2e tests are flaky, and can fail for reasons unrelated to your PR. We are working on fixing this, but in the meantime, if you need to restart the tests, please check the "If your build fails" wiki page.

@oppiabot
Copy link

oppiabot bot commented Dec 9, 2021

Hi @vojtechjelinek, @aks681 -- could one of you please add the appropriate changelog label to this pull request? Thanks!

@oppiabot
Copy link

oppiabot bot commented Dec 9, 2021

Hi @davisong. Due to recent changes in the "develop" branch, this PR now has a merge conflict. Please follow this link if you need help resolving the conflict, so that the PR can be merged. Thanks!

@oppiabot
Copy link

oppiabot bot commented Dec 12, 2021

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!

@oppiabot oppiabot bot added the PR: don't merge - STALE BUILD The build on this PR is stale and should be restarted. label Dec 12, 2021
Copy link
Member

@vojtechjelinek vojtechjelinek left a 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.

Comment on lines 50 to 51
'validation_method': (
domain_objects_validator.validate_params_dict)
Copy link
Member

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?

Copy link
Author

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.

Copy link
Author

@davisong davisong Dec 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vojtechjelinek PTAL

Copy link
Member

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

Copy link
Author

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

Copy link
Member

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.

@oppiabot
Copy link

oppiabot bot commented Dec 12, 2021

Unassigning @vojtechjelinek since the review is done.

@oppiabot
Copy link

oppiabot bot commented Dec 29, 2021

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.
If you are still working on this PR, please make a follow-up commit within 4 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you!

@oppiabot oppiabot bot added stale and removed stale labels Dec 29, 2021
@oppiabot oppiabot bot removed the PR: don't merge - STALE BUILD The build on this PR is stale and should be restarted. label Jan 3, 2022
}
}
},
'PUT': {
Copy link
Member

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?

Copy link
Member

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.

@aks681 aks681 assigned vojtechjelinek and unassigned aks681 Jan 4, 2022
Copy link
Member

@vojtechjelinek vojtechjelinek left a 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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (skill_id, mastery) in mastery_change_per_skill:
for skill_id, mastery in mastery_change_per_skill:

}
}
},
'PUT': {
Copy link
Member

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.

Comment on lines +40 to +44
'comma_separated_exp_ids': {
'schema': {
'type': 'basestring'
}
}
Copy link
Member

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.

@oppiabot
Copy link

oppiabot bot commented Jan 5, 2022

Unassigning @vojtechjelinek since the review is done.

@oppiabot oppiabot bot added the PR: don't merge - STALE BUILD The build on this PR is stale and should be restarted. label Jan 6, 2022
@oppiabot
Copy link

oppiabot bot commented Jan 6, 2022

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!

@oppiabot
Copy link

oppiabot bot commented Jan 13, 2022

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.
If you are still working on this PR, please make a follow-up commit within 4 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you!

@oppiabot oppiabot bot added the stale label Jan 13, 2022
@oppiabot oppiabot bot closed this Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: don't merge - HAS MERGE CONFLICTS PR: don't merge - STALE BUILD The build on this PR is stale and should be restarted. stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants