diff options
author | Henrique Joaquim <henriquecjoaquim@gmail.com> | 2024-05-09 23:55:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-09 22:55:54 +0000 |
commit | 83476ada465dbb3fd249922859ef11621a3e313e (patch) | |
tree | ebebe3e51202ceea94a6fbbbd6a08233437195c1 | |
parent | 9bdc0f140744a6c58ae0695b60abcc332028c219 (diff) |
[Feature] Update chart creation so it doesn't break the command execution (#6382)
* chart execution to not break the whole call
* pylint: disable=broad-exception-caught
---------
Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>
-rw-r--r-- | openbb_platform/core/openbb_core/app/command_runner.py | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/openbb_platform/core/openbb_core/app/command_runner.py b/openbb_platform/core/openbb_core/app/command_runner.py index 4d9985a2172..cf74f75c87a 100644 --- a/openbb_platform/core/openbb_core/app/command_runner.py +++ b/openbb_platform/core/openbb_core/app/command_runner.py @@ -304,31 +304,38 @@ class StaticCommandRunner: **kwargs, ) -> None: """Create a chart from the command output.""" - if "charting" not in obbject.accessors: - raise OpenBBError( - "Charting is not installed. Please install `openbb-charting`." - ) - chart_params = {} - extra_params = kwargs.get("extra_params", {}) - - if hasattr(extra_params, "__dict__") and hasattr(extra_params, "chart_params"): - chart_params = kwargs["extra_params"].__dict__.get("chart_params", {}) - elif isinstance(extra_params, dict) and "chart_params" in extra_params: - chart_params = kwargs["extra_params"].get("chart_params", {}) - - if "chart_params" in kwargs and kwargs["chart_params"] is not None: - chart_params.update(kwargs.pop("chart_params", {})) - - if ( - "kwargs" in kwargs - and "chart_params" in kwargs["kwargs"] - and kwargs["kwargs"].get("chart_params") is not None - ): - chart_params.update(kwargs.pop("kwargs", {}).get("chart_params", {})) - - if chart_params: - kwargs.update(chart_params) - obbject.charting.show(render=False, **kwargs) + try: + if "charting" not in obbject.accessors: + raise OpenBBError( + "Charting is not installed. Please install `openbb-charting`." + ) + chart_params = {} + extra_params = kwargs.get("extra_params", {}) + + if hasattr(extra_params, "__dict__") and hasattr( + extra_params, "chart_params" + ): + chart_params = kwargs["extra_params"].__dict__.get("chart_params", {}) + elif isinstance(extra_params, dict) and "chart_params" in extra_params: + chart_params = kwargs["extra_params"].get("chart_params", {}) + + if "chart_params" in kwargs and kwargs["chart_params"] is not None: + chart_params.update(kwargs.pop("chart_params", {})) + + if ( + "kwargs" in kwargs + and "chart_params" in kwargs["kwargs"] + and kwargs["kwargs"].get("chart_params") is not None + ): + chart_params.update(kwargs.pop("kwargs", {}).get("chart_params", {})) + + if chart_params: + kwargs.update(chart_params) + obbject.charting.show(render=False, **kwargs) + except Exception as e: # pylint: disable=broad-exception-caught + if Env().DEBUG_MODE: + raise OpenBBError(e) from e + warn(str(e), OpenBBWarning) # pylint: disable=R0913, R0914 @classmethod @@ -449,6 +456,7 @@ class StaticCommandRunner: except Exception as e: if Env().DEBUG_MODE: raise OpenBBError(e) from e + warn(str(e), OpenBBWarning) return obbject |