raise EmptyDataError when no results returned (#6592)

This commit is contained in:
Danglewood
2024-07-18 03:20:29 -07:00
committed by GitHub
parent 422d05077d
commit 6deabd7d01
3 changed files with 18 additions and 6 deletions

View File

@@ -5333,16 +5333,16 @@
},
{
"name": "tag_names",
"type": "str",
"description": "A semicolon delimited list of tag names that series match all of. Example: 'japan;imports'",
"type": "Union[str, List[str]]",
"description": "A semicolon delimited list of tag names that series match all of. Example: 'japan;imports' Multiple items allowed for provider(s): fred.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "exclude_tag_names",
"type": "str",
"description": "A semicolon delimited list of tag names that series match none of. Example: 'imports;services'. Requires that variable tag_names also be set to limit the number of matching series.",
"type": "Union[str, List[str]]",
"description": "A semicolon delimited list of tag names that series match none of. Example: 'imports;services'. Requires that variable tag_names also be set to limit the number of matching series. Multiple items allowed for provider(s): fred.",
"default": null,
"optional": true,
"choices": null

View File

@@ -1037,9 +1037,9 @@ class ROUTER_economy(Container):
filter_value : Optional[str]
String value to filter the variable by. Used in conjunction with filter_variable. (provider: fred)
tag_names : Optional[str]
A semicolon delimited list of tag names that series match all of. Example: 'japan;imports' (provider: fred)
A semicolon delimited list of tag names that series match all of. Example: 'japan;imports' Multiple comma separated items allowed. (provider: fred)
exclude_tag_names : Optional[str]
A semicolon delimited list of tag names that series match none of. Example: 'imports;services'. Requires that variable tag_names also be set to limit the number of matching series. (provider: fred)
A semicolon delimited list of tag names that series match none of. Example: 'imports;services'. Requires that variable tag_names also be set to limit the number of matching series. Multiple comma separated items allowed. (provider: fred)
series_id : Optional[str]
A FRED Series ID to return series group information for. This returns the required information to query for regional data. Not all series that are in FRED have geographical data. Entering a value for series_id will override all other parameters. Multiple series_ids can be separated by commas. (provider: fred)
@@ -1120,6 +1120,10 @@ class ROUTER_economy(Container):
"query": query,
},
extra_params=kwargs,
info={
"tag_names": {"fred": {"multiple_items_allowed": True}},
"exclude_tag_names": {"fred": {"multiple_items_allowed": True}},
},
)
)

View File

@@ -10,6 +10,7 @@ from openbb_core.provider.standard_models.fred_search import (
SearchQueryParams,
)
from openbb_core.provider.utils.descriptions import QUERY_DESCRIPTIONS
from openbb_core.provider.utils.errors import EmptyDataError
from pydantic import Field, NonNegativeInt
@@ -19,6 +20,11 @@ class FredSearchQueryParams(SearchQueryParams):
__alias_dict__ = {
"query": "search_text",
}
__json_schema_extra__ = {
"tag_names": {"multiple_items_allowed": True},
"exclude_tag_names": {"multiple_items_allowed": True},
}
is_release: Optional[bool] = Field(
default=False,
description="Is release? If True, other search filter variables are ignored."
@@ -171,6 +177,8 @@ class FredSearchFetcher(
query: FredSearchQueryParams, data: List[Dict], **kwargs: Any
) -> List[FredSearchData]:
"""Transform data."""
if not data:
raise EmptyDataError("No results were found with the supplied parameters.")
if query.series_id is None:
for observation in data:
id_column_name = (