This repository was archived by the owner on Nov 8, 2024. It is now read-only.
File tree 5 files changed +24
-5
lines changed 5 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,10 @@ def init(config: Config) -> EppoClient:
40
40
flag_config_store .set_configurations (
41
41
config .initial_configuration ._flags_configuration .flags
42
42
)
43
+ if config .initial_configuration ._bandits_configuration :
44
+ bandit_config_store .set_configurations (
45
+ config .initial_configuration ._bandits_configuration .bandits
46
+ )
43
47
44
48
config_requestor = ExperimentConfigurationRequestor (
45
49
http_client = http_client ,
Original file line number Diff line number Diff line change 1
- from eppo_client .models import UfcResponse
1
+ from eppo_client .models import UfcResponse , BanditResponse
2
2
3
3
4
4
class Configuration :
@@ -7,5 +7,16 @@ class Configuration:
7
7
interpret feature flags.
8
8
"""
9
9
10
- def __init__ (self , flags_configuration : str ):
10
+ _flags_configuration : UfcResponse
11
+ _bandits_configuration : BanditResponse | None = None
12
+
13
+ def __init__ (
14
+ self ,
15
+ flags_configuration : str | bytes ,
16
+ bandits_configuration : str | bytes | None = None ,
17
+ ) -> None :
11
18
self ._flags_configuration = UfcResponse .model_validate_json (flags_configuration )
19
+ if bandits_configuration is not None :
20
+ self ._bandits_configuration = BanditResponse .model_validate_json (
21
+ bandits_configuration
22
+ )
Original file line number Diff line number Diff line change 6
6
7
7
8
8
class ConfigurationStore (Generic [T ]):
9
- def __init__ (self ):
9
+ def __init__ (self ) -> None :
10
10
self .__is_initialized = False
11
11
self .__cache : Dict [str , T ] = {}
12
12
self .__lock = ReadWriteLock ()
Original file line number Diff line number Diff line change @@ -105,3 +105,7 @@ class BanditData(SdkBaseModel):
105
105
bandit_model_version : str = Field (alias = "modelVersion" )
106
106
bandit_model_data : BanditModelData = Field (alias = "modelData" )
107
107
updated_at : datetime
108
+
109
+
110
+ class BanditResponse (SdkBaseModel ):
111
+ bandits : dict [str , BanditData ]
Original file line number Diff line number Diff line change 5
5
6
6
7
7
def test_init_valid ():
8
- Configuration (flags_configuration = '{"flags": {}}' )
8
+ Configuration (flags_configuration = b '{"flags": {}}' )
9
9
10
10
11
11
def test_init_invalid_json ():
@@ -15,4 +15,4 @@ def test_init_invalid_json():
15
15
16
16
def test_init_invalid_format ():
17
17
with pytest .raises (pydantic .ValidationError ):
18
- Configuration (flags_configuration = '{"flags": []}' )
18
+ Configuration (flags_configuration = b '{"flags": []}' )
You can’t perform that action at this time.
0 commit comments