mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-13 12:51:49 +00:00
[V5] openbb-charting: Refactor for V5 and Decouple (#7545)
* refactor charting for v5 patterns and decouple entirely * coveragerc * lint and tests * fix tests * configure dev group with openbb-technical * ty * fix cli test * remove 3.15 from test matrix - dependencies are unstable --------- Co-authored-by: deeleeramone <>
This commit is contained in:
@@ -137,14 +137,36 @@ class Session(metaclass=SingletonMeta):
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def _resolve_backend_class() -> Any:
|
||||
"""Resolve the charting backend class, honoring overrides and the engine.
|
||||
|
||||
Prefers a backend registered under the ``openbb_charting_backend``
|
||||
entry-point group, otherwise asks the resolved charting engine for its
|
||||
built-in backend, so the CLI never depends on ``openbb_charting`` by name.
|
||||
"""
|
||||
from openbb_core.app.charting import (
|
||||
ChartingManager,
|
||||
get_charting_backend_class,
|
||||
)
|
||||
|
||||
backend_class = get_charting_backend_class()
|
||||
if backend_class is not None:
|
||||
return backend_class
|
||||
|
||||
engine = ChartingManager.get_charting_class()
|
||||
getter = getattr(engine, "get_backend_class", None) if engine else None
|
||||
return getter() if callable(getter) else None
|
||||
|
||||
def _build_backend(self) -> Any:
|
||||
try:
|
||||
from openbb_charting.core.backend import ( # ty: ignore[unresolved-import]
|
||||
Backend,
|
||||
)
|
||||
from openbb_core.app.model.charts.charting_settings import ChartingSettings
|
||||
|
||||
return Backend(
|
||||
backend_class = self._resolve_backend_class()
|
||||
if backend_class is None:
|
||||
return None
|
||||
|
||||
return backend_class(
|
||||
ChartingSettings(
|
||||
system_settings=self._obb.system,
|
||||
user_settings=self._obb.user,
|
||||
|
||||
Reference in New Issue
Block a user