mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-29 05:21:48 +00:00
rename provider interface property
This commit is contained in:
@@ -2,7 +2,6 @@ from pydantic import create_model
|
||||
|
||||
from openbb_core.app.provider_interface import get_provider_interface
|
||||
|
||||
|
||||
# Here we create the BaseModel from the provider required credentials.
|
||||
# This means that if a new provider extension is installed, the required
|
||||
# credentials will be automatically added to the Credentials model.
|
||||
@@ -12,12 +11,10 @@ class Config:
|
||||
validate_assignment = True
|
||||
|
||||
|
||||
required_credentials = get_provider_interface().credentials
|
||||
|
||||
Credentials = create_model( # type: ignore
|
||||
"Credentials",
|
||||
__config__=Config,
|
||||
**required_credentials,
|
||||
**get_provider_interface().required_credentials,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -52,8 +52,8 @@ class ProviderInterface:
|
||||
----------
|
||||
map : Dict[str, Dict[str, Dict[str, Any]]]
|
||||
Dictionary of provider information.
|
||||
credentials: Dict[str, Tuple[Optional[str], None]]
|
||||
Dictionary of credentials.
|
||||
required_credentials: Dict[str, Tuple[Optional[str], None]]
|
||||
Dictionary of required_credentials.
|
||||
model_providers : Dict[str, ProviderChoices]
|
||||
Dictionary of provider choices by model.
|
||||
params : Dict[str, Dict[str, Union[StandardParams, ExtraParams]]]
|
||||
@@ -79,7 +79,7 @@ class ProviderInterface:
|
||||
self.__params = self.__generate_params_dc()
|
||||
self.__data = self.__generate_data_dc()
|
||||
self.__merged_data = self.__merge_data_dc(self.__data)
|
||||
self.__credentials = self.__get_credentials()
|
||||
self.__required_credentials = self.__get_required_credentials()
|
||||
|
||||
@property
|
||||
def map(self) -> Dict[str, Dict[str, Dict[str, Any]]]:
|
||||
@@ -87,9 +87,9 @@ class ProviderInterface:
|
||||
return self.__map
|
||||
|
||||
@property
|
||||
def credentials(self) -> Dict[str, Tuple[Optional[str], None]]:
|
||||
"""Dictionary of credentials by provider."""
|
||||
return self.__credentials
|
||||
def required_credentials(self) -> Dict[str, Tuple[Optional[str], None]]:
|
||||
"""Dictionary of required credentials by provider."""
|
||||
return self.__required_credentials
|
||||
|
||||
@property
|
||||
def model_providers(self) -> Dict[str, ProviderChoices]:
|
||||
@@ -142,15 +142,15 @@ class ProviderInterface:
|
||||
return build_provider_registry(extensions_dict__)
|
||||
|
||||
@staticmethod
|
||||
def __get_credentials() -> Dict[str, Tuple[Optional[str], None]]:
|
||||
"""Get credentials."""
|
||||
credentials: Dict[str, Tuple[Optional[str], None]] = {}
|
||||
def __get_required_credentials() -> Dict[str, Tuple[Optional[str], None]]:
|
||||
"""Get required credentials."""
|
||||
required_credentials: Dict[str, Tuple[Optional[str], None]] = {}
|
||||
credentials_mapping = build_credentials_mapping()
|
||||
for provider_credentials in credentials_mapping.values():
|
||||
for credential in provider_credentials:
|
||||
credentials[credential] = (Optional[str], None)
|
||||
for credentials in credentials_mapping.values():
|
||||
for c in credentials:
|
||||
required_credentials[c] = (Optional[str], None)
|
||||
|
||||
return credentials
|
||||
return required_credentials
|
||||
|
||||
@staticmethod
|
||||
def __merge_fields(
|
||||
|
||||
@@ -12,6 +12,7 @@ from openbb_core.app.utils import df_to_basemodel
|
||||
class OpenBBError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def filter_call(func):
|
||||
@wraps(wrapped=func)
|
||||
def inner(*args, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user