"""Get feature flags on backend.""" from flask import g from pythonfeatures import pythonfeatures from pythonfeatures.constants import split as split_constants def is_feature_enabled(flag_name): """Check if users requested feature flag is enabled. Args: flag_name (str): name of the flag to be checked. Returns: bool: whether feature is enabled """ is_enabled = pythonfeatures.get_single_feature( flag_name, g.request_context ).message == split_constants.FEATURE_ENABLED g.ows.log.info(f'split {flag_name}: called with context_type ' f'{g.request_context} is {is_enabled}') return is_enabled