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 #14698: Add ability to generate X sample translation opportunities on local dev server #14889

Closed
wants to merge 37 commits into from

Conversation

jimbyo
Copy link
Contributor

@jimbyo jimbyo commented Feb 9, 2022

Overview

  1. This PR adds a generate translation opportunities button in the admin.py
  2. You can select the number of opportunities and number of interactions in each opportunity to generate

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

Video

  1. Creates 10 opportunities with 10 interactions
  2. Checks Contributor dashboard
  3. Creates 10 opportunities with 1 interaciton
  4. Checks Contributor dashboard
Screen.Recording.2022-02-15.at.4.22.51.PM.mov

Video 2

  1. Creates 1 opportunities with 1 interactions without checked submit suggestions.
  2. Checks Contributor dashboard
  3. Creates 1 opportunities with 1 interactions with checked submit suggestion.
  4. Checks Contributor dashboard noticing 4 submitted suggestions
  5. Creates 5 opportunities with 5 interactions with checked submit suggestion.
  6. Checks Contributor dashboard noticing 104 submitted suggestions
Screen.Recording.2022-02-23.at.6.00.45.PM.mov

@oppiabot
Copy link

oppiabot bot commented Feb 9, 2022

Hi @jimbyo, can you complete the following:

  1. The body of this PR is missing the required description, please update the body with a description of what this PR does.
  2. The karma and linter checklist has not been checked, please make sure to run the frontend tests and lint tests before pushing.
  3. The proof that changes are correct has not been provided, please make sure to upload a image/video showing that the changes are correct. Or include a sentence saying "No proof of changes needed because" and the reason why proof of changes cannot be provided.
    Thanks!

@oppiabot
Copy link

oppiabot bot commented Feb 9, 2022

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

@oppiabot
Copy link

oppiabot bot commented Feb 9, 2022

Hi @jimbyo. 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!

@jimbyo
Copy link
Contributor Author

jimbyo commented Feb 9, 2022

Closing for now because of bugs when generating opportunities multiple times

@jimbyo jimbyo closed this Feb 9, 2022
@jimbyo jimbyo reopened this Feb 16, 2022
@oppiabot
Copy link

oppiabot bot commented Feb 16, 2022

Hi @jimbyo, can you complete the following:

  1. The karma and linter checklist has not been checked, please make sure to run the frontend tests and lint tests before pushing.
  2. The proof that changes are correct has not been provided, please make sure to upload a image/video showing that the changes are correct. Or include a sentence saying "No proof of changes needed because" and the reason why proof of changes cannot be provided.
    Thanks!

@oppiabot
Copy link

oppiabot bot commented Mar 2, 2022

Hi @jimbyo, it looks like some changes were requested on this pull request by @sagangwee. PTAL. Thanks!

@oppiabot oppiabot bot assigned jimbyo Mar 2, 2022
@oppiabot
Copy link

oppiabot bot commented Mar 9, 2022

Hi @jimbyo, 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 PR: don't merge - STALE BUILD The build on this PR is stale and should be restarted. labels Mar 9, 2022
@oppiabot
Copy link

oppiabot bot commented Mar 9, 2022

Hi @jimbyo, 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 closed this Mar 13, 2022
@jimbyo jimbyo reopened this Mar 20, 2022
@oppiabot oppiabot bot removed the stale label Mar 20, 2022
@oppiabot oppiabot bot removed the PR: don't merge - STALE BUILD The build on this PR is stale and should be restarted. label Mar 21, 2022
Copy link
Contributor Author

@jimbyo jimbyo left a comment

Choose a reason for hiding this comment

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

Took another pass! PTAL! @sagangwee

