Skip to content

Commit

Permalink
Resilience fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
russss committed Mar 22, 2024
1 parent 11d2fc1 commit 08126fb
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions buildmap/plugins/power/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def get_distros(self):
yield Distro(
row["ogc_fid"],
get_key(row, "distro"),
get_key(row, "name"),
get_key(row, "name") or get_key(row, "entityhandle"),
get_key(row, "load"),
)

Expand Down Expand Up @@ -128,7 +128,7 @@ def get_outbound_connections(self, ogc_fid):
):
yield row[0], row[1], row[2] # End node FID, connection layer, length

def generate_plan(self):
def generate_plan(self) -> powerplan.Plan:
if self.opts.get("spec_dir"):
spec = powerplan.EquipmentSpec(self.opts["spec_dir"])
else:
Expand Down Expand Up @@ -216,7 +216,11 @@ def run(self):
for err in errors:
self.log.warning("\t" + str(err))

plan.generate()
try:
plan.generate()
except Exception as e:
self.log.exception("Error generating power plan: %s", e)
return

self.log.info("Plan validated in %.2f seconds", time.time() - start)

Expand Down Expand Up @@ -244,9 +248,11 @@ def run(self):
with open(os.path.join(out_path, "power-bom.html"), "w") as f:
f.write(generate_bom_html(plan))


with open(os.path.join(out_path, "test-schedules.html"), "w") as f:
f.write(generate_schedule_html(plan))
try:
with open(os.path.join(out_path, "test-schedules.html"), "w") as f:
f.write(generate_schedule_html(plan))
except Exception as e:
self.log.exception("Error generating test schedules: %s", e)

with open(os.path.join(out_path, "cables-bom.csv"), "w") as cables, open(
os.path.join(out_path, "distros-bom.csv"), "w"
Expand Down

0 comments on commit 08126fb

Please sign in to comment.