From d9ff145b9929697544bd091c9356af38667ab1e5 Mon Sep 17 00:00:00 2001 From: Jean-Marie Mineau Date: Tue, 20 May 2025 16:33:14 +0200 Subject: [PATCH] allow to rerun failed exp --- experiment/orchestrator.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/experiment/orchestrator.py b/experiment/orchestrator.py index 4042d10..be7b3e9 100644 --- a/experiment/orchestrator.py +++ b/experiment/orchestrator.py @@ -1,6 +1,8 @@ from pathlib import Path import os +import json +import shutil import time import subprocess import threading @@ -240,8 +242,21 @@ def worker(emu: str, apklist: list[str], out_folder: Path, script: Path): apk = apklist.pop() folder_name = apk.split("/")[-1].removesuffix(".apk") folder = out_folder / folder_name - if folder.exists(): - continue + if folder.exists() and (folder / "data.json").exists(): + has_error = False + with (folder / "data.json").open() as fp: + data = json.load(fp) + if "error" in data: + has_error = True + if (folder / "TIMEOUT").exists(): + has_error = True + if has_error: + print( + f"Previous result for {apk=} found but with error of timeout, remove old result and rerun it" + ) + shutil.rmtree(str(folder)) + else: + continue folder.mkdir(parents=True) with (