mirror of
https://github.com/clearml/clearml
synced 2025-06-26 18:16:07 +00:00
Allow to pass Plotly-style data_config to report_table
This commit is contained in:
parent
f9fa303091
commit
3ee6ddf835
@ -615,7 +615,7 @@ class Reporter(InterfaceBase, AbstractContextManager, SetupUploadMixin, AsyncMan
|
|||||||
nan_as_null=False,
|
nan_as_null=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
def report_table(self, title, series, table, iteration, layout_config=None):
|
def report_table(self, title, series, table, iteration, layout_config=None, data_config=None):
|
||||||
"""
|
"""
|
||||||
Report a table plot.
|
Report a table plot.
|
||||||
|
|
||||||
@ -629,8 +629,10 @@ class Reporter(InterfaceBase, AbstractContextManager, SetupUploadMixin, AsyncMan
|
|||||||
:type iteration: int
|
:type iteration: int
|
||||||
:param layout_config: optional dictionary for layout configuration, passed directly to plotly
|
:param layout_config: optional dictionary for layout configuration, passed directly to plotly
|
||||||
:type layout_config: dict or None
|
:type layout_config: dict or None
|
||||||
|
:param data_config: optional dictionary for data configuration, like column width, passed directly to plotly
|
||||||
|
:type data_config: dict or None
|
||||||
"""
|
"""
|
||||||
table_output = create_plotly_table(table, title, series, layout_config=layout_config)
|
table_output = create_plotly_table(table, title, series, layout_config=layout_config, data_config=data_config)
|
||||||
return self.report_plot(
|
return self.report_plot(
|
||||||
title=self._normalize_name(title),
|
title=self._normalize_name(title),
|
||||||
series=self._normalize_name(series),
|
series=self._normalize_name(series),
|
||||||
|
@ -306,6 +306,7 @@ class Logger(object):
|
|||||||
csv=None, # type: Optional[str]
|
csv=None, # type: Optional[str]
|
||||||
url=None, # type: Optional[str]
|
url=None, # type: Optional[str]
|
||||||
extra_layout=None, # type: Optional[dict]
|
extra_layout=None, # type: Optional[dict]
|
||||||
|
extra_data=None, # type: Optional[dict]
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
For explicit report, report a table plot.
|
For explicit report, report a table plot.
|
||||||
@ -337,7 +338,27 @@ class Logger(object):
|
|||||||
:param url: A URL to the location of csv file.
|
:param url: A URL to the location of csv file.
|
||||||
:param extra_layout: optional dictionary for layout configuration, passed directly to plotly
|
:param extra_layout: optional dictionary for layout configuration, passed directly to plotly
|
||||||
See full details on the supported configuration: https://plotly.com/javascript/reference/layout/
|
See full details on the supported configuration: https://plotly.com/javascript/reference/layout/
|
||||||
example: extra_layout={'height': 600}
|
For example:
|
||||||
|
|
||||||
|
.. code block:: py
|
||||||
|
logger.report_table(
|
||||||
|
title='table example',
|
||||||
|
series='pandas DataFrame',
|
||||||
|
iteration=0,
|
||||||
|
table_plot=df,
|
||||||
|
extra_layout={'height': 600})
|
||||||
|
|
||||||
|
:param extra_data: optional dictionary for data configuration, like column width, passed directly to plotly
|
||||||
|
See full details on the supported configuration: https://plotly.com/javascript/reference/table/
|
||||||
|
For example:
|
||||||
|
|
||||||
|
.. code block:: py
|
||||||
|
logger.report_table(
|
||||||
|
title='table example',
|
||||||
|
series='pandas DataFrame',
|
||||||
|
iteration=0,
|
||||||
|
table_plot=df,
|
||||||
|
extra_data={'columnwidth': [2., 1., 1., 1.]})
|
||||||
"""
|
"""
|
||||||
mutually_exclusive(
|
mutually_exclusive(
|
||||||
UsageError, _check_none=True,
|
UsageError, _check_none=True,
|
||||||
@ -373,6 +394,7 @@ class Logger(object):
|
|||||||
table=reporter_table,
|
table=reporter_table,
|
||||||
iteration=iteration or 0,
|
iteration=iteration or 0,
|
||||||
layout_config=extra_layout,
|
layout_config=extra_layout,
|
||||||
|
data_config=extra_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
def report_line_plot(
|
def report_line_plot(
|
||||||
|
@ -482,7 +482,7 @@ def plotly_scatter3d_layout_dict(title="Scatter", xaxis_title="X", yaxis_title="
|
|||||||
return plotly_object
|
return plotly_object
|
||||||
|
|
||||||
|
|
||||||
def create_plotly_table(table_plot, title, series, layout_config=None):
|
def create_plotly_table(table_plot, title, series, layout_config=None, data_config=None):
|
||||||
"""
|
"""
|
||||||
Create a basic Plotly table json style to be sent
|
Create a basic Plotly table json style to be sent
|
||||||
|
|
||||||
@ -492,6 +492,7 @@ def create_plotly_table(table_plot, title, series, layout_config=None):
|
|||||||
:param series: Series (AKA variant)
|
:param series: Series (AKA variant)
|
||||||
:type series: str
|
:type series: str
|
||||||
:param layout_config: additional configuration layout
|
:param layout_config: additional configuration layout
|
||||||
|
:param data_config: additional configuration for the data
|
||||||
:return: dict with plotly data.
|
:return: dict with plotly data.
|
||||||
"""
|
"""
|
||||||
is_list = isinstance(table_plot, (list, tuple))
|
is_list = isinstance(table_plot, (list, tuple))
|
||||||
@ -545,4 +546,7 @@ def create_plotly_table(table_plot, title, series, layout_config=None):
|
|||||||
if layout_config:
|
if layout_config:
|
||||||
ret["layout"] = merge_dicts(ret["layout"], layout_config)
|
ret["layout"] = merge_dicts(ret["layout"], layout_config)
|
||||||
|
|
||||||
|
if data_config and len(ret["data"]) == 1:
|
||||||
|
ret["data"][0] = merge_dicts(ret["data"][0], data_config)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
Loading…
Reference in New Issue
Block a user