-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfeature_variant_sample.py
More file actions
24 lines (18 loc) · 1.06 KB
/
feature_variant_sample.py
File metadata and controls
24 lines (18 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import json
import os
import sys
from random_filter import RandomFilter
from featuremanagement import FeatureManager, TargetingContext
script_directory = os.path.dirname(os.path.abspath(sys.argv[0]))
with open(script_directory + "/formatted_feature_flags.json", "r", encoding="utf-8") as f:
feature_flags = json.load(f)
feature_manager = FeatureManager(feature_flags, feature_filters=[RandomFilter()])
print(feature_manager.is_enabled("TestVariants", TargetingContext(user_id="Adam")))
print(feature_manager.get_variant("TestVariants", TargetingContext(user_id="Adam")).configuration)
print(feature_manager.is_enabled("TestVariants", TargetingContext(user_id="Cass")))
print(feature_manager.get_variant("TestVariants", TargetingContext(user_id="Cass")).configuration)