From 92928edc9303f1072f721c7d24725189486b2f7a Mon Sep 17 00:00:00 2001 From: Patrick Huck Date: Fri, 4 Aug 2023 11:44:40 -0700 Subject: [PATCH] check df.plot attrs --- mpcontribs-client/mpcontribs/client/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mpcontribs-client/mpcontribs/client/__init__.py b/mpcontribs-client/mpcontribs/client/__init__.py index 7e3baa51e..41af925ea 100644 --- a/mpcontribs-client/mpcontribs/client/__init__.py +++ b/mpcontribs-client/mpcontribs/client/__init__.py @@ -14,6 +14,7 @@ import logging import datetime +from inspect import getfullargspec from math import isclose from semantic_version import Version from requests.exceptions import RequestException @@ -55,6 +56,7 @@ from pint.converters import ScaleConverter from pint.errors import DimensionalityError from tempfile import gettempdir +from plotly.express._chart_types import line as line_chart RETRIES = 3 MAX_WORKERS = 3 @@ -307,8 +309,9 @@ def display(self): """Display a plotly graph for the table if in IPython/Jupyter""" if _in_ipython(): try: - # TODO make sure that attrs only contains valid kwargs - return self.plot(**self.attrs) + allowed_kwargs = getfullargspec(line_chart).args + attrs = {k: v for k, v in self.attrs.items() if k in allowed_kwargs} + return self.plot(**attrs) except Exception as e: logger.error(f"Can't display table: {e}")