-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Should we continue use of the FEATURES dict in edx-platform? #33026
Comments
Hah, I recall having this conversation at an edX Arch Lunch when I was an intern in 2017. Nobody could name a reason for keeping a separate FEATURES dict, especially considering that boolean flags already existed outside of FEATURES at that point. In any event, I'm in favor of flattening, either as |
Thanks @kdmccormick. I'll also note that https://docs.openedx.org/projects/edx-platform/en/latest/references/featuretoggles.html is a new feature that helps make it less important how consistent we are. I like clarity that leads to consistency, so I think it would be useful (through DEPR and/or ADR) to state that the Around naming, I think Also, some use Maybe the naming recommendations would be better as an edx-toggles how-to (or part of an existing how-to), and here we really just need to clarify whether or not to add to the dict. |
I like |
|
@kdmccormick: Some thoughts since we last wrote on the topic:
|
I also don't have time to carry this out right now. @feanil , is Aximprovements looking for work? If so, is collapsing FEATURES something they'd be interested in? |
A little more detail on the migration path I'm imagining... we'd collapse all of class _Features(dict):
def __init__(self, pass_through_to):
self.pass_through_to = pass_through_to
def __getitem__(self, key):
return self.pass_through_to[key]
def __setitem(self, key, value):
warnings.warn(f"FEATURES is deprecated. Instead of overriding FEATURES['{key}'], just override {key}")
self.pass_through_to[key] = value
FEATURES = _Features(pass_through_to=vars()) EDIT: Hm, this might not work, because |
Examples:
|
Linting would be simple if we just put an upper bound on the size of the dict. So, it is possible that we could decide, add linting, document a naming convention alternative, and iterate later with better automating the full transition when and if that gets prioritized. |
@robrap You're right, linting is totally feasible here just by inspecting the length or keys of the FEATURES dict. |
@robrap Regarding naming... I'm looking at common.py to see what other third-party apps do. It seems like the convention is to prefix with feature area, so I like that a lot (most of our own apps already do it too :). However, they don't suffix with _TOGGLE; rather, they just kinda describe the behavior that would occur if they were set to True. Some examples:
Given that, I lean away from suffixing with _TOGGLE, or with anything else for that matter. That does still leave the awkwardness of
A nice property of this is that all toggles can be checked the same way, regardless of whether they are Django settings, Toggles wrapping Django settings, or Toggles wrapping Waffle Flags. For CourseWaffleFlags, we could even support a nice syntax like:
where |
@kdmccormick: Good thoughts. I think your proposal is a reasonable alternative, or enhancement, to what is captured in openedx/edx-toggles#290. Yours is a more elegant solution from a readability perspective, as long as people don't get caught up wondering how it actually works. |
@robrap Oh, I didn't realize that there was edx-toggles work in flight--nice!
It's the classic tension between Having A Simple API and Having A Simple Implementation :) Alternatively, in the spirit of There's One Way To Do It, I'm also OK with just having Anyway, that's a lot of opinions from me, all loosely held. In the end, my only strong opinion is that we need to have fewer layers between what the site operator configures and what the application sees. |
Ultimately this should result in an ADR and/or a DEPR, but I'm first creating an issue to initiate discussion on the topic.
Background, I've heard in the past that we should stop using the
FEATURES
dict, but I do not know all the reasons or the recommended alternative. As new settings are added, it would be great if there was clarity around this.The following ADR on managing django settings mentions
FEATURES
, but it does not take any stance on this topic.Open questions:
FEATURE_XXX
?If anyone with history on this topic could shed some additional light, that would be great.
The text was updated successfully, but these errors were encountered: