This repository was archived by the owner on Nov 8, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +24
-5
lines changed Expand file tree Collapse file tree 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:
4040 flag_config_store .set_configurations (
4141 config .initial_configuration ._flags_configuration .flags
4242 )
43+ if config .initial_configuration ._bandits_configuration :
44+ bandit_config_store .set_configurations (
45+ config .initial_configuration ._bandits_configuration .bandits
46+ )
4347
4448 config_requestor = ExperimentConfigurationRequestor (
4549 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
22
33
44class Configuration :
@@ -7,5 +7,16 @@ class Configuration:
77 interpret feature flags.
88 """
99
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 :
1118 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 66
77
88class ConfigurationStore (Generic [T ]):
9- def __init__ (self ):
9+ def __init__ (self ) -> None :
1010 self .__is_initialized = False
1111 self .__cache : Dict [str , T ] = {}
1212 self .__lock = ReadWriteLock ()
Original file line number Diff line number Diff line change @@ -105,3 +105,7 @@ class BanditData(SdkBaseModel):
105105 bandit_model_version : str = Field (alias = "modelVersion" )
106106 bandit_model_data : BanditModelData = Field (alias = "modelData" )
107107 updated_at : datetime
108+
109+
110+ class BanditResponse (SdkBaseModel ):
111+ bandits : dict [str , BanditData ]
Original file line number Diff line number Diff line change 55
66
77def test_init_valid ():
8- Configuration (flags_configuration = '{"flags": {}}' )
8+ Configuration (flags_configuration = b '{"flags": {}}' )
99
1010
1111def test_init_invalid_json ():
@@ -15,4 +15,4 @@ def test_init_invalid_json():
1515
1616def test_init_invalid_format ():
1717 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