-
Notifications
You must be signed in to change notification settings - Fork 62
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
Dependent features #274
Dependent features #274
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
There was a problem hiding this 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 however I'm not a Python dev so would appreciate some Pythonista eyes on it :) I'd also add a test showing that we don't record a metrics for the parent feature.
dependency_feature = self.features[dependency_name] | ||
|
||
if not dependency_feature: | ||
LOGGER.warning("Feature dependency not found. %s", dependency_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in Node we have a mechanism to only log this message once. I'm assuming we don't do the same thing in Python SDK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a thing in the Python SDK at the moment, unfortunately. Not against adding it, but that should probably be a different PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM, I've left some thoughts, which are optional but should be considered, so I'm going to mark this as changes requested so this doesn't get accidentally merged
Agree with @kwasniew on the test, please! |
@@ -75,20 +82,20 @@ def _count_variant(self, variant_name: str) -> None: | |||
""" | |||
self.variant_counts[variant_name] = self.variant_counts.get(variant_name, 0) + 1 | |||
|
|||
def is_enabled(self, context: dict = None) -> bool: | |||
def is_enabled(self, context: dict = None, skip_stats: bool = False) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a more elegant way to do it? Without passing skip_stats
around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't think of a way without rearchitecting this a little. It should be possible to move the count metrics methods to public ones and only call those in the is_enabled in the UnleashClient but... I'm not sure that's worth it. This is all internal at the moment and when Yggdrasil arrives here this will go away anyway.
I'm okay with this as it stands. I think we can do better but I also don't think it's worth it to do so. I think this is a reasonable tradeoff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thumbs up
Description
Related to Unleash/unleash#2255
Introducing concept of "dependency" on a feature toggle. Feature toggle, in order to be enabled an return a variant, can require the specified state of another feature toggle. There will be a
dependencies
property on each feature.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: