-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Conversation
Hi @vojtechjelinek, @aks681 -- could one of you please add the appropriate changelog label to this pull request? Thanks! |
@aks681 @vojtechjelinek Please review my PR and tell me what changes are needed. 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/reader.py
Outdated
}, | ||
'state_name': { | ||
'schema': { | ||
'type': schema_utils.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.
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).
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.
done.
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 have replaced those constants. Please tell me If it needs any other changes.
core/controllers/reader.py
Outdated
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')) |
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.
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')) |
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.
done
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 let me know if I missed any changes here.
core/controllers/reader.py
Outdated
'params': { | ||
'schema': { | ||
'type': 'object_dict', | ||
'validation_method': ( | ||
domain_objects_validator.validate_params), | ||
} | ||
} |
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 are the params send like this?
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.
Can some more structured manner be 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.
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 PTAL. Thanks : ) |
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! |
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! |
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.
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) |
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 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
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.
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
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 think you can ignore this and leave it for now
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.
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.
LGTM!
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.
Lgtm as codeowner
Unassigning @aks681 since they have already approved the PR. |
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! |
Thanks, @aks681 @vojtechjelinek : ) |
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.
@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) |
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 think you can ignore this and leave it for now
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! |
Done. |
Overview
Essential Checklist
Proof that changes are correct
PR Pointers