Skip to content

Commit

Permalink
Merge pull request NREL#437 from rewiringamerica/collect_errors
Browse files Browse the repository at this point in the history
Collect simulation errors in results json
  • Loading branch information
nweires authored Mar 26, 2024
2 parents cdad016 + f4a0503 commit 59a307d
Show file tree
Hide file tree
Showing 5 changed files with 1,500 additions and 2 deletions.
14 changes: 13 additions & 1 deletion buildstockbatch/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,21 @@ def read_out_osw(fs, filename):
keys_to_copy = ["started_at", "completed_at", "completed_status"]
for key in keys_to_copy:
out_d[key] = d.get(key, None)

step_errors = []
for step in d.get("steps", []):
if step["measure_dir_name"] == "BuildExistingModel":
measure_dir_name = step["measure_dir_name"]
if measure_dir_name == "BuildExistingModel":
out_d["building_id"] = step["arguments"]["building_id"]

# Collect error messages from any failed steps.
if result := step.get("result"):
if result.get("step_result", "Success") != "Success":
step_errors.append({"measure_dir_name": measure_dir_name, "step_errors": result.get("step_errors")})

if step_errors:
out_d["step_failures"] = step_errors

return out_d


Expand Down
2 changes: 1 addition & 1 deletion buildstockbatch/test/test_hpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def make_sim_dir_mock(building_id, upgrade_idx, base_dir, overwrite_existing=Fal
# check results job-json
refrence_path = pathlib.Path(__file__).resolve().parent / "test_results" / "reference_files"

refrence_list = json.loads(gzip.open(refrence_path / "results_job1.json.gz", "r").read())
refrence_list = json.loads(open(refrence_path / "results_job1.json", "r").read())

output_list = json.loads(gzip.open(results_dir / "simulation_output" / "results_job1.json.gz", "r").read())

Expand Down
Loading

0 comments on commit 59a307d

Please sign in to comment.