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 #13162: Add schema and introduce new approach for saving multiple images in suggestion handler. #14063

Merged
merged 186 commits into from Dec 15, 2021
Merged

Fix #13162: Add schema and introduce new approach for saving multiple images in suggestion handler. #14063

merged 186 commits into from Dec 15, 2021

Conversation

chiragbaid7
Copy link
Contributor

@chiragbaid7 chiragbaid7 commented Oct 14, 2021

Overview

  1. This PR fixes or fixes part of Write schemas for handler class arguments #13162.
  2. This PR adds schema validation for suggestion handler.
  3. This PR introduces new approach for handling images for suggestion translation.

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

suggestion-handler.mp4
Suggestion.images.mp4
Translate.images.suggestion.mp4

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 Oct 14, 2021

Hi @DubeySandeep, could you please add the appropriate changelog label to this pull request? 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.

@chiragbaid7 Left one question for clarification.
Thank you

core/controllers/domain_objects_validator.py Show resolved Hide resolved
@Nik-09 Nik-09 assigned chiragbaid7 and unassigned Nik-09 Oct 16, 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! the overall design looks good. Left a few comments.

from core.domain import state_domain

from typing import Dict, Optional, Union


def validate_change(obj):
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
def validate_change(obj):
def validate_exploration_or_question_change(obj):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

from core.domain import state_domain

from typing import Dict, Optional, Union


def validate_change(obj):
"""Validates Exploration and Question domain change.
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
"""Validates Exploration and Question domain change.
"""Validates Exploration or Question change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 45 to 47
exp_domain.ExplorationChange(obj)
elif obj['cmd'] in feconf.LIST_CMD_QUESTION_CHANGE:
question_domain.QuestionSuggestionChange(obj)
Copy link
Member

Choose a reason for hiding this comment

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

Should we call validate explicitly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you talking about validation method in the schema for change param?

Copy link
Member

Choose a reason for hiding this comment

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

Nevermind. Can you just add a comment that the change is validated when the object is created?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 64 to 65
'target_version_at_submission':
{
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
'target_version_at_submission':
{
'target_version_at_submission': {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

core/controllers/suggestion.py Show resolved Hide resolved
Comment on lines 106 to 107
except utils.ValidationError as e:
raise self.InvalidInputException(e)
Copy link
Member

Choose a reason for hiding this comment

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

Can this still happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this can be removed as validation is being performed,

core/feconf.py Outdated
Comment on lines 1482 to 1496
# Constants defining various domain commands.
CMD_ADD_WRITTEN_TRANSLATION = 'add_written_translation'
CMD_EDIT_STATE_PROPERTY = 'edit_state_property'
CMD_CREATE_NEW_FULLY_SPECIFIED_QUESTION = 'create_new_fully_specified_question'

# Possible allowed commands for exploration change.
LIST_CMD_EXPLORATION_CHANGE = [
CMD_ADD_WRITTEN_TRANSLATION,
CMD_EDIT_STATE_PROPERTY
]

# Possible allowed commands for question change.
LIST_CMD_QUESTION_CHANGE = [
CMD_CREATE_NEW_FULLY_SPECIFIED_QUESTION
]
Copy link
Member

Choose a reason for hiding this comment

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

Why are we redefining these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The above constants are to check which domain the passed change object's parameter cmd belongs,
The object value cmd is then compared with possibles commands in the list and then corresponding domain object is called accordingly.

 if obj['cmd'] in feconf.LIST_CMD_EXPLORATION_CHANGE:
        exp_domain.ExplorationChange(obj)

 elif obj['cmd'] in feconf.LIST_CMD_QUESTION_CHANGE:
        question_domain.QuestionSuggestionChange(obj)

https://github.com/chiragbaid7/oppia/blob/a18acf4a359546845c107093bb9change717f818a9d978/core/controllers/domain_objects_validator.py#L44

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, but these commands are already defined in another file, we shouldn't redefine them, we should import them one way or the other.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I have created a list of possible allowed commands in question_domain and exp_domain and removed the redefined constants from feconf.

@seanlip seanlip assigned chiragbaid7 and unassigned seanlip Dec 10, 2021
@chiragbaid7
Copy link
Contributor Author

PTAL @seanlip

@oppiabot oppiabot bot assigned seanlip and unassigned chiragbaid7 Dec 10, 2021
@oppiabot
Copy link

oppiabot bot commented Dec 10, 2021

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

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

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

LGTM for my codeowner file. Thanks @chiragbaid7!

@seanlip seanlip removed their assignment Dec 11, 2021
@seanlip
Copy link
Member

seanlip commented Dec 11, 2021

@DubeySandeep PTAL

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

oppiabot bot commented Dec 13, 2021

Hi @chiragbaid7, 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 removed the PR: don't merge - STALE BUILD The build on this PR is stale and should be restarted. label Dec 13, 2021
Copy link
Member

@DubeySandeep DubeySandeep left a comment

Choose a reason for hiding this comment

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

LGTM for the changes in core/domain/image_validation_services.py

@oppiabot
Copy link

oppiabot bot commented Dec 13, 2021

Unassigning @DubeySandeep since they have already approved the PR.

@vojtechjelinek vojtechjelinek enabled auto-merge (squash) December 15, 2021 09:43
@vojtechjelinek vojtechjelinek self-assigned this Dec 15, 2021
@vojtechjelinek vojtechjelinek merged commit e400be5 into oppia:develop Dec 15, 2021
@chiragbaid7 chiragbaid7 deleted the add-schema-suggestion-handler branch December 17, 2021 14:03
vojtechjelinek added a commit to vojtechjelinek/oppia that referenced this pull request Dec 21, 2021
…ving multiple images in suggestion handler. (oppia#14063)"

This reverts commit e400be5.
@seanlip
Copy link
Member

seanlip commented Mar 10, 2022

Heads-up -- it looks like this PR inadvertently broke a key workflow in the contributor dashboard. See #15101.

@chiragbaid7 @vojtechjelinek would it be possible to make a fix quickly? We will need to hotfix this.

Thanks!

/cc @sagangwee @kevintab95

@vojtechjelinek
Copy link
Member

@chiragbaid7 Is working on the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants