mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-06 09:22:26 +00:00
removing access to extra/metadata and use designated private attrs instead
This commit is contained in:
@@ -396,6 +396,10 @@ class StaticCommandRunner:
|
||||
if Env().DEBUG_MODE:
|
||||
raise OpenBBError(e) from e
|
||||
|
||||
# pylint: disable=protected-access
|
||||
obbject._route = route
|
||||
obbject._standard_params = kwargs.get("standard_params", None)
|
||||
|
||||
return obbject
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ from typing import (
|
||||
|
||||
import pandas as pd
|
||||
from numpy import ndarray
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, Field, PrivateAttr
|
||||
|
||||
from openbb_core.app.model.abstract.error import OpenBBError
|
||||
from openbb_core.app.model.abstract.tagged import Tagged
|
||||
@@ -40,6 +40,10 @@ T = TypeVar("T")
|
||||
class OBBject(Tagged, Generic[T]):
|
||||
"""OpenBB object."""
|
||||
|
||||
accessors: ClassVar[Set[str]] = set()
|
||||
_user_settings: ClassVar[Optional[BaseModel]] = None
|
||||
_system_settings: ClassVar[Optional[BaseModel]] = None
|
||||
|
||||
results: Optional[T] = Field(
|
||||
default=None,
|
||||
description="Serializable results.",
|
||||
@@ -60,10 +64,12 @@ class OBBject(Tagged, Generic[T]):
|
||||
default_factory=dict,
|
||||
description="Extra info.",
|
||||
)
|
||||
_user_settings: ClassVar[Optional[BaseModel]] = None
|
||||
_system_settings: ClassVar[Optional[BaseModel]] = None
|
||||
|
||||
accessors: ClassVar[Set[str]] = set()
|
||||
_route: Optional[str] = PrivateAttr(
|
||||
default=None,
|
||||
)
|
||||
_standard_params: Optional[Dict[str, Any]] = PrivateAttr(
|
||||
default_factory=dict,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""Human readable representation of the object."""
|
||||
|
||||
@@ -62,18 +62,14 @@ class Charting:
|
||||
|
||||
def show(self, **kwargs):
|
||||
"""Display chart and save it to the OBBject."""
|
||||
# TODO: in order for this to perform, either metadata can't be a user preference
|
||||
# or this need to be done differently, perhaps add the params and the route to
|
||||
# OBBject private attributes at the CommandRunner level.
|
||||
|
||||
route = self._obbject.extra["metadata"].route
|
||||
standard_params = self._obbject.extra["metadata"].arguments["standard_params"]
|
||||
|
||||
charting_function = self._get_chart_function(route)
|
||||
|
||||
charting_function = self._get_chart_function(
|
||||
self._obbject._route # pylint: disable=protected-access
|
||||
)
|
||||
kwargs["obbject_item"] = self._obbject.results
|
||||
kwargs["charting_settings"] = self._charting_settings
|
||||
kwargs["standard_params"] = standard_params
|
||||
kwargs[
|
||||
"standard_params"
|
||||
] = self._obbject._standard_params # pylint: disable=protected-access
|
||||
|
||||
fig, content = charting_function(**kwargs)
|
||||
self._obbject.chart = Chart(
|
||||
|
||||
Reference in New Issue
Block a user