Skip to content

Commit 30d111b

Browse files
first attempt at rotating runs
1 parent 41690d5 commit 30d111b

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

choose_l10n_ci_set.py

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import json
22
import os
3+
import random
34
import re
5+
import subprocess
46
import sys
57
from collections import defaultdict
68
from subprocess import check_output
@@ -39,9 +41,40 @@ def add_selected_mappings(mappings):
3941
Args:
4042
mappings (dict): A dictionary of mappings, where the keys are sites and the values are sets of regions.
4143
"""
42-
for site, regions in mappings.items():
43-
with open(OUTPUT_FILE, "a+") as f:
44-
f.write(f"{site} {' '.join(regions)}\n")
44+
# sort the mappings by the length of the regions per site
45+
mappings = dict(sorted(mappings.items(), key=lambda val: len(val[1]), reverse=True))
46+
print(mappings)
47+
# place the mappings into 3 containers evenly according to the load
48+
loads = [0, 0, 0]
49+
containers = [[] for _ in range(3)]
50+
for key, value in mappings.items():
51+
min_idx = loads.index(min(loads))
52+
containers[min_idx].append(f"{key} {' '.join(value)}")
53+
loads[min_idx] += len(value)
54+
# shuffle the containers so each run for a beta is random.
55+
random.shuffle(containers)
56+
try:
57+
version = int(
58+
(
59+
subprocess.check_output(
60+
[sys.executable, "./collect_executables.py", "-n"]
61+
)
62+
.strip()
63+
.decode()
64+
)
65+
.split("-")[0]
66+
.split(".")[1]
67+
.split("b")[1]
68+
)
69+
except:
70+
# failsafe version
71+
version = 0
72+
# get container index according to beta version
73+
run_idx = version % 3
74+
with open(OUTPUT_FILE, "a+") as f:
75+
for mapping in containers[run_idx]:
76+
print(mapping)
77+
f.write(f"{mapping}\n")
4578

4679

4780
def process_changed_file(f, selected_mappings):
@@ -53,7 +86,7 @@ def process_changed_file(f, selected_mappings):
5386
selected_mappings: the selected mappings dictionary (updated in place).
5487
"""
5588
split = f.split(SLASH)
56-
89+
print(split)
5790
if f.startswith(os.path.join("l10n_CM", "sites")) or f.startswith(
5891
os.path.join("l10n_CM", "constants")
5992
):

l10n_CM/run_l10n.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"wish",
4343
"bijoubrigitte",
4444
"peacocks",
45-
"whittard"
45+
"whittard",
4646
}
4747

4848
loaded_valid_sites = valid_l10n_mappings().keys()

0 commit comments

Comments
 (0)