mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-03 16:02:04 +00:00
add executor query arg
This commit is contained in:
@@ -2,7 +2,6 @@ from dataclasses import dataclass, make_dataclass
|
||||
from typing import Any, Dict, List, Literal, Optional, Tuple, Union
|
||||
|
||||
from fastapi import Query
|
||||
from openbb_provider.query_executor import QueryExecutor
|
||||
from openbb_provider.registry_map import RegistryMap
|
||||
from pydantic import BaseConfig, BaseModel, Extra, Field, create_model
|
||||
from pydantic.fields import ModelField
|
||||
@@ -74,7 +73,6 @@ class ProviderInterface:
|
||||
"""Initialize provider interface."""
|
||||
self._registry_map = registry_map or RegistryMap()
|
||||
self._map = self._registry_map.map
|
||||
# self._map = build_model_mapping()
|
||||
self._model_providers_map = self._generate_model_providers_dc()
|
||||
self._params = self._generate_params_dc()
|
||||
self._data = self._generate_data_dc()
|
||||
@@ -130,10 +128,6 @@ class ProviderInterface:
|
||||
"""List of model names."""
|
||||
return self._registry_map.models
|
||||
|
||||
def create_executor(self) -> QueryExecutor:
|
||||
"""Get query executor."""
|
||||
return QueryExecutor(self._registry_map.registry)
|
||||
|
||||
def _get_required_credentials(self) -> List[str]:
|
||||
"""Get required credentials."""
|
||||
return self._registry_map.required_credentials
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import warnings
|
||||
from dataclasses import asdict
|
||||
from typing import Any, Dict
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from openbb_core.app.model.abstract.warning import OpenBBWarning
|
||||
from openbb_core.app.model.command_context import CommandContext
|
||||
@@ -12,6 +12,7 @@ from openbb_core.app.provider_interface import (
|
||||
StandardParams,
|
||||
get_provider_interface,
|
||||
)
|
||||
from openbb_provider.query_executor import QueryExecutor
|
||||
|
||||
|
||||
class Query:
|
||||
@@ -23,12 +24,14 @@ class Query:
|
||||
provider_choices: ProviderChoices,
|
||||
standard_params: StandardParams,
|
||||
extra_params: ExtraParams,
|
||||
executor: Optional[QueryExecutor] = None,
|
||||
) -> None:
|
||||
self.cc = cc
|
||||
self.provider = str(provider_choices.provider)
|
||||
self.standard_params = standard_params
|
||||
self.extra_params = extra_params
|
||||
self.name = self.standard_params.__class__.__name__
|
||||
self.executor = executor or QueryExecutor()
|
||||
|
||||
@staticmethod
|
||||
def filter_extra_params(
|
||||
@@ -60,7 +63,6 @@ class Query:
|
||||
|
||||
def execute(self) -> Any:
|
||||
"""Execute the query."""
|
||||
executor = get_provider_interface().create_executor()
|
||||
standard_dict = asdict(self.standard_params)
|
||||
extra_dict = (
|
||||
self.filter_extra_params(self.extra_params, self.provider)
|
||||
@@ -68,7 +70,7 @@ class Query:
|
||||
else {}
|
||||
)
|
||||
|
||||
return executor.execute(
|
||||
return self.executor.execute(
|
||||
provider_name=self.provider,
|
||||
model_name=self.name,
|
||||
params={**standard_dict, **extra_dict},
|
||||
|
||||
Reference in New Issue
Block a user