From 9bdc0f140744a6c58ae0695b60abcc332028c219 Mon Sep 17 00:00:00 2001 From: Danglewood <85772166+deeleeramone@users.noreply.github.com> Date: Thu, 9 May 2024 12:57:06 -0700 Subject: [PATCH 1/2] fix fmp (#6383) Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> --- .../openbb_fmp/models/crypto_historical.py | 2 +- .../openbb_fmp/models/currency_historical.py | 5 +-- .../test_fmp_crypto_historical_fetcher.yaml | 4 +-- .../test_fmp_currency_historical_fetcher.yaml | 31 ++++++++++--------- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/openbb_platform/providers/fmp/openbb_fmp/models/crypto_historical.py b/openbb_platform/providers/fmp/openbb_fmp/models/crypto_historical.py index ad528255c0df..9b94a92727bf 100644 --- a/openbb_platform/providers/fmp/openbb_fmp/models/crypto_historical.py +++ b/openbb_platform/providers/fmp/openbb_fmp/models/crypto_historical.py @@ -100,7 +100,7 @@ def get_url_params(symbol: str) -> str: url_params = f"{symbol}?{query_str}&apikey={api_key}" url = f"{base_url}/historical-chart/{interval}/{url_params}" if interval == "1day": - url = f"{base_url}/historical-price-full/crypto/{url_params}" + url = f"{base_url}/historical-price-full/{url_params}" return url symbols = query.symbol.split(",") diff --git a/openbb_platform/providers/fmp/openbb_fmp/models/currency_historical.py b/openbb_platform/providers/fmp/openbb_fmp/models/currency_historical.py index 697c3d0395db..58565d1edeb4 100644 --- a/openbb_platform/providers/fmp/openbb_fmp/models/currency_historical.py +++ b/openbb_platform/providers/fmp/openbb_fmp/models/currency_historical.py @@ -98,7 +98,7 @@ def get_url_params(symbol: str) -> str: url_params = f"{symbol}?{query_str}&apikey={api_key}" url = f"{base_url}/historical-chart/{interval}/{url_params}" if interval == "1day": - url = f"{base_url}/historical-price-full/forex/{url_params}" + url = f"{base_url}/historical-price-full/{url_params}" return url symbols = query.symbol.split(",") @@ -108,11 +108,8 @@ def get_url_params(symbol: str) -> str: async def get_one(symbol): """Get data for one symbol.""" - url = get_url_params(symbol) - data = [] - response = await amake_request(url, **kwargs) if isinstance(response, dict) and response.get("Error Message"): diff --git a/openbb_platform/providers/fmp/tests/record/http/test_fmp_fetchers/test_fmp_crypto_historical_fetcher.yaml b/openbb_platform/providers/fmp/tests/record/http/test_fmp_fetchers/test_fmp_crypto_historical_fetcher.yaml index 7d0757a15903..bb4feb0994a8 100644 --- a/openbb_platform/providers/fmp/tests/record/http/test_fmp_fetchers/test_fmp_crypto_historical_fetcher.yaml +++ b/openbb_platform/providers/fmp/tests/record/http/test_fmp_fetchers/test_fmp_crypto_historical_fetcher.yaml @@ -9,7 +9,7 @@ interactions: Connection: - keep-alive method: GET - uri: https://financialmodelingprep.com/api/v3/historical-price-full/crypto/BTCUSD?apikey=MOCK_API_KEY&from=2023-01-01&interval=1d&to=2023-01-10 + uri: https://financialmodelingprep.com/api/v3/historical-price-full/BTCUSD?apikey=MOCK_API_KEY&from=2023-01-01&interval=1d&to=2023-01-10 response: body: string: !!binary | @@ -48,7 +48,7 @@ interactions: Content-Type: - application/json; charset=utf-8 Date: - - Thu, 29 Feb 2024 04:42:50 GMT + - Thu, 09 May 2024 15:33:03 GMT Etag: - W/"ee3-iGBRI0WlQUT/ED3Q3GcS73lQbMw" Server: diff --git a/openbb_platform/providers/fmp/tests/record/http/test_fmp_fetchers/test_fmp_currency_historical_fetcher.yaml b/openbb_platform/providers/fmp/tests/record/http/test_fmp_fetchers/test_fmp_currency_historical_fetcher.yaml index 756dd1d34608..4b14b56c092d 100644 --- a/openbb_platform/providers/fmp/tests/record/http/test_fmp_fetchers/test_fmp_currency_historical_fetcher.yaml +++ b/openbb_platform/providers/fmp/tests/record/http/test_fmp_fetchers/test_fmp_currency_historical_fetcher.yaml @@ -9,22 +9,23 @@ interactions: Connection: - keep-alive method: GET - uri: https://financialmodelingprep.com/api/v3/historical-price-full/forex/EURUSD?apikey=MOCK_API_KEY&from=2023-01-01&interval=1d&to=2023-01-10 + uri: https://financialmodelingprep.com/api/v3/historical-price-full/EURUSD?apikey=MOCK_API_KEY&from=2023-01-01&interval=1d&to=2023-01-10 response: body: string: !!binary | - H4sIAAAAAAAAA5WWPW/bMBCG9/wKwbNt3PFbWdsuXVq0TZeig2ILsQvbCvwVBEH+eynWFY/KSWY8 - eLj3fBQfv3rJl5uimByet/fNZnJbTD7dfbv7/nEybaur9eHY7NeLqlV++UpRvIRvry2rY932CxBy - BjhDCL8JWvNY77yGc7DSia68Wj+sLmVrZFfeNE+XqlBdcbFpDvWlbLTu6tXyzwciSYmu087N5rQN - igOHcYHTzv/qdDjWy58DHYtVtXto6zAHELYvfK33i3p3DLrQSkT9/FQ9Xh4l7qe6rwPKz9XuVO2f - C4RpIeSkN/TLud7/WG+7Vdu5oeN1Ok4aSp60iJQIaV1ypJEFLV3sTUEbbWT8IzvQon3suCwDuteR - gAbtegIFDVqBQmXexxrKDNb/R+fhdhxuY4hZCW4TyXa0Ddk/pS2GbU0kAlsLG7fOwk46EtgWsCdQ - 2EZb8i/lkXYZpMPcPMyGxaw4yh4+Q1mx6UF7U8pa+A+DeZQwDxfHjIymxMg+j63JYBvm5rHVHFst - /MuSCVc5EXsTunFnvcQAI+MOiYmtAxg3cdJBOaMaMTHOJZfLMT/eUtbXKaPMDGXF2hd0XJ8glgxi - jZK4iNoUhxhrZRwXFOiV0eOv19ExnrW+cm/yOkL2DbY0louKMdDqCuiwbhicB1uyflY6bonC1swJ - qAfSAoYy2VhLTs3IWpSqjKM41mlHkhu67Kc1DQ7t3673WlpetzSEuXmgBetqS040AtoxZ59G3tRq - 8OyDkty/ImdpaJ5wnNOOxNMoccTTOGdvdGOYRYahMfc+h+x9zt9DGciWu1/QF5Y61kTb9c1MpI6x - 9XeiUcRpQ5oawvTzJEkNobTlII8dgpgBGcLgf5z99++b178DE4NG0AwAAA== + H4sIAAAAAAAAA42WTW/bMAyG7/0VRs5JIerL0q7bLrts2NZdhh3cxGgyJHGRjxZF0f8+WUtNSmEc + 5ZADSVPWw1ev9XpTVZP9y+a+W08+VJPPd9/vfnyaTPvocrU/dLvVvOkzv0Okql7jf8gtmkPb10sh + 1UzADER8Jua6x3YbcnAraiX9EF6uHpancG3VEF53z6eoNHqIztfdvj3Fja2HeLP4+/FC6qlbHzd9 + QjpwHuPHbXjouD+0i18XKubLZvvQx8WtCPtxWeJbu5u320PMSwm1wSWfm8fTm+gaH1s3922k+aXZ + HpvdSwViWkk1yfp+fWp3P1ebYeG+dax4m47DFp6FLckrENjGI1aEDYCTobDpxDLYNDXAVtpasGOw + s4oEtjAwAlvo2mgh8PUJb0UUlOMWvgD3e/My4o4jbpWXHHErcLsDcassCocSp2PLiNMUEjdGezFK + PK1IiDuXj4ISd0rW5EQNuK3HOZ3jdgW4Y+cy1pZlrVEGiNpaHACS1qyP0NqUs5Hhdw4aQ5yF8Hhh + zDwgYESORMwjbG0B29i3jK3h2BoJLFxNLO0drna8cSRnIcWbpIhx+HAkRmWcVlDOAPVl0HAbzI0M + G0GbWpKTecbaXGcNsXUZa83qWAD3SbQKGJc2oFnYycByLZMUgV0Lj8RY2EnFAHsWD68wWQZph4Lw + iUE3JrRtTfZ0RltfoR1X7luX0VassjW5IFDa5LuDtLXAbVBp05Fl0qYppO2MIK042mlFYiHG5N5C + PcRIpciSCNuNObS6rmwRO5exlqyyrWZZO8WxBs+adDKwTNmau+z1JAHVeYE15Po96QtG/HoWfCR4 + IHfbs0Jh+Jy2LFA2xN5luIHF7T1r2p677lnt2ctHMrNM2jQ14A4o/aiy04LURhTpyNiIklpxrm1r + N3bZgwLaIvb+Tzv8/7l5+wf35VDF+AwAAA== headers: Access-Control-Allow-Credentials: - 'true' @@ -44,9 +45,9 @@ interactions: Content-Type: - application/json; charset=utf-8 Date: - - Thu, 29 Feb 2024 04:42:50 GMT + - Thu, 09 May 2024 15:33:04 GMT Etag: - - W/"cd0-Rv/ywzhqPUdb7KJ/ZDpUXIC8K1A" + - W/"cf8-QiT4ARSPwS2WpuJ8xk9gvh9vqrg" Server: - nginx/1.18.0 (Ubuntu) Transfer-Encoding: From 83476ada465dbb3fd249922859ef11621a3e313e Mon Sep 17 00:00:00 2001 From: Henrique Joaquim Date: Thu, 9 May 2024 23:55:54 +0100 Subject: [PATCH 2/2] [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> --- .../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..cf74f75c87ac 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: # 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 @@ async def run( except Exception as e: if Env().DEBUG_MODE: raise OpenBBError(e) from e + warn(str(e), OpenBBWarning) return obbject