Skip to content

Commit b20c26a

Browse files
authored
add messages to dassert
1 parent 316d88c commit b20c26a

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

  • causal_automl/TutorTask401_EIA_metadata_downloader_pipeline

causal_automl/TutorTask401_EIA_metadata_downloader_pipeline/eia_utils.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def _get_api_request(self, route: str) -> Dict[str, Any]:
131131
# Get response from parsed payload.
132132
data: Dict[str, Any] = {}
133133
# TODO(alvino): Add error handling for JSON parsing to manage potential parsing errors.
134-
data = json_data.get("response", {})
134+
data = json_data["response"]
135135
return data
136136

137137
def _get_leaf_route_data(self) -> Dict[str, Dict[str, Any]]:
@@ -280,7 +280,11 @@ def _get_facet_values(
280280
:param route: dataset route under the EIA v2 API
281281
:return: data containing all facet values
282282
"""
283-
hdbg.dassert_in("facets", metadata)
283+
hdbg.dassert_in(
284+
"facets",
285+
metadata,
286+
msg="Column 'facets' not found in metadata index."
287+
)
284288
facets = metadata["facets"]
285289
rows = []
286290
for facet in facets:
@@ -393,7 +397,11 @@ def plot_distribution(df_metadata: pd.DataFrame, column: str, title: str) -> Non
393397
'frequency_id', 'data_units')
394398
:param title: title for the plot
395399
"""
396-
hdbg.dassert_in(column, df_metadata.columns)
400+
hdbg.dassert_in(
401+
column,
402+
df_metadata.columns,
403+
msg=f"Column '{column}' not found in metadata index."
404+
)
397405
counts = df_metadata[column].value_counts()
398406
ax = counts.plot(kind="bar", figsize=(8, 4), title=title)
399407
ax.set_xlabel(column.replace("_", " ").title())

0 commit comments

Comments
 (0)