Skip to content

Commit

Permalink
run_benchmarks: wait and retry for diffile to exist
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharth-krishna committed Jan 27, 2025
1 parent e2faee3 commit 4f0635b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion utils/run_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ def parse_result(output: str) -> tuple[float, int, int]:
return (float(m[0]), int(m[1]), int(m[3]))


def _check_file_exists_and_retry(file_path, retries=60):
for _ in range(retries):
logger.info("Checking diffile exists")
if path.exists(file_path):
logger.info("Found diffile")
return True
time.sleep(5)
return False


def run_gams_gdxdiff(
benchmark: Any,
times_folder: str,
Expand Down Expand Up @@ -129,9 +139,16 @@ def run_gams_gdxdiff(
logger.info(res.stdout)
logger.info(res.stderr if res.stderr is not None else "")
if res.returncode != 0:
diffile = path.join(out_folder, "diffile.gdx")
if not _check_file_exists_and_retry(diffile):
logger.info(res.stdout)
logger.info(res.stderr if res.stderr is not None else "")
logger.error(
f"GAMS gdxdiff failed on {benchmark['name']}: diffile.gdx not found"
)
# Report the number of lines in the gdxdump of the difffile
res = subprocess.run(
["gdxdump", path.join(out_folder, "diffile.gdx")],
["gdxdump", diffile],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
Expand Down

0 comments on commit 4f0635b

Please sign in to comment.