elif action == 'generate_sample_opportunities':
num_sample_ops = self.normalized_payload.get(
'num_sample_ops')
num_sample_interactions = self.normalized_payload.get(
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

Args:
num_sample_ops: int. Count of sample opportunities to
be generated.
num_sample_interactions: int. Count of sample
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

be generated.
num_sample_interactions: int. Count of sample
interactions to be generated.
should_submit_suggestions: boolean. Boolean to track
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

should_submit_suggestions: boolean. Boolean to track
whether suggestions should be submitted.
"""
topic_id_1 = topic_fetchers.get_new_topic_id()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to topic id and also changed topic_1 to topic

story_id, exp_ids_in_story)

if should_submit_suggestions:
for i in range(num_sample_ops):
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. Changed i to opportunity_num and j to interaction num

new_exploration_id, title=title, category=category,
objective='Dummy Objective')

for interaction_num in range(num_sample_interactions):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

created helper

objective='Dummy Objective')

for interaction_num in range(num_sample_interactions):
if interaction_num == num_sample_interactions - 1:
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!

Also quick question. When should we have helper functions inside a function and outside a function

core/controllers/admin.py Show resolved Hide resolved
len_story = len(story_node_dicts)
for i, story_node_dict in enumerate(story_node_dicts):
self._generate_sample_story_nodes(
story, len_story, i + 1, **story_node_dict)
Copy link
Contributor Author

@jimbyo jimbyo Mar 20, 2022

Choose a reason for hiding this comment

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

story node ids start at one not zero, when they start at zero the code fails. I have changed enumerate(story_node_dicts) to enumerate(story_node_dicts, 1) to make this more clear than the previous i + 1

"""

story.add_node(
'%s%d' % (story_domain.NODE_ID_PREFIX, node_id),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry what are you talking being duplicated? This portion?
'%s%d' % (story_domain.NODE_ID_PREFIX, node_id)

@jimbyo jimbyo assigned sagangwee and unassigned jimbyo Mar 21, 2022
@oppiabot oppiabot bot added the PR: don't merge - STALE BUILD The build on this PR is stale and should be restarted. label Mar 23, 2022
@oppiabot
Copy link

oppiabot bot commented Mar 23, 2022

Hi @jimbyo, 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
Contributor

@sagangwee sagangwee left a comment

Choose a reason for hiding this comment

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

@jimbyo Sorry for the delay! Took a pass. Thanks.

Track whether suggestions should be submitted.

Raises:
Exception. Environment is not DEVMODE.
Copy link
Contributor

Choose a reason for hiding this comment

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

DEV_MODE*

num_sample_interactions_per_opportunity: int. Number of sample
interactions to generate per opportunity.
should_submit_suggestions: boolean.
Track whether suggestions should be submitted.
Copy link
Contributor

Choose a reason for hiding this comment

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

Cam omit "Track"

num_sample_interactions_per_opportunity,
should_submit_suggestions)

def _generate_sample_opportunities_without_existing_topic(
Copy link
Contributor

Choose a reason for hiding this comment

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

Generally order functions in the order that they're used, so this should be below _generate_sample_opportunities_with_existing_topic.

self, num_sample_ops,
num_sample_interactions_per_opportunity,
should_submit_suggestions):
"""Generates a topic and story and creates
Copy link
Contributor

Choose a reason for hiding this comment

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

Bring some of the sentence to this line up to the line limit?

interactions to generate per opportunity.
should_submit_suggestions: boolean.
Track whether suggestions should be submitted.
story_url_fragment: stringType. Story fragment of existing story.
Copy link
Contributor

Choose a reason for hiding this comment

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

*string ?

Also, what does "Story fragment of existing story" mean? The description should something like "The url fragment of the story." right? And if the story_url_fragment is always set to 'sample-story-title', then it doesn't seem like this arg is necessary.

have been generated.
num_sample_interactions_per_opportunity: int. Number of sample
interactions that have been generated.
exp_ids_in_story: list. List of the exploration ids of explorations
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Since we specify the "list" type already, we can just omit the "List of" part of the description. Here and below.

Comment on lines +944 to +945
title = random.choice(possible_titles) + ' ' + str(
opportunity_num + num_chapters)
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer using string interpolation instead of concatenation here (easier to read).


for interaction_num in range(num_sample_interactions_per_opportunity):
if is_last_interaction():
dest = 'End'
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: destination and current_state seem short enough to not abbreviate.

Comment on lines +1014 to +1015
"""Populates a sample interaction
and links to a destination interaction.
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix line limit here as well.

"""

story.add_node(
'%s%d' % (story_domain.NODE_ID_PREFIX, node_id),
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. It would read better if we stored that portion to a variable, e.g. node_name.

@oppiabot
Copy link

oppiabot bot commented Mar 24, 2022

Unassigning @sagangwee since the review is done.

@oppiabot
Copy link

oppiabot bot commented Mar 24, 2022

Hi @jimbyo, it looks like some changes were requested on this pull request by @sagangwee. PTAL. Thanks!

@oppiabot
Copy link

oppiabot bot commented Mar 25, 2022

Hi @jimbyo, there is a new change in develop which needs to be in your PR. Please update your branch with the latest changes in develop. For instructions, refer to this link. Thanks!

@oppiabot
Copy link

oppiabot bot commented Apr 1, 2022

Hi @jimbyo, 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 Apr 1, 2022
@oppiabot oppiabot bot closed this Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: don't merge - STALE BUILD The build on this PR is stale and should be restarted. stale
Projects
None yet
5 participants