diff options
author | Diogo Sousa <montezdesousa@gmail.com> | 2024-05-23 11:32:22 +0100 |
---|---|---|
committer | Diogo Sousa <montezdesousa@gmail.com> | 2024-05-23 11:32:22 +0100 |
commit | e8e3bff83579adc1af57bc4b99b6071baa3f62e6 (patch) | |
tree | d358bb90e9c91621af25fc4f146304261d93e416 | |
parent | 4771f32bd3cb54743592bfcaab1bfe22f44abb9b (diff) |
fix: detailed error message
4 files changed, 67 insertions, 60 deletions
diff --git a/openbb_platform/core/openbb_core/app/static/container.py b/openbb_platform/core/openbb_core/app/static/container.py index 9bb8004e305..bcabe6507a2 100644 --- a/openbb_platform/core/openbb_core/app/static/container.py +++ b/openbb_platform/core/openbb_core/app/static/container.py @@ -24,11 +24,11 @@ class Container: return obbject return getattr(obbject, "to_" + output_type)() - def _check_credentials(self, provider: str) -> bool: + def _check_credentials(self, provider: str) -> Optional[bool]: """Check required credentials are populated.""" credentials = self._command_runner.user_settings.credentials if provider not in credentials.origins: - return False + return None required = credentials.origins.get(provider) return all(getattr(credentials, r, None) for r in required) @@ -37,8 +37,8 @@ class Container: ) -> str: """Get the provider to use in execution. - If no choice is specified, the configured fallback is used. A provider is used - when its required credentials are populated. + If no choice is specified, the configured priority list is used. A provider is used + when all of its required credentials are populated. Parameters ---------- @@ -47,7 +47,7 @@ class Container: command: str The command to get the provider for, for example 'equity.price.historical' default_priority: Tuple[str, ...] - A tuple of available providers for the given command to use as default fallback. + A tuple of available providers for the given command to use as default priority list. Returns ------- @@ -57,17 +57,26 @@ class Container: Raises ------ OpenBBError - Raises error when all the providers in the fallback failed. + Raises error when all the providers in the priority list failed. """ if choice is None: commands = self._command_runner.user_settings.defaults.commands providers = ( commands.get(command, {}).get("provider", []) or default_priority ) + tries = [] for p in providers: - if self._check_credentials(p): + result = self._check_credentials(p) + if result: return p + elif result is False: + tries.append((p, "missing credentials")) + else: + tries.append((p, "not found")) + + msg = "\n ".join([f"* '{pair[0]}' -> {pair[1]}" for pair in tries]) raise OpenBBError( - f"Fallback failed, please specify the provider or update credentials. Tried: {', '.join(providers)}." + f"Provider fallback failed, please specify the provider or update credentials.\n" + f"[Providers]\n {msg}" ) return choice diff --git a/openbb_platform/openbb/assets/reference.json b/openbb_platform/openbb/assets/reference.json index bb1b9e77042..2c503641db7 100644 --- a/openbb_platform/openbb/assets/reference.json +++ b/openbb_platform/openbb/assets/reference.json @@ -1,36 +1,36 @@ { - "openbb": "4.2.1", + "openbb": "4.2.0", "info": { "title": "OpenBB Platform (Python)", "description": "Investment research for everyone, anywhere.", - "core": "1.2.3", + "core": "1.2.2", "extensions": { "openbb_core_extension": [ - "commodity@1.1.1", - "crypto@1.2.1", - "currency@1.2.1", - "derivatives@1.2.1", - "economy@1.2.1", - "equity@1.2.1", - "etf@1.2.1", - "fixedincome@1.2.1", - "index@1.2.1", - "news@1.2.1", - "regulators@1.2.1" + "commodity@1.1.0", + "crypto@1.2.0", + "currency@1.2.0", + "derivatives@1.2.0", + "economy@1.2.0", + "equity@1.2.0", + "etf@1.2.0", + "fixedincome@1.2.0", + "index@1.2.0", + "news@1.2.0", + "regulators@1.2.0" ], "openbb_provider_extension": [ - "benzinga@1.2.1", - "econdb@1.1.1", - "federal_reserve@1.2.1", - "fmp@1.2.1", - "fred@1.2.1", - "intrinio@1.2.1", - "oecd@1.2.1", - "polygon@1.2.1", - "sec@1.2.1", - "tiingo@1.2.1", - "tradingeconomics@1.2.1", - "yfinance@1.2.1" + "benzinga@1.2.0", + "econdb@1.1.0", + "federal_reserve@1.2.0", + "fmp@1.2.0", + "fred@1.2.0", + "intrinio@1.2.0", + "oecd@1.2.0", + "polygon@1.2.0", + "sec@1.2.0", + "tiingo@1.2.0", + "tradingeconomics@1.2.0", + "yfinance@1.2.0" ], "openbb_obbject_extension": [] } diff --git a/openbb_platform/openbb/package/__extensions__.py b/openbb_platform/openbb/package/__extensions__.py index 4de5adcdba6..e6bd5cbbe47 100644 --- a/openbb_platform/openbb/package/__extensions__.py +++ b/openbb_platform/openbb/package/__extensions__.py @@ -20,30 +20,30 @@ Routers: /regulators Extensions: - - commodity@1.1.1 - - crypto@1.2.1 - - currency@1.2.1 - - derivatives@1.2.1 - - economy@1.2.1 - - equity@1.2.1 - - etf@1.2.1 - - fixedincome@1.2.1 - - index@1.2.1 - - news@1.2.1 - - regulators@1.2.1 - - - benzinga@1.2.1 - - econdb@1.1.1 - - federal_reserve@1.2.1 - - fmp@1.2.1 - - fred@1.2.1 - - intrinio@1.2.1 - - oecd@1.2.1 - - polygon@1.2.1 - - sec@1.2.1 - - tiingo@1.2.1 - - tradingeconomics@1.2.1 - - yfinance@1.2.1 """ + - commodity@1.1.0 + - crypto@1.2.0 + - currency@1.2.0 + - derivatives@1.2.0 + - economy@1.2.0 + - equity@1.2.0 + - etf@1.2.0 + - fixedincome@1.2.0 + - index@1.2.0 + - news@1.2.0 + - regulators@1.2.0 + + - benzinga@1.2.0 + - econdb@1.1.0 + - federal_reserve@1.2.0 + - fmp@1.2.0 + - fred@1.2.0 + - intrinio@1.2.0 + - oecd@1.2.0 + - polygon@1.2.0 + - sec@1.2.0 + - tiingo@1.2.0 + - tradingeconomics@1.2.0 + - yfinance@1.2.0 """ # fmt: on def __repr__(self) -> str: diff --git a/openbb_platform/openbb/package/fixedincome_government.py b/openbb_platform/openbb/package/fixedincome_government.py index ff9a2997fbb..533cf2c1ce8 100644 --- a/openbb_platform/openbb/package/fixedincome_government.py +++ b/openbb_platform/openbb/package/fixedincome_government.py @@ -237,9 +237,7 @@ class ROUTER_fixedincome_government(Container): date : Union[str, None, List[Optional[str]]] A specific date to get data for. By default is the current data. Multiple comma separated items allowed for provider(s): econdb, federal_reserve, fmp, fred. provider : Optional[Literal['econdb', 'federal_reserve', 'fmp', 'fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'econdb' if there is - no default. + The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: econdb, federal_reserve, fmp, fred. country : Literal['australia', 'canada', 'china', 'hong_kong', 'india', 'japan', 'mexico', 'new_zealand', 'russia', 'saudi_arabia', 'singapore', 'south_africa', 'south_korea', 'taiwan', 'thailand', 'united_kingdom', 'united_states'] The country to get data. New Zealand, Mexico, Singapore, and Thailand have only monthly data. The nearest date to the requested one will be used. (provider: econdb) use_cache : bool |