Skip to content

Commit f17e291

Browse files
finish fixes
1 parent ef663f9 commit f17e291

File tree

2 files changed

+36
-34
lines changed

2 files changed

+36
-34
lines changed

choose_l10n_ci_set.py

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
6637
def process_changed_file(f, selected_mappings):
6738
"""
6839
process the changed file to add the site/region mappings.
@@ -135,15 +106,15 @@ def save_mappings(selected_container):
135106
# failsafe beta_version
136107
beta_version = 0
137108
# choose split number
138-
beta_version %= 3
109+
beta_version = (beta_version % 3) + 1
139110
l10n_mappings = valid_l10n_mappings()
140111
sample_mappings = {k: v for k, v in l10n_mappings.items() if k.startswith("demo")}
141112
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:
143114
l10n_mappings = json.load(f)
144115
if os.environ.get("TESTRAIL_REPORT") or os.environ.get("MANUAL"):
145116
# 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)
147118
sys.exit(0)
148119

149120
re_set_all = [
@@ -204,5 +175,5 @@ def save_mappings(selected_container):
204175
selected_mappings |= sample_mappings
205176
break
206177

207-
save_mappings(distribute_mappings_evenly(selected_mappings, beta_version))
178+
save_mappings(selected_mappings)
208179
sys.exit(0)
Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,32 @@
1-
{"demo": ["US", "GB", "DE", "FR", "PL", "ES", "CA"], "bijoubrigitte": ["DE"], "calvinklein": ["US"], "aldoshoes": ["US"], "peacocks": ["GB"], "assos": ["GB"], "fnac": ["FR"], "canadatire": ["CA"]}
1+
{
2+
"demo": [
3+
"US",
4+
"GB",
5+
"DE",
6+
"FR",
7+
"PL",
8+
"ES",
9+
"CA"
10+
],
11+
"bijoubrigitte": [
12+
"DE"
13+
],
14+
"calvinklein": [
15+
"US"
16+
],
17+
"aldoshoes": [
18+
"US"
19+
],
20+
"peacocks": [
21+
"GB"
22+
],
23+
"assos": [
24+
"GB"
25+
],
26+
"fnac": [
27+
"FR"
28+
],
29+
"canadatire": [
30+
"CA"
31+
]
32+
}

0 commit comments

Comments
 (0)