diff options
24 files changed, 289 insertions, 280 deletions
diff --git a/openbb_platform/core/openbb_core/api/rest_api.py b/openbb_platform/core/openbb_core/api/rest_api.py index 7c9e0f1488e..f166a91be4e 100644 --- a/openbb_platform/core/openbb_core/api/rest_api.py +++ b/openbb_platform/core/openbb_core/api/rest_api.py @@ -88,6 +88,8 @@ AppLoader.from_routers( @app.exception_handler(Exception) async def api_exception_handler(_: Request, exc: Exception): """Exception handler for all other exceptions.""" + if Env().DEBUG_MODE: + raise exc logger.error(exc) return JSONResponse( status_code=404, @@ -101,6 +103,8 @@ async def api_exception_handler(_: Request, exc: Exception): @app.exception_handler(OpenBBError) async def openbb_exception_handler(_: Request, exc: OpenBBError): """Exception handler for OpenBB errors.""" + if Env().DEBUG_MODE: + raise exc logger.error(exc.original) openbb_error = exc.original status_code = 400 if "No results" in str(openbb_error) else 500 diff --git a/openbb_platform/core/openbb_core/app/provider_interface.py b/openbb_platform/core/openbb_core/app/provider_interface.py index 0b5267e58b8..ac43a50a16a 100644 --- a/openbb_platform/core/openbb_core/app/provider_interface.py +++ b/openbb_platform/core/openbb_core/app/provider_interface.py @@ -218,10 +218,10 @@ class ProviderInterface(metaclass=SingletonMeta): multiple := extra.get("multiple_items_allowed") # type: ignore ): if provider_name: - additional_description += " Multiple items allowed." + additional_description += " Multiple comma separated items allowed." else: additional_description += ( - " Multiple items allowed for provider(s): " + ", ".join(multiple) + "." # type: ignore + " Multiple comma separated items allowed for provider(s): " + ", ".join(multiple) + "." # type: ignore ) provider_field = ( diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index 0faab062605..663fa7e4340 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -788,13 +788,18 @@ class MethodDefinition: code += " simplefilter('always', DeprecationWarning)\n" code += f""" warn("{deprecation_message}", category=DeprecationWarning, stacklevel=2)\n\n""" - extra_info = {} + info = {} code += " return self._run(\n" code += f""" "{path}",\n""" code += " **filter_inputs(\n" for name, param in parameter_map.items(): if name == "extra_params": + fields = param.annotation.__args__[0].__dataclass_fields__ + values = {k: k for k in fields} + for k in values: + if extra := MethodDefinition.get_extra(fields[k]): + info[k] = extra code += f" {name}=kwargs,\n" elif name == "provider_choices": field = param.annotation.__args__[0].__dataclass_fields__["provider"] @@ -808,19 +813,18 @@ class MethodDefinition: code += " },\n" elif MethodDefinition.is_annotated_dc(param.annotation): fields = param.annotation.__args__[0].__dataclass_fields__ - value = {k: k for k in fields} + values = {k: k for k in fields} code += f" {name}={{\n" - for k, v in value.items(): + for k, v in values.items(): code += f' "{k}": {v},\n' - # TODO: Extend this to extra_params if extra := MethodDefinition.get_extra(fields[k]): - extra_info[k] = extra + info[k] = extra code += " },\n" else: code += f" {name}={name},\n" - if extra_info: - code += f" extra_info={extra_info},\n" + if info: + code += f" info={info},\n" if MethodDefinition.is_data_processing_function(path): code += " data_processing=True,\n" diff --git a/openbb_platform/core/openbb_core/app/static/utils/filters.py b/openbb_platform/core/openbb_core/app/static/utils/filters.py index 36e9d3164db..32a92138586 100644 --- a/openbb_platform/core/openbb_core/app/static/utils/filters.py +++ b/openbb_platform/core/openbb_core/app/static/utils/filters.py @@ -7,7 +7,7 @@ from openbb_core.app.utils import check_single_item, convert_to_basemodel def filter_inputs( data_processing: bool = False, - extra_info: Optional[Dict[str, Dict[str, List[str]]]] = None, + info: Optional[Dict[str, Dict[str, List[str]]]] = None, **kwargs, ) -> dict: """Filter command inputs.""" @@ -15,13 +15,13 @@ def filter_inputs( if data_processing and key == "data": kwargs[key] = convert_to_basemodel(value) - if extra_info: + if info: PROPERTY = "multiple_items_allowed" # Here we check if list items are passed and multiple items allowed for # the given provider/input combination. In that case we transform the list # into a comma-separated string - for field, props in extra_info.items(): + for field, props in info.items(): if PROPERTY in props and ( provider := kwargs.get("provider_choices", {}).get("provider") ): diff --git a/openbb_platform/core/openbb_core/provider/standard_models/analyst_search.py b/openbb_platform/core/openbb_core/provider/standard_models/analyst_search.py index c4b13b4067c..14f95b00de5 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/analyst_search.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/analyst_search.py @@ -16,13 +16,13 @@ class AnalystSearchQueryParams(QueryParams): analyst_name: Optional[str] = Field( default=None, - description="A comma separated list of analyst names to bring back." - + " Omitting will bring back all available analysts.", + description="Analyst names to return." + + " Omitting will return all available analysts.", ) firm_name: Optional[str] = Field( default=None, - description="A comma separated list of firm names to bring back." - + " Omitting will bring back all available firms.", + description="Firm names to return." + + " Omitting will return all available firms.", ) diff --git a/openbb_platform/core/openbb_core/provider/standard_models/company_news.py b/openbb_platform/core/openbb_core/provider/standard_models/company_news.py index cae56e2d081..80433ecb6e6 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/company_news.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/company_news.py @@ -22,8 +22,7 @@ class CompanyNewsQueryParams(QueryParams): symbol: Optional[str] = Field( default=None, - description=QUERY_DESCRIPTIONS.get("symbol", "") - + " This endpoint will accept multiple symbols separated by commas.", + description=QUERY_DESCRIPTIONS.get("symbol", ""), ) start_date: Optional[dateType] = Field( default=None, description=QUERY_DESCRIPTIONS.get("start_date", "") diff --git a/openbb_platform/core/openbb_core/provider/standard_models/equity_quote.py b/openbb_platform/core/openbb_core/provider/standard_models/equity_quote.py index 8fc3045fb0e..c98c7cfdfad 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/equity_quote.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/equity_quote.py @@ -16,10 +16,7 @@ from openbb_core.provider.utils.descriptions import ( class EquityQuoteQueryParams(QueryParams): """Equity Quote Query.""" - symbol: str = Field( - description=QUERY_DESCRIPTIONS.get("symbol", "") - + " This endpoint will accept multiple symbols separated by commas." - ) + symbol: str = Field(description=QUERY_DESCRIPTIONS.get("symbol", "")) @field_validator("symbol", mode="before", check_fields=False) @classmethod diff --git a/openbb_platform/extensions/equity/integration/test_equity_api.py b/openbb_platform/extensions/equity/integration/test_equity_api.py index f30e471e073..511b4305417 100644 --- a/openbb_platform/extensions/equity/integration/test_equity_api.py +++ b/openbb_platform/extensions/equity/integration/test_equity_api.py @@ -683,6 +683,20 @@ def test_equity_estimates_price_target(params, headers): "firm_ids": None, "firm_name": "Barclays", "analyst_name": None, + "page": 0, + } + ), + ( + { + "limit": 3, + "provider": "benzinga", + # optional provider params + "fields": None, + "analyst_ids": None, + "firm_ids": None, + "firm_name": "Barclays,Credit Suisse", + "analyst_name": None, + "page": 1, } ), ], diff --git a/openbb_platform/extensions/tests/conftest.py b/openbb_platform/extensions/tests/conftest.py index 01de5e65d3f..7e3fbce9dc2 100644 --- a/openbb_platform/extensions/tests/conftest.py +++ b/openbb_platform/extensions/tests/conftest.py @@ -1,6 +1,6 @@ """Custom pytest configuration for the extensions.""" -from typing import Any, Dict, List, Tuple +from typing import Any, Dict, List import pytest from openbb_core.app.router import CommandMap @@ -13,7 +13,7 @@ commands = list(cm.map.keys()) # ruff: noqa: SIM114 -def parametrize(argnames: str, argvalues: List[Tuple[Any, ...]], **kwargs): +def parametrize(argnames: str, argvalues: List[Dict[str, Any]], **kwargs): """Custom parametrize decorator that filters test cases based on the environment.""" routers, providers, obbject_ext = list_openbb_extensions() diff --git a/openbb_platform/openbb/assets/reference.json b/openbb_platform/openbb/assets/reference.json index 13c7fda420d..fa564183b18 100644 --- a/openbb_platform/openbb/assets/reference.json +++ b/openbb_platform/openbb/assets/reference.json @@ -782,7 +782,7 @@ }, { "name": "counter_currencies", - "type": "Union[str, List[str]]", + "type": "Union[List[str], str]", "description": "An optional list of counter currency symbols to filter for. None returns all.", "default": null, "optional": true @@ -4381,21 +4381,21 @@ }, { "name": "analyst_ids", - "type": "Union[str, List[str]]", + "type": "Union[List[str], str]", "description": "Comma-separated list of analyst (person) IDs. Omitting will bring back all available analysts.", "default": null, "optional": true }, { "name": "firm_ids", - "type": "Union[str, List[str]]", + "type": "Union[List[str], str]", "description": "Comma-separated list of firm IDs.", "default": null, "optional": true }, { "name": "fields", - "type": "Union[str, List[str]]", + "type": "Union[List[str], str]", "description": "Comma-separated list of fields to include in the response. See https://docs.benzinga.io/benzinga-apis/calendar/get-ratings to learn about the available fields.", "default": null, "optional": true @@ -5023,15 +5023,15 @@ "standard": [ { "name": "analyst_name", - "type": "str", - "description": "A comma separated list of analyst names to bring back. Omitting will bring back all available analysts.", + "type": "Union[str, List[str]]", + "description": "Analyst names to return. Omitting will return all available analysts. Multiple items allowed for provider(s): benzinga.", "default": null, "optional": true }, { "name": "firm_name", - "type": "str", - "description": "A comma separated list of firm names to bring back. Omitting will bring back all available firms.", + "type": "Union[str, List[str]]", + "description": "Firm names to return. Omitting will return all available firms. Multiple items allowed for provider(s): benzinga.", "default": null, "optional": true }, @@ -5047,14 +5047,14 @@ { "name": "analyst_ids", "type": "Union[str, List[str]]", - "description": "A comma separated list of analyst IDs to bring back.", + "description": "List of analyst IDs to return. Multiple items allowed for provider(s): benzinga.", "default": null, "optional": true }, { "name": "firm_ids", "type": "Union[str, List[str]]", - "description": "A comma separated list of firm IDs to bring back.", + "description": "Firm IDs to return. Multiple items allowed for provider(s): benzinga.", "default": null, "optional": true }, @@ -5075,7 +5075,7 @@ { "name": "fields", "type": "Union[str, List[str]]", - "description": "Comma-separated list of fields to include in the response. See https://docs.benzinga.io/benzinga-apis/calendar/get-ratings to learn about the available fields.", + "description": "Fields to include in the response. See https://docs.benzinga.io/benzinga-apis/calendar/get-ratings to learn about the available fields. Multiple items allowed for provider(s): benzinga.", "default": null, "optional": true } @@ -13482,20 +13482,6 @@ "optional": false }, { - "name": "start_date", - "type": "Union[date, str]", - "description": "Start date of the data, in YYYY-MM-DD format.", - "default": null, - "optional": true - }, - { - "name": "end_date", - "type": "Union[date, str]", - "description": "End date of the data, in YYYY-MM-DD format.", - "default": null, - "optional": true - }, - { "name": "provider", "type": "Literal['fmp']", "description": "The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default.", @@ -13503,7 +13489,15 @@ "optional": true } ], - "fmp": [] + "fmp": [ + { + "name": "year", + "type": "int", + "description": "Year of the compensation.", + "default": null, + "optional": true + } + ] }, "returns": { "OBBject": [ @@ -13551,84 +13545,99 @@ "optional": true }, { - "name": "filing_date", - "type": "date", - "description": "Date of the filing.", - "default": "", - "optional": false - }, - { - "name": "accepted_date", - "type": "datetime", - "description": "Date the filing was accepted.", - "default": "", - "optional": false + "name": "company_name", + "type": "str", + "description": "The name of the company.", + "default": null, + "optional": true }, { - "name": "name_and_position", + "name": "industry", "type": "str", - "description": "Name and position of the executive.", - "default": "", - "optional": false + "description": "The industry of the company.", + "default": null, + "optional": true }, { "name": "year", "type": "int", "description": "Year of the compensation.", - "default": "", - "optional": false + "default": null, + "optional": true + }, + { + "name": "name_and_position", + "type": "str", + "description": "Name and position.", + "default": null, + "optional": true }, { "name": "salary", - "type": "float", - "description": "Salary of the executive.", - "default": "", - "optional": false + "type": "Annotated[float, Ge(ge=0)]", + "description": "Salary.", + "default": null, + "optional": true }, { "name": "bonus", - "type": "float", - "description": "Bonus of the executive.", - "default": "", - "optional": false + "type": "Annotated[float, Ge(ge=0)]", + "description": "Bonus payments.", + "default": null, + "optional": true }, { "name": "stock_award", - "type": "float", - "description": "Stock award of the executive.", - "default": "", - "optional": false + "type": "Annotated[float, Ge(ge=0)]", + "description": "Stock awards.", + "default": null, + "optional": true }, { "name": "incentive_plan_compensation", - "type": "float", - "description": "Incentive plan compensation of the executive.", - "default": "", - "optional": false + "type": "Annotated[float, Ge(ge=0)]", + "description": "Incentive plan compensation.", + "default": null, + "optional": true }, { "name": "all_other_compensation", - "type": "float", - "description": "All other compensation of the executive.", - "default": "", - "optional": false + "type": "Annotated[float, Ge(ge=0)]", + "description": "All other compensation.", + "default": null, + "optional": true }, { "name": "total", - "type": "float", - "description": "Total compensation of the executive.", - "default": "", - "optional": false + "type": "Annotated[float, Ge(ge=0)]", + "description": "Total compensation.", + "default": null, + "optional": true + } + ], + "fmp": [ + { + "name": "filing_date", + "type": "date", + "description": "Date of the filing.", + "default": null, + "optional": true + }, + { + "name": "accepted_date", + "type": "datetime", + "description": "Date the filing was accepted.", + "default": null, + "optional": true }, { "name": "url", "type": "str", - "description": "URL of the filing data.", - "default": "", - "optional": false + "description": "URL to the filing data.", + "default": null, + "optional": true } - ], - "fmp": [] + ] |