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: Add argument schema for ExplorationCompleteEventHandler, ExplorationMaybeLeaveHandler, SolutionHitEventHandler classes #14208

Merged
merged 35 commits into from
Dec 3, 2021

Conversation

SD-13
Copy link
Collaborator

@SD-13 SD-13 commented Nov 9, 2021

Overview

  1. This PR fixes or fixes part of Write schemas for handler class arguments #13162.
  2. This PR does the following: This PR adds schema for ExplorationCompleteEventHandler, ExplorationMaybeLeaveHandler, SolutionHitEventHandler classes.

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

Screenshot from 2021-11-09 13-22-55

Screenshot from 2021-11-09 12-18-25
Screenshot from 2021-11-09 12-17-45
Screenshot from 2021-11-09 12-17-54

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 Nov 9, 2021

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

@SD-13
Copy link
Collaborator Author

SD-13 commented Nov 9, 2021

@aks681 @vojtechjelinek Please review my PR and tell me what changes are needed. Thanks

Copy link
Contributor

@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.

},
'state_name': {
'schema': {
'type': schema_utils.SCHEMA_TYPE_BASESTRING
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we usually do not use constants for these simple strings (we do not use them in schemas, in other parts of the codebase we use them).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have replaced those constants. Please tell me If it needs any other changes.

Comment on lines 647 to 650
exploration_id, self.normalized_payload.get('exploration_version'),
self.normalized_payload.get('state_name'),
self.normalized_payload.get('session_id'),
self.normalized_payload.get('time_spent_in_state_secs'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
exploration_id, self.normalized_payload.get('exploration_version'),
self.normalized_payload.get('state_name'),
self.normalized_payload.get('session_id'),
self.normalized_payload.get('time_spent_in_state_secs'))
exploration_id,
self.normalized_payload.get('exploration_version'),
self.normalized_payload.get('state_name'),
self.normalized_payload.get('session_id'),
self.normalized_payload.get('time_spent_in_state_secs'))

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please let me know if I missed any changes here.

Comment on lines 691 to 697
'params': {
'schema': {
'type': 'object_dict',
'validation_method': (
domain_objects_validator.validate_params),
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are the params send like this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can some more structured manner be used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think here I picked the wrong type. Later I found params arg in the domain layer and I have updated the schema accordingly. Please have a look and let me know if any changes are needed.

@vojtechjelinek vojtechjelinek assigned SD-13 and unassigned vojtechjelinek and aks681 Nov 10, 2021
@SD-13
Copy link
Collaborator Author

SD-13 commented Nov 12, 2021

@vojtechjelinek PTAL. Thanks : )

@oppiabot oppiabot bot assigned vojtechjelinek and unassigned SD-13 Nov 12, 2021
@oppiabot
Copy link

oppiabot bot commented Nov 12, 2021

Unassigning @SD-13 since a re-review was requested. @SD-13, please make sure you have addressed all review comments. Thanks!

@oppiabot
Copy link

oppiabot bot commented Nov 14, 2021

Hi @SD-13, 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 Dec 1, 2021

Hi @SD-13, 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!

Copy link
Member

@Nik-09 Nik-09 left a comment

Choose a reason for hiding this comment

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

Thank you @SD-13, added one comment.

params: dict. Data that needs to be validated.
"""
if not isinstance(params, dict):
raise Exception('Excepted dict, received %s' % params)
Copy link
Member

Choose a reason for hiding this comment

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

I was asking to add a validation inorder to expect the type of the params to be dict, as you have done here.
Also verify that the keys in params dict are of string type.

Also can you modify the type annotation here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I found in many places that it is taking string-type keys.
previously I tried to add rules for both keys and values individually and that was causing lots of e2e failures and it seemed like they were transformed into string types before passing into the validator.
Also, I did not find anything that violates them. then what did you ask me to modify? Can you please explain

Copy link
Member

Choose a reason for hiding this comment

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

I think you can ignore this and leave it for now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay.

@Nik-09 Nik-09 assigned SD-13 and unassigned Nik-09 Dec 2, 2021
Copy link
Contributor

@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.

LGTM!

@SD-13 SD-13 removed their assignment Dec 2, 2021
Copy link
Contributor

@aks681 aks681 left a comment

Choose a reason for hiding this comment

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

Lgtm as codeowner

@oppiabot oppiabot bot unassigned aks681 Dec 3, 2021
@oppiabot
Copy link

oppiabot bot commented Dec 3, 2021

Unassigning @aks681 since they have already approved the PR.

@oppiabot oppiabot bot added the PR: LGTM label Dec 3, 2021
@oppiabot
Copy link

oppiabot bot commented Dec 3, 2021

Hi @vojtechjelinek, this PR is ready to be merged. Author of this PR does not have permissions to merge this PR. Before you merge it, please make sure that there are no pending comments that require action from the author's end. Thanks!

@SD-13
Copy link
Collaborator Author

SD-13 commented Dec 3, 2021

Thanks, @aks681 @vojtechjelinek : )

Copy link
Member

@Nik-09 Nik-09 left a comment

Choose a reason for hiding this comment

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

@SD-13 Update the PR with upstream.

params: dict. Data that needs to be validated.
"""
if not isinstance(params, dict):
raise Exception('Excepted dict, received %s' % params)
Copy link
Member

Choose a reason for hiding this comment

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

I think you can ignore this and leave it for now

@Nik-09 Nik-09 enabled auto-merge (squash) December 3, 2021 13:55
@oppiabot
Copy link

oppiabot bot commented Dec 3, 2021

Hi @vojtechjelinek, this PR is ready to be merged. Author of this PR does not have permissions to merge this PR. Before you merge it, please make sure that there are no pending comments that require action from the author's end. Thanks!

@SD-13
Copy link
Collaborator Author

SD-13 commented Dec 3, 2021

@SD-13 Update the PR with upstream.

Done.

@Nik-09 Nik-09 merged commit dd898b9 into oppia:develop Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants