@@ -34,35 +34,6 @@ def valid_l10n_mappings():
34
34
return mapping
35
35
36
36
37
- def distribute_mappings_evenly (mappings , version ):
38
- """
39
- Distribute the selected mappings if its a reportable run.
40
-
41
- Args:
42
- mappings (dict): A dictionary of mappings, where the keys are sites and the values are sets of regions.
43
- version (int): The beta_version of the beta.
44
- """
45
- if not mappings :
46
- return {}
47
- if os .environ .get ("TESTRAIL_REPORT" ):
48
- # sort the mappings by the length of the regions per site
49
- mappings = dict (
50
- sorted (mappings .items (), key = lambda val : len (val [1 ]), reverse = True )
51
- )
52
- # place the mappings into 3 containers evenly according to the load
53
- loads = [0 , 0 , 0 ]
54
- containers = [defaultdict (set ) for _ in range (3 )]
55
- for key , value in mappings .items ():
56
- min_idx = loads .index (min (loads ))
57
- containers [min_idx ][key ] = value
58
- loads [min_idx ] += len (value )
59
- # get container index according to beta beta_version
60
- run_idx = version % 3
61
- return containers [run_idx ]
62
- else :
63
- return mappings
64
-
65
-
66
37
def process_changed_file (f , selected_mappings ):
67
38
"""
68
39
process the changed file to add the site/region mappings.
@@ -135,15 +106,15 @@ def save_mappings(selected_container):
135
106
# failsafe beta_version
136
107
beta_version = 0
137
108
# choose split number
138
- beta_version %= 3
109
+ beta_version = ( beta_version % 3 ) + 1
139
110
l10n_mappings = valid_l10n_mappings ()
140
111
sample_mappings = {k : v for k , v in l10n_mappings .items () if k .startswith ("demo" )}
141
112
if os .path .exists (f"l10n_CM/beta_run_splits/l10n_split_{ beta_version } .json" ):
142
- with open (f"l10n_CM/beta_run_splits/l10n_split_{ beta_version } .json" , "w " ) as f :
113
+ with open (f"l10n_CM/beta_run_splits/l10n_split_{ beta_version } .json" , "r " ) as f :
143
114
l10n_mappings = json .load (f )
144
115
if os .environ .get ("TESTRAIL_REPORT" ) or os .environ .get ("MANUAL" ):
145
116
# Run all tests if this is a scheduled beta or a manual run
146
- save_mappings (distribute_mappings_evenly ( l10n_mappings , beta_version ) )
117
+ save_mappings (l10n_mappings )
147
118
sys .exit (0 )
148
119
149
120
re_set_all = [
@@ -204,5 +175,5 @@ def save_mappings(selected_container):
204
175
selected_mappings |= sample_mappings
205
176
break
206
177
207
- save_mappings (distribute_mappings_evenly ( selected_mappings , beta_version ) )
178
+ save_mappings (selected_mappings )
208
179
sys .exit (0 )
0 commit comments