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

Update email constants for single release candidate #20170

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

kevintab95
Copy link
Member

Overview

  1. This PR fixes https://github.com/oppia/release-scripts/issues/133
  2. This PR does the following:
  • CAN_SEND_EMAILS is now a platform parameter. This will be switched on for the prod server and off for the other servers.
  • CAN_SEND_EDITOR_ROLE_EMAILS, CAN_SEND_FEEDBACK_MESSAGE_EMAILS and CAN_SEND_SUBSCRIPTION_EMAILS are replaced with CAN_SEND_TRANSACTIONAL_EMAILS.
  • DEFAULT_EMAIL_UPDATES_PREFERENCE is set to True in feconf.py and is not configurable per-server.
  • REQUIRE_EMAIL_ON_MODERATOR_ACTION is set to True and the constant is removed.

Essential Checklist

Please follow the instructions for making a code change.

  • I have linked the issue that this PR fixes in the "Development" section of the sidebar.
  • I have checked the "Files Changed" tab and confirmed that the changes are what I want to make.
  • I have written tests for my code.
  • The PR title starts with "Fix #bugnum: " or "Fix part of #bugnum: ...", followed by a short, clear summary of the changes.
  • I have assigned the correct reviewers to this PR (or will leave a comment with the phrase "@{{reviewer_username}} PTAL" if I can't assign them directly).

Testing doc (for PRs with Beam jobs that modify production server data)

  • A testing doc has been written: ... (ADD LINK) ...
  • (To be confirmed by the server admin) All jobs in this PR have been verified on a live server, and the PR is safe to merge.

Proof that changes are correct

can_send_emails

Proof of changes on desktop with slow/throttled network

Proof of changes on mobile phone

Proof of changes in Arabic language

PR Pointers

* CAN_SEND_EMAILS is now a platform parameter. This will
be switched on for the prod server and off for the
other servers.
* CAN_SEND_EDITOR_ROLE_EMAILS,
CAN_SEND_FEEDBACK_MESSAGE_EMAILS and
CAN_SEND_SUBSCRIPTION_EMAILS are replaced with
CAN_SEND_TRANSACTIONAL_EMAILS.
* DEFAULT_EMAIL_UPDATES_PREFERENCE is set to
True in feconf.py and is not configurable per-server.
* REQUIRE_EMAIL_ON_MODERATOR_ACTION is set to
True and the constant is removed.
@kevintab95 kevintab95 requested review from a team as code owners April 16, 2024 09:50
Copy link

oppiabot bot commented Apr 16, 2024

Hi @kevintab95, can you complete the following:

  1. The body of this PR is missing the proof that changes are correct section, please update it to include the section.
    Thanks!

Copy link

oppiabot bot commented Apr 16, 2024

Hi @vojtechjelinek, @DubeySandeep, @kevintab95, PTAL at this PR, it adds a new cron job.
Also @kevintab95 It seems you have added or edited a CRON job, if so please request a testing of this CRON job with this server jobs form Please refer to this guide for details.
Thanks!

@oppiabot oppiabot bot added the PR: Affects datastore layer Labels to indicate a PR that changes the datastore layer. label Apr 16, 2024
Copy link

oppiabot bot commented Apr 16, 2024

Hi @kevintab95 please assign the required reviewer(s) for this PR. Thanks!

@kevintab95
Copy link
Member Author

@oppia/release-coordinators please note that for the release containing these changes, the RC must ensure that the CAN_SEND_EMAILS platform parameter is set in production and unset on other servers. Thanks.

@kevintab95 kevintab95 changed the title Update email constants for single rc Update email constants for single release candidate Apr 16, 2024
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! Took a pass.

Comment on lines 248 to 253
self.swap_to_always_return(
platform_parameter_services,
'get_platform_parameter_value',
True
)
)
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
self.swap_to_always_return(
platform_parameter_services,
'get_platform_parameter_value',
True
)
)
self.swap_to_always_return(
platform_parameter_services,
'get_platform_parameter_value',
True
)
)

Copy link
Member

Choose a reason for hiding this comment

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

ditto below

Copy link
Member 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 389 to 390
if (can_send_emails and (
feconf.CAN_SEND_TRANSACTIONAL_EMAILS and
Copy link
Member

Choose a reason for hiding this comment

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

Can we also somehow cleanup this if at this point it is almost unreadable. At least something like this:

    # TODO(#12079): Figure out a better way to avoid sending feedback
    # thread emails for contributor dashboard suggestions.
    message_changed = len(text) > 0 or old_statuses[index] != new_statuses[index]
    if (
        can_send_emails and
        feconf.CAN_SEND_TRANSACTIONAL_EMAILS and
        author_id is not None and
        user_services.is_user_registered(author_id)) and
        message_changed and
        should_send_email
    ):

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Copy link

oppiabot bot commented Apr 16, 2024

Unassigning @vojtechjelinek since the review is done.

Copy link
Member Author

@kevintab95 kevintab95 left a comment

Choose a reason for hiding this comment

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

)
if (
server_can_send_emails and
(
Copy link
Member 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 485 to 488
) -> Callable[[Callable[
..., _GenericHandlerFunctionReturnType]],
Callable[..., _GenericHandlerFunctionReturnType]
]:
Copy link
Member 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 509 to 511
with swap_get_platform_parameter_value_function(
platform_parameter_name_value_tuples):
return func(*args, **kwargs)
Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

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.

Thanks @kevintab95! Couple small things, but looks pretty good for codeowners :)

Also @kevintab95 I think this needs a testing doc? It's trivial (set the param on) but we need a way to make sure this gets into the release instructions.

