You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Set up a custom strategy in Unleash. Note down the name - you'll need this exact value to ensure we're loading the custom strategy correctly.
Create a custom strategy object by sub-classing the Strategy object.
from UnleashClient.strategies import Strategy
class CatTest(Strategy):
def load_provisioning(self) -> list:
return [x.strip() for x in self.parameters["sound"].split(',')]
def __call__(self, context: dict = None) -> bool:
"""
Turn on if I'm a cat.
:return:
"""
default_value = False
if "sound" in context.keys():
default_value = context["sound"] in self.parsed_provisioning
return default_value
Create a dictionary where the key is the name of the custom strategy.
my_custom_strategies = {"amIACat": CatTest}
When initializing UnleashClient, provide the custom strategy dictionary.