@@ -34,35 +34,6 @@ def valid_l10n_mappings():
3434 return mapping
3535
3636
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-
6637def process_changed_file (f , selected_mappings ):
6738 """
6839 process the changed file to add the site/region mappings.
@@ -108,6 +79,21 @@ def save_mappings(selected_container):
10879 f .writelines (current_running_mappings )
10980
11081
82+ def select_l10n_mappings (beta_version ):
83+ """
84+ Select the correct l10n mappings.
85+
86+ Args:
87+ beta_version: the current beta version.
88+ """
89+ beta_split = (beta_version % 3 ) + 1
90+ if os .path .exists (f"l10n_CM/beta_run_splits/l10n_split_{ beta_split } .json" ):
91+ with open (f"l10n_CM/beta_run_splits/l10n_split_{ beta_split } .json" , "r" ) as f :
92+ return json .load (f )
93+ else :
94+ return valid_l10n_mappings ()
95+
96+
11197if __name__ == "__main__" :
11298 if os .path .exists (".env" ):
11399 with open (".env" ) as fh :
@@ -134,11 +120,12 @@ def save_mappings(selected_container):
134120 except ValueError :
135121 # failsafe beta_version
136122 beta_version = 0
137- l10n_mappings = valid_l10n_mappings ()
123+ # choose split number
124+ l10n_mappings = select_l10n_mappings (beta_version )
138125 sample_mappings = {k : v for k , v in l10n_mappings .items () if k .startswith ("demo" )}
139126 if os .environ .get ("TESTRAIL_REPORT" ) or os .environ .get ("MANUAL" ):
140127 # Run all tests if this is a scheduled beta or a manual run
141- save_mappings (distribute_mappings_evenly ( l10n_mappings , beta_version ) )
128+ save_mappings (l10n_mappings )
142129 sys .exit (0 )
143130
144131 re_set_all = [
@@ -199,5 +186,5 @@ def save_mappings(selected_container):
199186 selected_mappings |= sample_mappings
200187 break
201188
202- save_mappings (distribute_mappings_evenly ( selected_mappings , beta_version ) )
189+ save_mappings (selected_mappings )
203190 sys .exit (0 )
0 commit comments