Skip to content

[BD-21] Extract waffle_utils from edx-platform - #70

Merged
regisb merged 15 commits into
openedx:masterfrom
regisb:regisb/extract-waffle-utils
Oct 22, 2020
Merged

[BD-21] Extract waffle_utils from edx-platform#70
regisb merged 15 commits into
openedx:masterfrom
regisb:regisb/extract-waffle-utils

Conversation

@regisb

@regisb regisb commented Oct 7, 2020

Copy link
Copy Markdown
Contributor

Description: Extract the various waffle switch/flag classes from edx-platform such that they can be used in other IDAs. This implements ADR #2 <https://github.com/edx/edx-toggles/tree/master/docs/decisions/0002-application-toggle-state.rst>, #3 <https://github.com/edx/edx-toggles/tree/master/docs/decisions/0003-django-setting-toggles.rst>, #4 <https://github.com/edx/edx-toggles/tree/master/docs/decisions/0004-toggle-api.rst>__. These changes are backward-compatible. Suppression of the namespace classes will happen in a separate PR.

JIRA: https://openedx.atlassian.net/wiki/spaces/COMM/pages/1596358943?src=mail&src.mail.timestamp=1593719976942

Reviewers:

Merge checklist:

  • All reviewers approved
  • CI build is green
  • Version bumped
  • Changelog record added
  • Documentation updated (not only docstrings)
  • Commits are squashed

Post merge:

  • Create a tag
  • Check new version is pushed to PyPi after tag-triggered build is
    finished.
  • Delete working branch (if not needed anymore)

This is a work in progress. A couple things still need to be done:

  • Move waffle flag classes
  • Move unit tests
  • Document the new classes
  • Do not export BaseNamespace, which should not be exposed to edx-platform

@openedx-webhooks openedx-webhooks added blended PR is managed through 2U's blended developmnt program waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Oct 7, 2020
@openedx-webhooks

openedx-webhooks commented Oct 7, 2020

Copy link
Copy Markdown

Thanks for the pull request, @regisb! I've created BLENDED-617 to keep track of it in Jira. More details are on the BD-21 project page.

When this pull request is ready, tag your edX technical lead.

@robrap robrap left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm going to wait on further review.

Comment thread edx_toggles/toggles/internal/__init__.py
Comment thread edx_toggles/toggles/internal/base.py Outdated
Comment thread edx_toggles/toggles/internal/base.py

@robrap robrap left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I added a couple of additional high-level comments. Thanks!

Comment thread edx_toggles/toggles/internal/waffles.py Outdated
Comment thread edx_toggles/toggles/internal/waffles.py Outdated
Comment thread edx_toggles/toggles/internal/base.py
@regisb
regisb force-pushed the regisb/extract-waffle-utils branch 2 times, most recently from d211fa6 to e5796a6 Compare October 12, 2020 14:53
@regisb

regisb commented Oct 12, 2020

Copy link
Copy Markdown
Contributor Author

@robrap I expect that the suppression of the namespace classes is going to be tedious, but not otherwise complex. So I propose that we resolve the extraction of the waffle and switch classes first. I will then open a new PR to get rid of the many namespace instances. Otherwise we will end up with a PR that touches upon dozens of files, which is inconvenient to review.

@regisb
regisb force-pushed the regisb/extract-waffle-utils branch 4 times, most recently from 2390052 to acb0bba Compare October 12, 2020 16:59
@regisb
regisb force-pushed the regisb/extract-waffle-utils branch from ec83e96 to 190c219 Compare October 13, 2020 10:14
@regisb regisb changed the title [BD-21] Extract waffle_utils from edx-platform (WIP) [BD-21] Extract waffle_utils from edx-platform Oct 13, 2020
@openedx-webhooks openedx-webhooks added needs triage and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Oct 13, 2020
@regisb

regisb commented Oct 13, 2020

Copy link
Copy Markdown
Contributor Author

@robrap This should now be ready to review.

@regisb
regisb force-pushed the regisb/extract-waffle-utils branch 4 times, most recently from f54692c to 6a5d3c3 Compare October 14, 2020 14:36
Comment thread CHANGELOG.rst Outdated
Comment thread edx_toggles/toggles/internal/base.py
Comment thread edx_toggles/toggles/internal/waffle.py Outdated
Comment thread edx_toggles/toggles/internal/waffle.py Outdated
Comment thread edx_toggles/toggles/internal/waffle.py Outdated
Comment thread edx_toggles/toggles/internal/waffle.py Outdated
Comment thread edx_toggles/toggles/internal/waffle.py
Comment thread edx_toggles/toggles/internal/waffle.py Outdated
Comment on lines +190 to +192
def _get_flag_active_default(self, namespaced_flag_name):
"""
Return default value in the absence of any other, more specific flag value.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This name and docstring don't really match the implementation, which includes lots of warnings, because this is an exceptional case. What about _get_flag_active_for_missing_request or _get_flag_active_default_for_missing_request?

@regisb regisb Oct 22, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll go with _get_flag_active_no_request to be consistent with the naming of the _get_flag_active_request method.

Comment thread edx_toggles/toggles/internal/waffle.py Outdated
Comment thread edx_toggles/urls.py
Comment thread CHANGELOG.rst Outdated
@regisb
regisb force-pushed the regisb/extract-waffle-utils branch from 6a5d3c3 to 999ead8 Compare October 22, 2020 10:26
regisb added 13 commits October 22, 2020 12:28
Otherwise the edx-platform root url is overridden, too... This took me a
long while to figure it out...
This is necessary to get the flag value in the current request context.
This will be necessary for caching and monitoring.
For now, we keep the namespace classes, but they are meant to go soon.
The constructor was missing the `module_name` argument.
`tox -e pii_check` was failing with the following error:

    Coverage found 3 uncovered models:

        waffle.Flag
        waffle.Sample
        waffle.Switch

We mark these models as safe to pass the pii_check test.
The class attribute `_cached_value` was never being used. Instead,
`self._cached_value` was creating an instance-level attribute. So we
just get rid of the class attribute.
As these features are destined to be removed, we should not make them
available in the edx-toggles shared package.
This simplifies the API, notably for tests which no longer have to
manually call the `_get_waffle_flag_custom_attributes_set.clear_cache`
function before each test.

Instead, the WAFFLE_FLAG_CUSTOM_ATTRIBUTES setting should be a set.
Lists are also supported, although they might be slightly less
performant, dependending on the number of custom attributes.
* Fix ``SettingDictToggle`` constructor.
* Extract waffle classes from edx-platform and move them here.
* Fix pinned requirements and incorrect root url that overrode
edx-platform's.
@regisb
regisb force-pushed the regisb/extract-waffle-utils branch from 999ead8 to 4f690e6 Compare October 22, 2020 10:32

@robrap robrap left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We will follow-up with cleaning out namespacing in a following PR.

@regisb
regisb merged commit 8de5f3e into openedx:master Oct 22, 2020
@regisb
regisb deleted the regisb/extract-waffle-utils branch October 22, 2020 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blended PR is managed through 2U's blended developmnt program merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants