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

Change growth threshold algorithm do use percentage points increase #22875

Merged
merged 3 commits into from
Nov 25, 2024

Conversation

diox
Copy link
Member

@diox diox commented Nov 21, 2024

Also contains a refactor to make the code easier to test, as well as admin & reviewer tools tweaks to make the consequences of changing that threshold more obvious.

If the average hotness in a tier is 0.1, and the growth threshold is set to 50, we used to flag add-ons in that tier with hotness over 0.15 (percentage increase) now we'll flag over 0.51 (percentage points increase).

Fixes mozilla/addons#15178

Screenshots

New admin features:
Screenshot 2024-11-21 at 14-45-47 low Change usage tier Django site admin

Testing

You can add addons with various hotness and average_daily_users values to your local environment to test and trigger flag_high_hotness_according_to_review_tier task (if the add-on is flagged, it should get a NeedsHumanReview instance with HOTNESS_THRESHOLD reason attached to the latest signed version in each channel that hasn't already been explicitly reviewed by a human), or trust the unit tests that do that.

Also contains a refactor to make the code easier to test, as well as
admin & reviewer tools tweaks to make the consequences of changing that
threshold more obvious.

If the average hotness in a tier is 0.1, and the growth threshold is set to 50,
we used to flag add-ons in that tier with hotness over 0.15 (percentage increase)
now we'll flag over 0.51 (percentage points increase).
@diox diox force-pushed the growth-threshold-percentage-points-increase branch from a07420e to 75689b9 Compare November 21, 2024 11:26
@diox diox requested review from a team and KevinMind and removed request for a team November 21, 2024 12:02
Copy link
Contributor

@KevinMind KevinMind left a comment

Choose a reason for hiding this comment

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

Looks good in principle.. I have a slight doubt/question about the algo change.

src/olympia/addons/tasks.py Show resolved Hide resolved
src/olympia/reviewers/models.py Show resolved Hide resolved
src/olympia/addons/tasks.py Show resolved Hide resolved
The value is computed from the average growth (hotness) of add-ons in
that tier plus the growth_threshold_before_flagging converted to
decimal."""
return self.average_growth + self.growth_threshold_before_flagging / 100
Copy link
Member Author

Choose a reason for hiding this comment

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

With the old algorithm this would have been:

        return self.average_growth * (
            1 + self.growth_threshold_before_flagging / 100
        )

@diox diox requested a review from KevinMind November 22, 2024 12:28
@KevinMind
Copy link
Contributor

@diox is it possble to get more specific criteria for a given addon, which values should be set to what in order to trigger or not trigger the flag?

@diox
Copy link
Member Author

diox commented Nov 25, 2024

It's difficult since it depends on the average hotness of your non-disabled extensions, and what the threshold for the given tier (which themselves depend on average_daily_users). That's why I suggested to trust the unit test.

On a local env, assuming a completely empty database (or at least no add-ons with a average_daily_users value that would matter for the tier we're creating), you can try doing the following:

  • Submit 3 unlisted extensions, run auto_approve to make sure they are signed
  • Update their average_daily_users value to 1500 each via shell
  • Update their hotness value to 0.4, 0.5, 0.6 respectively
  • Create a UsageTier in the admin with lower_adu_threshold set to 1000, upper_adu_threshold set to 5000, and growth_threshold_before_flagging to 9

With that setup, the average hotness amongst add-ons in that specific tier that was created should be 0.5, since the growth treshold is 9, that should flag only the one with 0.6 hotness (0.5 + 9/100). So triggering the task (flag_high_hotness_according_to_review_tier() in a shell - optionally flag_high_hotness_according_to_review_tier.delay() if you want to use celery) should result in that add-on to be added to the manual review queue, and its review page should indicate that it has been flagged for growth.

Copy link
Contributor

@KevinMind KevinMind left a comment

Choose a reason for hiding this comment

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

Looks good to me 🚢

@diox diox merged commit 9985dfb into mozilla:master Nov 25, 2024
31 checks passed
chrstinalin pushed a commit that referenced this pull request Jan 10, 2025
…22875)

* Change growth threshold algorithm do use percentage points increase

Also contains a refactor to make the code easier to test, as well as
admin & reviewer tools tweaks to make the consequences of changing that
threshold more obvious.

If the average hotness in a tier is 0.1, and the growth threshold is set to 50,
we used to flag add-ons in that tier with hotness over 0.15 (percentage increase)
now we'll flag over 0.51 (percentage points increase).

* Add test with negative average hotness

* Add assert num queries
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.

[Task]: Change growth threshold algorithm do use percentage points increase
2 participants