From f9b475a34dafb84fa19a1c39ab3a59620f49edd7 Mon Sep 17 00:00:00 2001 From: hjoaquim Date: Wed, 8 May 2024 14:32:00 +0100 Subject: [PATCH 1/2] chart execution to not break the whole call --- .../core/openbb_core/app/command_runner.py | 58 +++++++++++-------- 1 file 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 4d9985a2172c..ad23cca7a2e2 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 @@ def _chart( **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: + if Env().DEBUG_MODE: + raise OpenBBError(e) from e + warn(str(e), OpenBBWarning) # pylint: disable=R0913, R0914 @classmethod @@ -449,6 +456,7 @@ async def run( except Exception as e: if Env().DEBUG_MODE: raise OpenBBError(e) from e + warn(str(e), OpenBBWarning) return obbject From 56198cc8a8a72108c495c50e0b7daaaf398c9d44 Mon Sep 17 00:00:00 2001 From: hjoaquim Date: Thu, 9 May 2024 14:22:24 +0100 Subject: [PATCH 2/2] pylint: disable=broad-exception-caught --- openbb_platform/core/openbb_core/app/command_runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbb_platform/core/openbb_core/app/command_runner.py b/openbb_platform/core/openbb_core/app/command_runner.py index ad23cca7a2e2..cf74f75c87ac 100644 --- a/openbb_platform/core/openbb_core/app/command_runner.py +++ b/openbb_platform/core/openbb_core/app/command_runner.py @@ -332,7 +332,7 @@ def _chart( if chart_params: kwargs.update(chart_params) obbject.charting.show(render=False, **kwargs) - except Exception as e: + except Exception as e: # pylint: disable=broad-exception-caught if Env().DEBUG_MODE: raise OpenBBError(e) from e warn(str(e), OpenBBWarning)