in mozci/console/commands/batch_execution.py [0:0]
def handle(self) -> None:
# Default value from a constant if nothing is provided
workers_count = MAXIMUM_PROCESSES
workers_option = self.option("workers")
if workers_option:
try:
workers_count = int(workers_option)
except ValueError:
self.line("<error>Provided --workers should be an int.</error>")
exit(1)
if workers_count > MAXIMUM_PROCESSES:
self.line(
f"<comment>Parallelization over {workers_count} workers was requested but only {MAXIMUM_PROCESSES} CPUs are available, falling back to using only {MAXIMUM_PROCESSES} workers.</comment>"
)
workers_count = MAXIMUM_PROCESSES
pushes = self.retrieve_pushes()
self.line(
f"<info>{len(pushes)} pushes will be classified using {len(PARAMETERS_COMBINATIONS)} parameters combinations.</info>"
)
with Pool(workers_count) as pool:
# Populate the cache + Clean up potential biases
pool.map(retrieve_push_and_prepare_for_analysis, pushes)
if not os.path.exists(BASE_OUTPUT_DIR):
os.makedirs(BASE_OUTPUT_DIR)
with open(
BASE_OUTPUT_DIR + "/all_executions.csv", "w", encoding="UTF8", newline=""
) as f:
writer = csv.DictWriter(f, fieldnames=self.csv_header)
writer.writeheader()
with Pool(workers_count) as pool:
# Each time an execution ends (execution = all combinations for a single push),
# its result will be appended to the CSV
for csv_rows in pool.imap(run_combinations_for_push, pushes):
writer.writerows(csv_rows)