Skip to content

Commit

Permalink
fail gracefully when a metric returns None
Browse files Browse the repository at this point in the history
  • Loading branch information
ocefpaf committed Apr 3, 2024
1 parent d768d09 commit 5d3bb95
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ioos_metrics/ioos_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def _compare_metrics(column, num):
Compares last stored metric against the new one and report if it is up, down, or the same.
"""
if num is None:
return f"[{date}] : {column} failed."
last_row = previous_metrics().iloc[-1]
date = last_row["date_UTC"]
old = last_row[column]
Expand Down Expand Up @@ -212,7 +214,8 @@ def atn_deployments():
headers = {"Accept": "application/json"}

raw_payload = requests.get(
"https://search.axds.co/v2/search?portalId=99", headers=headers
"https://search.axds.co/v2/search?portalId=99",
headers=headers,
)
json_payload = raw_payload.json()
for plt in json_payload["types"]:
Expand Down Expand Up @@ -296,7 +299,9 @@ def ioos_core_variables():

# Drop the rows where 'name' doesn't exist.
df = df.dropna(
axis="index", how="any", subset="http://mmisw.org/ont/ioos/core_variable/name"
axis="index",
how="any",
subset="http://mmisw.org/ont/ioos/core_variable/name",
)

return len(df.index.tolist())
Expand Down

0 comments on commit 5d3bb95

Please sign in to comment.