@@ -186,6 +187,9 @@ def test_trained_classifier_handler(self) -> None:
classifier_training_job.status,
feconf.TRAINING_JOB_STATUS_COMPLETE)

@test_utils.use_platform_parameters(
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 "set" is better than "use", since we are always using all platform params (just that, sometimes, they have their default values).

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

PlatformDataTypes. The value of the platform parameter if the
parameter is present in the platform_parameter_names list.
"""
platform_parameter_name_value_dict = dict(
Copy link
Member

Choose a reason for hiding this comment

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

What if a parameter that's retrieved is not specified in the given list of tuples?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added a check for this now. Done.

@seanlip seanlip assigned kevintab95 and unassigned seanlip May 28, 2024
Copy link
Sponsor Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

I have no concerns for the changes (for Android), and am otherwise deferring to @seanlip for Android & core owners approvals since he's already looking at the PR.

@BenHenning BenHenning removed their assignment May 28, 2024
Copy link
Member Author

@kevintab95 kevintab95 left a comment

Choose a reason for hiding this comment

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

PTAL @seanlip. Thanks!

@@ -186,6 +187,9 @@ def test_trained_classifier_handler(self) -> None:
classifier_training_job.status,
feconf.TRAINING_JOB_STATUS_COMPLETE)

@test_utils.use_platform_parameters(
Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

PlatformDataTypes. The value of the platform parameter if the
parameter is present in the platform_parameter_names list.
"""
platform_parameter_name_value_dict = dict(
Copy link
Member Author

Choose a reason for hiding this comment

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

I've added a check for this now. Done.

@kevintab95
Copy link
Member Author

Also @kevintab95 I think this needs a testing doc? It's trivial (set the param on) but we need a way to make sure this gets into the release instructions.

I've submitted a testing request for this.

@kevintab95 kevintab95 removed their assignment May 29, 2024
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 @kevintab95, I have no concerns re frontend changes.

@oppiabot oppiabot bot unassigned Nik-09 May 29, 2024
Copy link

oppiabot bot commented May 29, 2024

Unassigning @Nik-09 since they have already approved the PR.

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.

Thanks Kevin, a couple of follow-up comments!

@@ -453,10 +453,18 @@ def mock_get_platform_parameter_value(
Returns:
PlatformDataTypes. The value of the platform parameter if the
parameter is present in the platform_parameter_names list.

Raises:
Exception. If the parameter_name is not present in the
Copy link
Member

Choose a reason for hiding this comment

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

If the --> The

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

"""
platform_parameter_name_value_dict = dict(
(x.value, y) for x, y in platform_parameter_name_value_tuples
)
if parameter_name not in platform_parameter_name_value_dict:
raise Exception(
'Unknown platform parameter name: %s' % parameter_name
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this more explicit -- something like "The value for the platform parameter XYZ was needed in this test, but not specified in the XXX decorator. Please add a XXX decorator with this information."

Also just to confirm -- if a backend test uses a platform parameter (directly or indirectly), then they must specify its value, is that correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Regarding the second question, this is true if the test uses the decorator i.e. if a test uses the decorator, it will need to exhaustively define all the platform parameter that it requires or it will throw the error above. There may still be tests that rely on calling the actual procedure (not mocking) and/or there may be other tests that mocks the method a different way (e.g. always return xxx).

Copy link
Member

@seanlip seanlip May 31, 2024

Choose a reason for hiding this comment

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

Thanks @kevintab95, sg. One question though -- have we modified all the tests that rely on calling the actual procedure / mock the method a different way to use the new decorator instead? I think that's important because, otherwise, devs will simply copy those old tests if it's the first example they see.

Copy link
Member Author

Choose a reason for hiding this comment

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

The way I went about these changes were to find out places where the email related platform parameter is used and then modify those tests to use the decorator instead. I do see around 24 places in the test files where platform_parameter_services.get_platform_parameter_value is mocked without the decorator e.g.

def test_custom_high_bounce_rate_obsoletion_threshold(self) -> None:
swap_get_platform_parameter_value = self.swap_to_always_return(
platform_parameter_services,
'get_platform_parameter_value',
0.05
)

Can this be fixed in a separate PR as it seems out of scope for the current one?

Copy link
Member Author

Choose a reason for hiding this comment

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

Update: Per offline discussion, I will be handling these cases in the same PR.

@seanlip seanlip assigned kevintab95 and unassigned seanlip May 29, 2024
Copy link
Member Author

@kevintab95 kevintab95 left a comment

Choose a reason for hiding this comment

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

PTAL @seanlip, thanks!

@@ -453,10 +453,18 @@ def mock_get_platform_parameter_value(
Returns:
PlatformDataTypes. The value of the platform parameter if the
parameter is present in the platform_parameter_names list.

Raises:
Exception. If the parameter_name is not present in the
Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

"""
platform_parameter_name_value_dict = dict(
(x.value, y) for x, y in platform_parameter_name_value_tuples
)
if parameter_name not in platform_parameter_name_value_dict:
raise Exception(
'Unknown platform parameter name: %s' % parameter_name
Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Regarding the second question, this is true if the test uses the decorator i.e. if a test uses the decorator, it will need to exhaustively define all the platform parameter that it requires or it will throw the error above. There may still be tests that rely on calling the actual procedure (not mocking) and/or there may be other tests that mocks the method a different way (e.g. always return xxx).

@kevintab95 kevintab95 assigned seanlip and kevintab95 and unassigned kevintab95 and seanlip May 31, 2024
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.

LGTM!

Copy link

oppiabot bot commented May 31, 2024

Unassigning @vojtechjelinek since they have already approved the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Affects datastore layer Labels to indicate a PR that changes the datastore layer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants