Skip to content

Commit aa88e12

Browse files
committed
restrict DataSource() construction to only applicable fields
...as was done for DataSignal() in #1303 , and using the same ugly over-extended comprehension pattern
1 parent d8acacc commit aa88e12

File tree

1 file changed

+2
-1
lines changed
  • src/server/endpoints/covidcast_utils

1 file changed

+2
-1
lines changed

src/server/endpoints/covidcast_utils/model.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ def _load_data_sources():
196196
data_sources_df: pd.DataFrame = pd.read_csv(_base_dir / "db_sources.csv")
197197
data_sources_df = data_sources_df.replace({np.nan: None})
198198
data_sources_df.columns = map(_clean_column, data_sources_df.columns)
199-
data_sources: List[DataSource] = [DataSource(**d) for d in data_sources_df.to_dict(orient="records")]
199+
datasource_fields = {f.name for f in fields(DataSource)}}
200+
data_sources: List[DataSource] = [DataSource(**{k: v for k, v in d.items() if k in datasource_fields}) for d in data_sources_df.to_dict(orient="records")]
200201
data_sources_df.set_index("source")
201202
return data_sources, data_sources_df
202203

0 commit comments

Comments
 (0)