feat: add setup notebook and update env example for Athena
This commit is contained in:
@@ -17,11 +17,24 @@ def _diff_rows(a: dict[str, dict], b: dict[str, dict]) -> list[dict]:
|
||||
"""Return one row per field with side-by-side year values."""
|
||||
keys = sorted(set(a.keys()) | set(b.keys()))
|
||||
rows: list[dict] = []
|
||||
def _years_of(v: dict) -> dict:
|
||||
"""Accept both friendly (year_values) and wire (nested years) shapes."""
|
||||
if isinstance(v.get("year_values"), dict):
|
||||
return {str(k): val for k, val in v["year_values"].items()}
|
||||
if isinstance(v.get("years"), dict):
|
||||
return {
|
||||
str(k): (cell or {}).get("value")
|
||||
for k, cell in v["years"].items()
|
||||
}
|
||||
if v.get("value") is not None:
|
||||
return {"1": v["value"]}
|
||||
return {}
|
||||
|
||||
for k in keys:
|
||||
av = a.get(k, {}) or {}
|
||||
bv = b.get(k, {}) or {}
|
||||
ay = av.get("year_values") or {}
|
||||
by = bv.get("year_values") or {}
|
||||
ay = _years_of(av)
|
||||
by = _years_of(bv)
|
||||
years = sorted(set(ay.keys()) | set(by.keys()), key=lambda x: int(x))
|
||||
for y in years:
|
||||
a_val = float(ay.get(y) or 0)
|
||||
@@ -79,8 +92,13 @@ def render(client: TEIClient, tool: dict) -> None:
|
||||
{
|
||||
"Version": v.get("version_number"),
|
||||
"Date": v.get("created_at") or v.get("date"),
|
||||
"NPV": float(snap.get("npv") or 0),
|
||||
"ROI %": float(snap.get("roi") or snap.get("roi_pct") or 0),
|
||||
"NPV": float(snap.get("net_present_value") or snap.get("npv") or 0),
|
||||
"ROI %": float(
|
||||
snap.get("roi_percentage")
|
||||
or snap.get("roi")
|
||||
or snap.get("roi_pct")
|
||||
or 0
|
||||
),
|
||||
"Note": v.get("note", ""),
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user