From f10657410f395eaa095e906cb080afedbe7b0945 Mon Sep 17 00:00:00 2001 From: thatguy11325 <148832074+thatguy11325@users.noreply.github.com> Date: Sun, 13 Oct 2024 10:44:07 -0400 Subject: [PATCH] More tolerant to crashes and failures --- pokemonred_puffer/sweep.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/pokemonred_puffer/sweep.py b/pokemonred_puffer/sweep.py index 4b8371e..8a4b988 100644 --- a/pokemonred_puffer/sweep.py +++ b/pokemonred_puffer/sweep.py @@ -131,21 +131,25 @@ def launch_sweep( elif ( run["state"] in [ - # RunState.failed.value, + RunState.failed.value, RunState.finished.value, - # RunState.crashed.value, + RunState.crashed.value, ] and run["name"] not in finished ): finished.add(run["name"]) summary_metrics = json.loads(run["summaryMetrics"]) - obs_in = ObservationInParam( - input=json.loads(run["config"])["x"]["value"], - # TODO: try out other stats like required count - output=summary_metrics["environment/stats/event"], - cost=summary_metrics["performance/uptime"], - ) - carbs.observe(obs_in) + if ( + "environment/stats/event" in summary_metrics + and "performance/uptime" in summary_metrics + ): + obs_in = ObservationInParam( + input=json.loads(run["config"])["x"]["value"], + # TODO: try out other stats like required count + output=summary_metrics["environment/stats/event"], + cost=summary_metrics["performance/uptime"], + ) + carbs.observe(obs_in) elif run["state"] == RunState.pending: print(f"PENDING RUN FOUND {run['name']}") sweep.print_status()