77
88SplitView = namedtuple (
99 'SplitView' ,
10- ['name' , 'traffic_type' , 'killed' , 'treatments' , 'change_number' , 'configs' ]
10+ ['name' , 'traffic_type' , 'killed' , 'treatments' , 'change_number' , 'configs' , 'default_treatment' , 'sets' ]
1111)
1212
1313
@@ -41,7 +41,8 @@ def __init__( # pylint: disable=too-many-arguments
4141 algo = None ,
4242 traffic_allocation = None ,
4343 traffic_allocation_seed = None ,
44- configurations = None
44+ configurations = None ,
45+ sets = None
4546 ):
4647 """
4748 Class constructor.
@@ -62,6 +63,8 @@ def __init__( # pylint: disable=too-many-arguments
6263 :type traffic_allocation: int
6364 :pram traffic_allocation_seed: Seed used to hash traffic allocation.
6465 :type traffic_allocation_seed: int
66+ :pram sets: list of flag sets
67+ :type sets: list
6568 """
6669 self ._name = name
6770 self ._seed = seed
@@ -90,6 +93,7 @@ def __init__( # pylint: disable=too-many-arguments
9093 self ._algo = HashAlgorithm .LEGACY
9194
9295 self ._configurations = configurations
96+ self ._sets = set (sets ) if sets is not None else set ()
9397
9498 @property
9599 def name (self ):
@@ -146,6 +150,11 @@ def traffic_allocation_seed(self):
146150 """Return the traffic allocation seed of the split."""
147151 return self ._traffic_allocation_seed
148152
153+ @property
154+ def sets (self ):
155+ """Return the flag sets of the split."""
156+ return self ._sets
157+
149158 def get_configurations_for (self , treatment ):
150159 """Return the mapping of treatments to configurations."""
151160 return self ._configurations .get (treatment ) if self ._configurations else None
@@ -173,7 +182,8 @@ def to_json(self):
173182 'defaultTreatment' : self .default_treatment ,
174183 'algo' : self .algo .value ,
175184 'conditions' : [c .to_json () for c in self .conditions ],
176- 'configurations' : self ._configurations
185+ 'configurations' : self ._configurations ,
186+ 'sets' : list (self ._sets )
177187 }
178188
179189 def to_split_view (self ):
@@ -189,7 +199,9 @@ def to_split_view(self):
189199 self .killed ,
190200 list (set (part .treatment for cond in self .conditions for part in cond .partitions )),
191201 self .change_number ,
192- self ._configurations if self ._configurations is not None else {}
202+ self ._configurations if self ._configurations is not None else {},
203+ self ._default_treatment ,
204+ list (self ._sets ) if self ._sets is not None else []
193205 )
194206
195207 def local_kill (self , default_treatment , change_number ):
@@ -238,5 +250,6 @@ def from_raw(raw_split):
238250 raw_split .get ('algo' ),
239251 traffic_allocation = raw_split .get ('trafficAllocation' ),
240252 traffic_allocation_seed = raw_split .get ('trafficAllocationSeed' ),
241- configurations = raw_split .get ('configurations' )
253+ configurations = raw_split .get ('configurations' ),
254+ sets = set (raw_split .get ('sets' )) if raw_split .get ('sets' ) is not None else []
242255 )
0 commit comments