From d438a2154c7af8460b739d245c135f2f40327829 Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Wed, 17 Jul 2024 16:39:25 -0400 Subject: [PATCH 01/24] Created an Intake Source for DataframePlotDataSource for reading Dataframe Plot visualizations --- rubicon_ml/intake_rubicon/__init__.py | 4 ++- rubicon_ml/intake_rubicon/publish.py | 50 ++++++++++++++++++--------- rubicon_ml/intake_rubicon/viz.py | 23 +++++++++++- setup.cfg | 1 + tests/unit/intake_rubicon/test_viz.py | 27 +++++++++++++++ ~/.nvm/nvm-exec | 1 + ~/.nvm/nvm.sh | 1 + 7 files changed, 88 insertions(+), 19 deletions(-) create mode 120000 ~/.nvm/nvm-exec create mode 120000 ~/.nvm/nvm.sh diff --git a/rubicon_ml/intake_rubicon/__init__.py b/rubicon_ml/intake_rubicon/__init__.py index 936d4a68..126d97d2 100644 --- a/rubicon_ml/intake_rubicon/__init__.py +++ b/rubicon_ml/intake_rubicon/__init__.py @@ -2,5 +2,7 @@ from rubicon_ml.intake_rubicon.experiment import ExperimentSource from rubicon_ml.intake_rubicon.viz import ExperimentsTableDataSource +from rubicon_ml.intake_rubicon.viz import DataframePlotDataSource -__all__ = ["ExperimentSource", "ExperimentsTableDataSource"] + +__all__ = ["ExperimentSource", "ExperimentsTableDataSource", "DataframePlotDataSource"] diff --git a/rubicon_ml/intake_rubicon/publish.py b/rubicon_ml/intake_rubicon/publish.py index a7142a14..394750d0 100644 --- a/rubicon_ml/intake_rubicon/publish.py +++ b/rubicon_ml/intake_rubicon/publish.py @@ -1,16 +1,17 @@ -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING, Optional, Union import fsspec import yaml if TYPE_CHECKING: from rubicon_ml.viz.experiments_table import ExperimentsTable + from rubicon_ml.viz import DataframePlot def publish( experiments, # visualization object passed, defaulted to None - visualization_object: Optional["ExperimentsTable"] = None, + visualization_object: Optional[Union[DataframePlot,ExperimentsTable]] = None, output_filepath=None, base_catalog_filepath=None, ): @@ -132,20 +133,35 @@ def _build_catalog(experiments, visualization): # create visualization entry to the catalog file if visualization is not None: - appended_visualization_catalog = { - "driver": "rubicon_ml_experiment_table", - "args": { - "is_selectable": visualization.is_selectable, - "metric_names": visualization.metric_names, - "metric_query_tags": visualization.metric_query_tags, - "metric_query_type": visualization.metric_query_type, - "parameter_names": visualization.parameter_names, - "parameter_query_tags": visualization.parameter_query_tags, - "parameter_query_type": visualization.parameter_query_type, - }, - } - - # append visualization object to end of catalog file - catalog["sources"]["experiment_table"] = appended_visualization_catalog + # vizualization is an ExperimentsTable + if isinstance(visualization,ExperimentsTable): + appended_visualization_catalog = { + "driver": "rubicon_ml_experiment_table", + "args": { + "is_selectable": visualization.is_selectable, + "metric_names": visualization.metric_names, + "metric_query_tags": visualization.metric_query_tags, + "metric_query_type": visualization.metric_query_type, + "parameter_names": visualization.parameter_names, + "parameter_query_tags": visualization.parameter_query_tags, + "parameter_query_type": visualization.parameter_query_type, + }, + } + # append visualization object to end of catalog file + catalog["sources"]["experiment_table"] = appended_visualization_catalog + + # vizualization is an DataframePlot + if isinstance(visualization,DataframePlot): + appended_visualization_catalog = { + "driver": "rubicon_ml_dataframe_plot", + "args": { + "dataframe_name": visualization.dataframe_name, + "x": visualization.x, + "y": visualization.y, + } + } + + # append visualization object to end of catalog file + catalog["sources"]["dataframe_plot"] = appended_visualization_catalog return catalog diff --git a/rubicon_ml/intake_rubicon/viz.py b/rubicon_ml/intake_rubicon/viz.py index dbda152a..fbf79a3b 100644 --- a/rubicon_ml/intake_rubicon/viz.py +++ b/rubicon_ml/intake_rubicon/viz.py @@ -1,6 +1,6 @@ from rubicon_ml import __version__ from rubicon_ml.intake_rubicon.base import VizDataSourceMixin - +from rubicon_ml.viz import DataframePlot class ExperimentsTableDataSource(VizDataSourceMixin): """An Intake data source for reading `rubicon` Experiment Table visualizations.""" @@ -22,3 +22,24 @@ def _get_schema(self): self._visualization_object = ExperimentsTable(**self._catalog_data) return super()._get_schema() + + +class DataframePlotDataSource(VizDataSourceMixin): + """An Intake data source for reading `rubicon` Dataframe Plot visualizations.""" + + version = __version__ + + container = "python" + name = "rubicon_ml_dataframe_plot" + + def __init__(self, metadata=None, **catalog_data): + self._catalog_data = catalog_data or {} + + super().__init__(metadata=metadata) + + def _get_schema(self): + """Creates an Experiments Table visualization and sets it as the visualization object attribute""" + print(self._catalog_data) + self._visualization_object = DataframePlot(**self._catalog_data) + + return super()._get_schema() diff --git a/setup.cfg b/setup.cfg index 753a6605..9682d4cf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -62,6 +62,7 @@ console_scripts = intake.drivers = rubicon_ml_experiment = rubicon_ml.intake_rubicon.experiment:ExperimentSource rubicon_ml_experiment_table = rubicon_ml.intake_rubicon.viz:ExperimentsTableDataSource + rubicon_ml_dataframe_plot = rubicon_ml.intake_rubicon.viz:DataframePlotDataSource [versioneer] vcs = git diff --git a/tests/unit/intake_rubicon/test_viz.py b/tests/unit/intake_rubicon/test_viz.py index 1623eb26..809eaa5a 100644 --- a/tests/unit/intake_rubicon/test_viz.py +++ b/tests/unit/intake_rubicon/test_viz.py @@ -1,6 +1,7 @@ import os from rubicon_ml.intake_rubicon.viz import ExperimentsTableDataSource +from rubicon_ml.intake_rubicon.viz import DataframePlotDataSource root = os.path.dirname(__file__) @@ -33,3 +34,29 @@ def test_experiments_table_source(): assert visualization.parameter_query_type == catalog_data_sample["parameter_query_type"] source.close() + + +def test_datatable_plot_source(): + catalog_data_sample = { + "experiments": None, + "plotting_func": None, + "plotting_func_kwargs": None, + "x": None, + "y": None + } + + source = DataframePlotDataSource(catalog_data_sample) + assert source is not None + + source.discover() + + visualization = source.read() + + assert visualization is not None + assert visualization.experiments == catalog_data_sample["experiments"] + assert visualization.plotting_func == catalog_data_sample["plotting_func"] + assert visualization.plotting_func_kwargs == catalog_data_sample["plotting_func_kwargs"] + assert visualization.x == catalog_data_sample["x"] + assert visualization.y == catalog_data_sample["y"] + + source.close() \ No newline at end of file diff --git a/~/.nvm/nvm-exec b/~/.nvm/nvm-exec new file mode 120000 index 00000000..e2d79682 --- /dev/null +++ b/~/.nvm/nvm-exec @@ -0,0 +1 @@ +/opt/homebrew/opt/nvm/libexec/nvm-exec \ No newline at end of file diff --git a/~/.nvm/nvm.sh b/~/.nvm/nvm.sh new file mode 120000 index 00000000..3d91048c --- /dev/null +++ b/~/.nvm/nvm.sh @@ -0,0 +1 @@ +/opt/homebrew/opt/nvm/libexec/nvm.sh \ No newline at end of file From ca45344677a09e07e18d8e972794104fd8e9ad9a Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Thu, 18 Jul 2024 12:17:08 -0400 Subject: [PATCH 02/24] fixing typing errors --- rubicon_ml/intake_rubicon/publish.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rubicon_ml/intake_rubicon/publish.py b/rubicon_ml/intake_rubicon/publish.py index 394750d0..e6c1b7a9 100644 --- a/rubicon_ml/intake_rubicon/publish.py +++ b/rubicon_ml/intake_rubicon/publish.py @@ -11,7 +11,7 @@ def publish( experiments, # visualization object passed, defaulted to None - visualization_object: Optional[Union[DataframePlot,ExperimentsTable]] = None, + visualization_object: Optional[Union["DataframePlot","ExperimentsTable"]] = None, output_filepath=None, base_catalog_filepath=None, ): @@ -103,6 +103,8 @@ def _update_catalog( def _build_catalog(experiments, visualization): + from rubicon_ml.viz.experiments_table import ExperimentsTable + from rubicon_ml.viz import DataframePlot """Helper function to build catalog dictionary from given experiments. Parameters From a3d353d8198852797f0d92c0b2f6d5bc689ef59d Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Thu, 18 Jul 2024 13:46:13 -0400 Subject: [PATCH 03/24] update styling issues --- rubicon_ml/intake_rubicon/__init__.py | 7 ++++--- rubicon_ml/intake_rubicon/publish.py | 13 +++++++------ rubicon_ml/intake_rubicon/viz.py | 3 ++- tests/unit/intake_rubicon/test_viz.py | 18 ++++++++++-------- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/rubicon_ml/intake_rubicon/__init__.py b/rubicon_ml/intake_rubicon/__init__.py index 126d97d2..f96b82e5 100644 --- a/rubicon_ml/intake_rubicon/__init__.py +++ b/rubicon_ml/intake_rubicon/__init__.py @@ -1,8 +1,9 @@ import intake # noqa F401 from rubicon_ml.intake_rubicon.experiment import ExperimentSource -from rubicon_ml.intake_rubicon.viz import ExperimentsTableDataSource -from rubicon_ml.intake_rubicon.viz import DataframePlotDataSource - +from rubicon_ml.intake_rubicon.viz import ( + DataframePlotDataSource, + ExperimentsTableDataSource, +) __all__ = ["ExperimentSource", "ExperimentsTableDataSource", "DataframePlotDataSource"] diff --git a/rubicon_ml/intake_rubicon/publish.py b/rubicon_ml/intake_rubicon/publish.py index e6c1b7a9..c3df8049 100644 --- a/rubicon_ml/intake_rubicon/publish.py +++ b/rubicon_ml/intake_rubicon/publish.py @@ -4,14 +4,14 @@ import yaml if TYPE_CHECKING: - from rubicon_ml.viz.experiments_table import ExperimentsTable from rubicon_ml.viz import DataframePlot + from rubicon_ml.viz.experiments_table import ExperimentsTable def publish( experiments, # visualization object passed, defaulted to None - visualization_object: Optional[Union["DataframePlot","ExperimentsTable"]] = None, + visualization_object: Optional[Union["DataframePlot", "ExperimentsTable"]] = None, output_filepath=None, base_catalog_filepath=None, ): @@ -103,8 +103,9 @@ def _update_catalog( def _build_catalog(experiments, visualization): - from rubicon_ml.viz.experiments_table import ExperimentsTable from rubicon_ml.viz import DataframePlot + from rubicon_ml.viz.experiments_table import ExperimentsTable + """Helper function to build catalog dictionary from given experiments. Parameters @@ -136,7 +137,7 @@ def _build_catalog(experiments, visualization): # create visualization entry to the catalog file if visualization is not None: # vizualization is an ExperimentsTable - if isinstance(visualization,ExperimentsTable): + if isinstance(visualization, ExperimentsTable): appended_visualization_catalog = { "driver": "rubicon_ml_experiment_table", "args": { @@ -153,14 +154,14 @@ def _build_catalog(experiments, visualization): catalog["sources"]["experiment_table"] = appended_visualization_catalog # vizualization is an DataframePlot - if isinstance(visualization,DataframePlot): + if isinstance(visualization, DataframePlot): appended_visualization_catalog = { "driver": "rubicon_ml_dataframe_plot", "args": { "dataframe_name": visualization.dataframe_name, "x": visualization.x, "y": visualization.y, - } + }, } # append visualization object to end of catalog file diff --git a/rubicon_ml/intake_rubicon/viz.py b/rubicon_ml/intake_rubicon/viz.py index fbf79a3b..860b8396 100644 --- a/rubicon_ml/intake_rubicon/viz.py +++ b/rubicon_ml/intake_rubicon/viz.py @@ -2,6 +2,7 @@ from rubicon_ml.intake_rubicon.base import VizDataSourceMixin from rubicon_ml.viz import DataframePlot + class ExperimentsTableDataSource(VizDataSourceMixin): """An Intake data source for reading `rubicon` Experiment Table visualizations.""" @@ -41,5 +42,5 @@ def _get_schema(self): """Creates an Experiments Table visualization and sets it as the visualization object attribute""" print(self._catalog_data) self._visualization_object = DataframePlot(**self._catalog_data) - + return super()._get_schema() diff --git a/tests/unit/intake_rubicon/test_viz.py b/tests/unit/intake_rubicon/test_viz.py index 809eaa5a..35aea04a 100644 --- a/tests/unit/intake_rubicon/test_viz.py +++ b/tests/unit/intake_rubicon/test_viz.py @@ -1,7 +1,9 @@ import os -from rubicon_ml.intake_rubicon.viz import ExperimentsTableDataSource -from rubicon_ml.intake_rubicon.viz import DataframePlotDataSource +from rubicon_ml.intake_rubicon.viz import ( + DataframePlotDataSource, + ExperimentsTableDataSource, +) root = os.path.dirname(__file__) @@ -38,11 +40,11 @@ def test_experiments_table_source(): def test_datatable_plot_source(): catalog_data_sample = { - "experiments": None, - "plotting_func": None, - "plotting_func_kwargs": None, - "x": None, - "y": None + "experiments": None, + "plotting_func": None, + "plotting_func_kwargs": None, + "x": None, + "y": None, } source = DataframePlotDataSource(catalog_data_sample) @@ -59,4 +61,4 @@ def test_datatable_plot_source(): assert visualization.x == catalog_data_sample["x"] assert visualization.y == catalog_data_sample["y"] - source.close() \ No newline at end of file + source.close() From 0b6a15a1360464e4ccc1f15d022163b068264ac3 Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Thu, 18 Jul 2024 13:57:10 -0400 Subject: [PATCH 04/24] update environment.yml --- environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment.yml b/environment.yml index b0a76b8a..39717025 100644 --- a/environment.yml +++ b/environment.yml @@ -45,7 +45,7 @@ dependencies: - versioneer # for packaging - - setuptools + - setuptools<71.0.0 - wheel # for edgetest From dae7f498b9ea9498166f2d81252e56f4c7f9f38d Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Thu, 18 Jul 2024 14:01:14 -0400 Subject: [PATCH 05/24] remove nvm files --- ~/.nvm/nvm-exec | 1 - ~/.nvm/nvm.sh | 1 - 2 files changed, 2 deletions(-) delete mode 120000 ~/.nvm/nvm-exec delete mode 120000 ~/.nvm/nvm.sh diff --git a/~/.nvm/nvm-exec b/~/.nvm/nvm-exec deleted file mode 120000 index e2d79682..00000000 --- a/~/.nvm/nvm-exec +++ /dev/null @@ -1 +0,0 @@ -/opt/homebrew/opt/nvm/libexec/nvm-exec \ No newline at end of file diff --git a/~/.nvm/nvm.sh b/~/.nvm/nvm.sh deleted file mode 120000 index 3d91048c..00000000 --- a/~/.nvm/nvm.sh +++ /dev/null @@ -1 +0,0 @@ -/opt/homebrew/opt/nvm/libexec/nvm.sh \ No newline at end of file From 6e2c4ac17a9deb69373e99f92606dfc3e746db41 Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Thu, 18 Jul 2024 14:10:29 -0400 Subject: [PATCH 06/24] update test_viz.py for dataframe test --- tests/unit/intake_rubicon/test_viz.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/unit/intake_rubicon/test_viz.py b/tests/unit/intake_rubicon/test_viz.py index 35aea04a..3dfe5afa 100644 --- a/tests/unit/intake_rubicon/test_viz.py +++ b/tests/unit/intake_rubicon/test_viz.py @@ -38,8 +38,9 @@ def test_experiments_table_source(): source.close() -def test_datatable_plot_source(): +def test_dataframe_plot_source(): catalog_data_sample = { + "dataframe_name": None, "experiments": None, "plotting_func": None, "plotting_func_kwargs": None, From b9d0b910776dcc5a8d79b83ba3a247ceb233ff43 Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Thu, 18 Jul 2024 14:20:28 -0400 Subject: [PATCH 07/24] update parameters in test_viz.py for dataframe test --- tests/unit/intake_rubicon/test_viz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/intake_rubicon/test_viz.py b/tests/unit/intake_rubicon/test_viz.py index 3dfe5afa..8c2f8376 100644 --- a/tests/unit/intake_rubicon/test_viz.py +++ b/tests/unit/intake_rubicon/test_viz.py @@ -40,7 +40,7 @@ def test_experiments_table_source(): def test_dataframe_plot_source(): catalog_data_sample = { - "dataframe_name": None, + "dataframe_name": "dataframe_name", "experiments": None, "plotting_func": None, "plotting_func_kwargs": None, From 73beb271b17115082d840c877b2bbb8081359c77 Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Wed, 17 Jul 2024 16:39:25 -0400 Subject: [PATCH 08/24] merging branch to main --- rubicon_ml/intake_rubicon/__init__.py | 1 + rubicon_ml/intake_rubicon/publish.py | 18 +++++++++++++++++- rubicon_ml/intake_rubicon/viz.py | 26 +++++++++++++++++++++++--- setup.cfg | 1 + tests/unit/intake_rubicon/test_viz.py | 1 + ~/.nvm/nvm-exec | 1 + ~/.nvm/nvm.sh | 1 + 7 files changed, 45 insertions(+), 4 deletions(-) create mode 120000 ~/.nvm/nvm-exec create mode 120000 ~/.nvm/nvm.sh diff --git a/rubicon_ml/intake_rubicon/__init__.py b/rubicon_ml/intake_rubicon/__init__.py index 3ea2161e..f7bc9915 100644 --- a/rubicon_ml/intake_rubicon/__init__.py +++ b/rubicon_ml/intake_rubicon/__init__.py @@ -4,6 +4,7 @@ from rubicon_ml.intake_rubicon.viz import ( ExperimentsTableDataSource, MetricCorrelationPlotDataSource, + DataframePlotDataSource ) __all__ = [ diff --git a/rubicon_ml/intake_rubicon/publish.py b/rubicon_ml/intake_rubicon/publish.py index e925a092..150d46a9 100644 --- a/rubicon_ml/intake_rubicon/publish.py +++ b/rubicon_ml/intake_rubicon/publish.py @@ -6,11 +6,12 @@ if TYPE_CHECKING: from rubicon_ml.viz.experiments_table import ExperimentsTable from rubicon_ml.viz.metric_correlation_plot import MetricCorrelationPlot + from rubicon_ml.viz import DataframePlot def publish( experiments, - visualization_object: Optional[Union["ExperimentsTable", "MetricCorrelationPlot"]] = None, + visualization_object: Optional[Union["ExperimentsTable", "MetricCorrelationPlot", "DataframePlot"]] = None, output_filepath=None, base_catalog_filepath=None, ): @@ -149,6 +150,7 @@ def _build_catalog(experiments, visualization): }, } catalog["sources"]["experiment_table"] = appended_visualization_catalog + if isinstance(visualization, MetricCorrelationPlot): appended_visualization_catalog = { "driver": "rubicon_ml_metric_correlation_plot", @@ -160,6 +162,20 @@ def _build_catalog(experiments, visualization): } catalog["sources"]["metric_correlation_plot"] = appended_visualization_catalog + # vizualization is an DataframePlot + if isinstance(visualization,DataframePlot): + appended_visualization_catalog = { + "driver": "rubicon_ml_dataframe_plot", + "args": { + "dataframe_name": visualization.dataframe_name, + "x": visualization.x, + "y": visualization.y, + } + } + + # append visualization object to end of catalog file + catalog["sources"]["dataframe_plot"] = appended_visualization_catalog + # append visualization object to end of catalog file return catalog diff --git a/rubicon_ml/intake_rubicon/viz.py b/rubicon_ml/intake_rubicon/viz.py index 79b81935..d1a49562 100644 --- a/rubicon_ml/intake_rubicon/viz.py +++ b/rubicon_ml/intake_rubicon/viz.py @@ -1,6 +1,8 @@ from rubicon_ml import __version__ from rubicon_ml.intake_rubicon.base import VizDataSourceMixin from rubicon_ml.viz import MetricCorrelationPlot +from rubicon_ml.viz import DataframePlot +from rubicon_ml.viz import ExperimentsTable class ExperimentsTableDataSource(VizDataSourceMixin): @@ -18,7 +20,6 @@ def __init__(self, metadata=None, **catalog_data): def _get_schema(self): """Creates an Experiments Table visualization and sets it as the visualization object attribute""" - from rubicon_ml.viz import ExperimentsTable self._visualization_object = ExperimentsTable(**self._catalog_data) @@ -27,7 +28,6 @@ def _get_schema(self): class MetricCorrelationPlotDataSource(VizDataSourceMixin): """An Intake data source for reading `rubicon` Metric Correlation Plot visualizations.""" - version = __version__ container = "python" @@ -35,11 +35,31 @@ class MetricCorrelationPlotDataSource(VizDataSourceMixin): def __init__(self, metadata=None, **catalog_data): self._catalog_data = catalog_data or {} - print(self._catalog_data) super().__init__(metadata=metadata) def _get_schema(self): """Creates a Metric Correlation Plot visualization and sets it as the visualization object attribute""" self._visualization_object = MetricCorrelationPlot(**self._catalog_data) + + return super()._get_schema() + + +class DataframePlotDataSource(VizDataSourceMixin): + """An Intake data source for reading `rubicon` Dataframe Plot visualizations.""" + + version = __version__ + + container = "python" + name = "rubicon_ml_dataframe_plot" + + def __init__(self, metadata=None, **catalog_data): + self._catalog_data = catalog_data or {} + + super().__init__(metadata=metadata) + + def _get_schema(self): + """Creates a Dataframe Plot visualization and sets it as the visualization object attribute""" + self._visualization_object = DataframePlot(**self._catalog_data) + return super()._get_schema() diff --git a/setup.cfg b/setup.cfg index 626674d8..d3cc418d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -63,6 +63,7 @@ intake.drivers = rubicon_ml_experiment = rubicon_ml.intake_rubicon.experiment:ExperimentSource rubicon_ml_experiment_table = rubicon_ml.intake_rubicon.viz:ExperimentsTableDataSource rubicon_ml_metric_correlation_plot = rubicon_ml.intake_rubicon.viz:MetricCorrelationPlotDataSource + rubicon_ml_dataframe_plot = rubicon_ml.intake_rubicon.viz:DataframePlotDataSource [versioneer] vcs = git diff --git a/tests/unit/intake_rubicon/test_viz.py b/tests/unit/intake_rubicon/test_viz.py index 972326c4..59171255 100644 --- a/tests/unit/intake_rubicon/test_viz.py +++ b/tests/unit/intake_rubicon/test_viz.py @@ -3,6 +3,7 @@ from rubicon_ml.intake_rubicon.viz import ( ExperimentsTableDataSource, MetricCorrelationPlotDataSource, + DataframePlotDataSource ) root = os.path.dirname(__file__) diff --git a/~/.nvm/nvm-exec b/~/.nvm/nvm-exec new file mode 120000 index 00000000..e2d79682 --- /dev/null +++ b/~/.nvm/nvm-exec @@ -0,0 +1 @@ +/opt/homebrew/opt/nvm/libexec/nvm-exec \ No newline at end of file diff --git a/~/.nvm/nvm.sh b/~/.nvm/nvm.sh new file mode 120000 index 00000000..3d91048c --- /dev/null +++ b/~/.nvm/nvm.sh @@ -0,0 +1 @@ +/opt/homebrew/opt/nvm/libexec/nvm.sh \ No newline at end of file From da0e44fc50b88eaa511fd6a6ec1a7b1dbdf17dcf Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Thu, 18 Jul 2024 13:46:13 -0400 Subject: [PATCH 09/24] resolve merge conflicts --- rubicon_ml/intake_rubicon/__init__.py | 1 + rubicon_ml/intake_rubicon/publish.py | 4 ++-- rubicon_ml/intake_rubicon/viz.py | 3 ++- tests/unit/intake_rubicon/test_viz.py | 27 +++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/rubicon_ml/intake_rubicon/__init__.py b/rubicon_ml/intake_rubicon/__init__.py index f7bc9915..775fc278 100644 --- a/rubicon_ml/intake_rubicon/__init__.py +++ b/rubicon_ml/intake_rubicon/__init__.py @@ -11,4 +11,5 @@ "ExperimentSource", "ExperimentsTableDataSource", "MetricCorrelationPlotDataSource", + "DataframePlotDataSource" ] diff --git a/rubicon_ml/intake_rubicon/publish.py b/rubicon_ml/intake_rubicon/publish.py index 150d46a9..9ec6e5ea 100644 --- a/rubicon_ml/intake_rubicon/publish.py +++ b/rubicon_ml/intake_rubicon/publish.py @@ -163,14 +163,14 @@ def _build_catalog(experiments, visualization): catalog["sources"]["metric_correlation_plot"] = appended_visualization_catalog # vizualization is an DataframePlot - if isinstance(visualization,DataframePlot): + if isinstance(visualization, DataframePlot): appended_visualization_catalog = { "driver": "rubicon_ml_dataframe_plot", "args": { "dataframe_name": visualization.dataframe_name, "x": visualization.x, "y": visualization.y, - } + }, } # append visualization object to end of catalog file diff --git a/rubicon_ml/intake_rubicon/viz.py b/rubicon_ml/intake_rubicon/viz.py index d1a49562..66dd4488 100644 --- a/rubicon_ml/intake_rubicon/viz.py +++ b/rubicon_ml/intake_rubicon/viz.py @@ -5,6 +5,7 @@ from rubicon_ml.viz import ExperimentsTable + class ExperimentsTableDataSource(VizDataSourceMixin): """An Intake data source for reading `rubicon` Experiment Table visualizations.""" @@ -61,5 +62,5 @@ def __init__(self, metadata=None, **catalog_data): def _get_schema(self): """Creates a Dataframe Plot visualization and sets it as the visualization object attribute""" self._visualization_object = DataframePlot(**self._catalog_data) - + return super()._get_schema() diff --git a/tests/unit/intake_rubicon/test_viz.py b/tests/unit/intake_rubicon/test_viz.py index 59171255..2018eb37 100644 --- a/tests/unit/intake_rubicon/test_viz.py +++ b/tests/unit/intake_rubicon/test_viz.py @@ -59,3 +59,30 @@ def test_metric_correlation_plot_source(): assert visualization.selected_metric == catalog_data_sample["selected_metric"] source.close() + + +def test_datatable_plot_source(): + catalog_data_sample = { + "dataframe_name": "dataframe_name", + "experiments": None, + "plotting_func": None, + "plotting_func_kwargs": None, + "x": None, + "y": None, + } + + source = DataframePlotDataSource(catalog_data_sample) + assert source is not None + + source.discover() + + visualization = source.read() + + assert visualization is not None + assert visualization.experiments == catalog_data_sample["experiments"] + assert visualization.plotting_func == catalog_data_sample["plotting_func"] + assert visualization.plotting_func_kwargs == catalog_data_sample["plotting_func_kwargs"] + assert visualization.x == catalog_data_sample["x"] + assert visualization.y == catalog_data_sample["y"] + + source.close() From b715d0555b12d56a670041e7a4defa49e7324116 Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Thu, 18 Jul 2024 14:01:14 -0400 Subject: [PATCH 10/24] remove nvm files --- ~/.nvm/nvm-exec | 1 - ~/.nvm/nvm.sh | 1 - 2 files changed, 2 deletions(-) delete mode 120000 ~/.nvm/nvm-exec delete mode 120000 ~/.nvm/nvm.sh diff --git a/~/.nvm/nvm-exec b/~/.nvm/nvm-exec deleted file mode 120000 index e2d79682..00000000 --- a/~/.nvm/nvm-exec +++ /dev/null @@ -1 +0,0 @@ -/opt/homebrew/opt/nvm/libexec/nvm-exec \ No newline at end of file diff --git a/~/.nvm/nvm.sh b/~/.nvm/nvm.sh deleted file mode 120000 index 3d91048c..00000000 --- a/~/.nvm/nvm.sh +++ /dev/null @@ -1 +0,0 @@ -/opt/homebrew/opt/nvm/libexec/nvm.sh \ No newline at end of file From 9147bdf95d992335075a113f93cc4ce9b86d72f6 Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Thu, 18 Jul 2024 16:12:32 -0400 Subject: [PATCH 11/24] moved imports in viz.py and added dataframe plot tests in test_publish.py --- rubicon_ml/intake_rubicon/__init__.py | 4 +-- rubicon_ml/intake_rubicon/publish.py | 8 +++--- rubicon_ml/intake_rubicon/viz.py | 12 +++++---- tests/unit/intake_rubicon/test_publish.py | 30 +++++++++++++++++++++++ tests/unit/intake_rubicon/test_viz.py | 2 +- 5 files changed, 45 insertions(+), 11 deletions(-) diff --git a/rubicon_ml/intake_rubicon/__init__.py b/rubicon_ml/intake_rubicon/__init__.py index 775fc278..12695f5e 100644 --- a/rubicon_ml/intake_rubicon/__init__.py +++ b/rubicon_ml/intake_rubicon/__init__.py @@ -2,14 +2,14 @@ from rubicon_ml.intake_rubicon.experiment import ExperimentSource from rubicon_ml.intake_rubicon.viz import ( + DataframePlotDataSource, ExperimentsTableDataSource, MetricCorrelationPlotDataSource, - DataframePlotDataSource ) __all__ = [ "ExperimentSource", "ExperimentsTableDataSource", "MetricCorrelationPlotDataSource", - "DataframePlotDataSource" + "DataframePlotDataSource", ] diff --git a/rubicon_ml/intake_rubicon/publish.py b/rubicon_ml/intake_rubicon/publish.py index 3ecd9f27..cadc8b61 100644 --- a/rubicon_ml/intake_rubicon/publish.py +++ b/rubicon_ml/intake_rubicon/publish.py @@ -4,14 +4,16 @@ import yaml if TYPE_CHECKING: + from rubicon_ml.viz import DataframePlot from rubicon_ml.viz.experiments_table import ExperimentsTable from rubicon_ml.viz.metric_correlation_plot import MetricCorrelationPlot - from rubicon_ml.viz import DataframePlot def publish( experiments, - visualization_object: Optional[Union["ExperimentsTable", "MetricCorrelationPlot", "DataframePlot"]] = None, + visualization_object: Optional[ + Union["ExperimentsTable", "MetricCorrelationPlot", "DataframePlot"] + ] = None, output_filepath=None, base_catalog_filepath=None, ): @@ -103,8 +105,8 @@ def _update_catalog( def _build_catalog(experiments, visualization): - from rubicon_ml.viz.experiments_table import ExperimentsTable from rubicon_ml.viz import DataframePlot + from rubicon_ml.viz.experiments_table import ExperimentsTable from rubicon_ml.viz.metric_correlation_plot import MetricCorrelationPlot """Helper function to build catalog dictionary from given experiments. diff --git a/rubicon_ml/intake_rubicon/viz.py b/rubicon_ml/intake_rubicon/viz.py index 66dd4488..024f1a90 100644 --- a/rubicon_ml/intake_rubicon/viz.py +++ b/rubicon_ml/intake_rubicon/viz.py @@ -1,9 +1,5 @@ from rubicon_ml import __version__ from rubicon_ml.intake_rubicon.base import VizDataSourceMixin -from rubicon_ml.viz import MetricCorrelationPlot -from rubicon_ml.viz import DataframePlot -from rubicon_ml.viz import ExperimentsTable - class ExperimentsTableDataSource(VizDataSourceMixin): @@ -21,6 +17,7 @@ def __init__(self, metadata=None, **catalog_data): def _get_schema(self): """Creates an Experiments Table visualization and sets it as the visualization object attribute""" + from rubicon_ml.viz import ExperimentsTable self._visualization_object = ExperimentsTable(**self._catalog_data) @@ -29,6 +26,7 @@ def _get_schema(self): class MetricCorrelationPlotDataSource(VizDataSourceMixin): """An Intake data source for reading `rubicon` Metric Correlation Plot visualizations.""" + version = __version__ container = "python" @@ -41,8 +39,10 @@ def __init__(self, metadata=None, **catalog_data): def _get_schema(self): """Creates a Metric Correlation Plot visualization and sets it as the visualization object attribute""" + from rubicon_ml.viz import MetricCorrelationPlot + self._visualization_object = MetricCorrelationPlot(**self._catalog_data) - + return super()._get_schema() @@ -61,6 +61,8 @@ def __init__(self, metadata=None, **catalog_data): def _get_schema(self): """Creates a Dataframe Plot visualization and sets it as the visualization object attribute""" + from rubicon_ml.viz import DataframePlot + self._visualization_object = DataframePlot(**self._catalog_data) return super()._get_schema() diff --git a/tests/unit/intake_rubicon/test_publish.py b/tests/unit/intake_rubicon/test_publish.py index 3370a64d..e03caf9a 100644 --- a/tests/unit/intake_rubicon/test_publish.py +++ b/tests/unit/intake_rubicon/test_publish.py @@ -2,6 +2,7 @@ import yaml from rubicon_ml import Rubicon, publish +from rubicon_ml.viz.dataframe_plot import DataframePlot from rubicon_ml.viz.experiments_table import ExperimentsTable from rubicon_ml.viz.metric_correlation_plot import MetricCorrelationPlot @@ -67,6 +68,35 @@ def test_publish(project_client): ) assert catalog["sources"]["metric_correlation_plot"] is not None + # Dataframe Plot + + visualization_object = DataframePlot() + catalog_yaml = publish(project.experiments(), visualization_object) + catalog = yaml.safe_load(catalog_yaml) + + assert f"experiment_{experiment.id.replace('-', '_')}" in catalog["sources"] + assert ( + "rubicon_ml_experiment" + == catalog["sources"][f"experiment_{experiment.id.replace('-', '_')}"]["driver"] + ) + assert ( + experiment.repository.root_dir + == catalog["sources"][f"experiment_{experiment.id.replace('-', '_')}"]["args"]["urlpath"] + ) + assert ( + experiment.id + == catalog["sources"][f"experiment_{experiment.id.replace('-', '_')}"]["args"][ + "experiment_id" + ] + ) + assert ( + project.name + == catalog["sources"][f"experiment_{experiment.id.replace('-', '_')}"]["args"][ + "project_name" + ] + ) + assert catalog["sources"]["dataframe_plot"] is not None + def test_publish_from_multiple_sources(): rubicon_a = Rubicon(persistence="memory", root_dir="path/a") diff --git a/tests/unit/intake_rubicon/test_viz.py b/tests/unit/intake_rubicon/test_viz.py index 2018eb37..2933f3c1 100644 --- a/tests/unit/intake_rubicon/test_viz.py +++ b/tests/unit/intake_rubicon/test_viz.py @@ -1,9 +1,9 @@ import os from rubicon_ml.intake_rubicon.viz import ( + DataframePlotDataSource, ExperimentsTableDataSource, MetricCorrelationPlotDataSource, - DataframePlotDataSource ) root = os.path.dirname(__file__) From a01c3e96f80e432dc59956f351b4f1c1bbd89410 Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Thu, 18 Jul 2024 17:52:59 -0400 Subject: [PATCH 12/24] add dataframe argumentfor publish tests --- tests/unit/intake_rubicon/test_publish.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/intake_rubicon/test_publish.py b/tests/unit/intake_rubicon/test_publish.py index e03caf9a..f7691bf5 100644 --- a/tests/unit/intake_rubicon/test_publish.py +++ b/tests/unit/intake_rubicon/test_publish.py @@ -70,7 +70,7 @@ def test_publish(project_client): # Dataframe Plot - visualization_object = DataframePlot() + visualization_object = DataframePlot(dataframe_name="test_dataframe") catalog_yaml = publish(project.experiments(), visualization_object) catalog = yaml.safe_load(catalog_yaml) From 9095c8413976ff423723b4ec3c075602175f4f02 Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Fri, 19 Jul 2024 09:38:33 -0400 Subject: [PATCH 13/24] debugging test_viz.py --- tests/unit/intake_rubicon/test_viz.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/unit/intake_rubicon/test_viz.py b/tests/unit/intake_rubicon/test_viz.py index 2933f3c1..eee0aaf2 100644 --- a/tests/unit/intake_rubicon/test_viz.py +++ b/tests/unit/intake_rubicon/test_viz.py @@ -71,7 +71,14 @@ def test_datatable_plot_source(): "y": None, } - source = DataframePlotDataSource(catalog_data_sample) + source = DataframePlotDataSource( + dataframe_name="dataframe_name", + experiments=None, + plotting_func=None, + plotting_func_kwargs=None, + x=None, + y=None, + ) assert source is not None source.discover() @@ -79,6 +86,7 @@ def test_datatable_plot_source(): visualization = source.read() assert visualization is not None + assert visualization.experiments == catalog_data_sample["dataframe_name"] assert visualization.experiments == catalog_data_sample["experiments"] assert visualization.plotting_func == catalog_data_sample["plotting_func"] assert visualization.plotting_func_kwargs == catalog_data_sample["plotting_func_kwargs"] From 823d7752d704618f0d483c2be120846e08e80583 Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Fri, 19 Jul 2024 10:19:44 -0400 Subject: [PATCH 14/24] removed experiments check in test_viz --- tests/unit/intake_rubicon/test_viz.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/unit/intake_rubicon/test_viz.py b/tests/unit/intake_rubicon/test_viz.py index eee0aaf2..d519be00 100644 --- a/tests/unit/intake_rubicon/test_viz.py +++ b/tests/unit/intake_rubicon/test_viz.py @@ -86,8 +86,7 @@ def test_datatable_plot_source(): visualization = source.read() assert visualization is not None - assert visualization.experiments == catalog_data_sample["dataframe_name"] - assert visualization.experiments == catalog_data_sample["experiments"] + assert visualization.dataframe_name == catalog_data_sample["dataframe_name"] assert visualization.plotting_func == catalog_data_sample["plotting_func"] assert visualization.plotting_func_kwargs == catalog_data_sample["plotting_func_kwargs"] assert visualization.x == catalog_data_sample["x"] From 9c639ba13619d8a83ba7fd8e4e6b4b7a1680adb0 Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Mon, 22 Jul 2024 11:11:40 -0400 Subject: [PATCH 15/24] Created an intake source for MetricListComparisonDataSource for reading Metric List Comparison visualizations --- rubicon_ml/intake_rubicon/__init__.py | 2 ++ rubicon_ml/intake_rubicon/publish.py | 20 ++++++++++++++- rubicon_ml/intake_rubicon/viz.py | 22 +++++++++++++++++ rubicon_ml/viz/metric_lists_comparison.py | 4 +-- setup.cfg | 1 + tests/unit/intake_rubicon/test_publish.py | 30 +++++++++++++++++++++++ tests/unit/intake_rubicon/test_viz.py | 18 ++++++++++++++ 7 files changed, 94 insertions(+), 3 deletions(-) diff --git a/rubicon_ml/intake_rubicon/__init__.py b/rubicon_ml/intake_rubicon/__init__.py index 12695f5e..30c3a338 100644 --- a/rubicon_ml/intake_rubicon/__init__.py +++ b/rubicon_ml/intake_rubicon/__init__.py @@ -5,6 +5,7 @@ DataframePlotDataSource, ExperimentsTableDataSource, MetricCorrelationPlotDataSource, + MetricListComparisonDataSource, ) __all__ = [ @@ -12,4 +13,5 @@ "ExperimentsTableDataSource", "MetricCorrelationPlotDataSource", "DataframePlotDataSource", + "MetricListComparisonDataSource", ] diff --git a/rubicon_ml/intake_rubicon/publish.py b/rubicon_ml/intake_rubicon/publish.py index cadc8b61..ca7f2ae8 100644 --- a/rubicon_ml/intake_rubicon/publish.py +++ b/rubicon_ml/intake_rubicon/publish.py @@ -7,12 +7,13 @@ from rubicon_ml.viz import DataframePlot from rubicon_ml.viz.experiments_table import ExperimentsTable from rubicon_ml.viz.metric_correlation_plot import MetricCorrelationPlot + from rubicon_ml.viz.metric_lists_comparison import MetricListsComparison def publish( experiments, visualization_object: Optional[ - Union["ExperimentsTable", "MetricCorrelationPlot", "DataframePlot"] + Union["ExperimentsTable", "MetricCorrelationPlot", "DataframePlot", "MetricListsComparison"] ] = None, output_filepath=None, base_catalog_filepath=None, @@ -108,6 +109,7 @@ def _build_catalog(experiments, visualization): from rubicon_ml.viz import DataframePlot from rubicon_ml.viz.experiments_table import ExperimentsTable from rubicon_ml.viz.metric_correlation_plot import MetricCorrelationPlot + from rubicon_ml.viz.metric_lists_comparison import MetricListsComparison """Helper function to build catalog dictionary from given experiments. @@ -181,4 +183,20 @@ def _build_catalog(experiments, visualization): # append visualization object to end of catalog file + # vizualization is an MetricListsComparison + if isinstance(visualization, MetricListsComparison): + appended_visualization_catalog = { + "driver": "rubicon_ml_metric_list", + "args": { + "column_names": visualization.column_names, + "experiments": visualization.experiments, + "selected_metric": visualization.selected_metric, + }, + } + + # append visualization object to end of catalog file + catalog["sources"]["metric_list"] = appended_visualization_catalog + + # append visualization object to end of catalog file + return catalog diff --git a/rubicon_ml/intake_rubicon/viz.py b/rubicon_ml/intake_rubicon/viz.py index 024f1a90..6713f78a 100644 --- a/rubicon_ml/intake_rubicon/viz.py +++ b/rubicon_ml/intake_rubicon/viz.py @@ -66,3 +66,25 @@ def _get_schema(self): self._visualization_object = DataframePlot(**self._catalog_data) return super()._get_schema() + + +class MetricListComparisonDataSource(VizDataSourceMixin): + """An Intake data source for reading `rubicon` Metric List Comparison visualizations.""" + + version = __version__ + + container = "python" + name = "rubicon_ml_metric_list" + + def __init__(self, metadata=None, **catalog_data): + self._catalog_data = catalog_data or {} + + super().__init__(metadata=metadata) + + def _get_schema(self): + """Creates a Dataframe Plot visualization and sets it as the visualization object attribute""" + from rubicon_ml.viz import MetricListsComparison + + self._visualization_object = MetricListsComparison(**self._catalog_data) + + return super()._get_schema() diff --git a/rubicon_ml/viz/metric_lists_comparison.py b/rubicon_ml/viz/metric_lists_comparison.py index ad11b51c..b0e6a2f9 100644 --- a/rubicon_ml/viz/metric_lists_comparison.py +++ b/rubicon_ml/viz/metric_lists_comparison.py @@ -78,7 +78,7 @@ def load_experiment_data(self): for experiment in self.experiments: for metric in experiment.metrics(): - if isinstance(metric.value, list): + if isinstance(metric.value, float): self.metric_names.add(metric.name) experiment_record = self.experiment_records.get(experiment.id, {}) @@ -154,7 +154,7 @@ def update_metric_heatmap(*args): data_array = np.array(heatmap_data) numerator = data_array - data_array.min(axis=0) - denominator = data_array.max(axis=0) - data_array.min(axis=0) + denominator = np.array(data_array.max(axis=0) - data_array.min(axis=0)) denominator[denominator == 0] = 1 scaled_heatmap_data = numerator / denominator diff --git a/setup.cfg b/setup.cfg index d3cc418d..dc51eb0f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -64,6 +64,7 @@ intake.drivers = rubicon_ml_experiment_table = rubicon_ml.intake_rubicon.viz:ExperimentsTableDataSource rubicon_ml_metric_correlation_plot = rubicon_ml.intake_rubicon.viz:MetricCorrelationPlotDataSource rubicon_ml_dataframe_plot = rubicon_ml.intake_rubicon.viz:DataframePlotDataSource + rubicon_ml_metric_list = rubicon_ml.intake_rubicon.viz:MetricListComparisonDataSource [versioneer] vcs = git diff --git a/tests/unit/intake_rubicon/test_publish.py b/tests/unit/intake_rubicon/test_publish.py index f7691bf5..ecdfb14f 100644 --- a/tests/unit/intake_rubicon/test_publish.py +++ b/tests/unit/intake_rubicon/test_publish.py @@ -5,6 +5,7 @@ from rubicon_ml.viz.dataframe_plot import DataframePlot from rubicon_ml.viz.experiments_table import ExperimentsTable from rubicon_ml.viz.metric_correlation_plot import MetricCorrelationPlot +from rubicon_ml.viz.metric_lists_comparison import MetricListsComparison def test_publish(project_client): @@ -97,6 +98,35 @@ def test_publish(project_client): ) assert catalog["sources"]["dataframe_plot"] is not None + # MetricListComparison + + visualization_object = MetricListsComparison() + catalog_yaml = publish(project.experiments(), visualization_object) + catalog = yaml.safe_load(catalog_yaml) + + assert f"experiment_{experiment.id.replace('-', '_')}" in catalog["sources"] + assert ( + "rubicon_ml_experiment" + == catalog["sources"][f"experiment_{experiment.id.replace('-', '_')}"]["driver"] + ) + assert ( + experiment.repository.root_dir + == catalog["sources"][f"experiment_{experiment.id.replace('-', '_')}"]["args"]["urlpath"] + ) + assert ( + experiment.id + == catalog["sources"][f"experiment_{experiment.id.replace('-', '_')}"]["args"][ + "experiment_id" + ] + ) + assert ( + project.name + == catalog["sources"][f"experiment_{experiment.id.replace('-', '_')}"]["args"][ + "project_name" + ] + ) + assert catalog["sources"]["metric_list"] is not None + def test_publish_from_multiple_sources(): rubicon_a = Rubicon(persistence="memory", root_dir="path/a") diff --git a/tests/unit/intake_rubicon/test_viz.py b/tests/unit/intake_rubicon/test_viz.py index d519be00..25d79657 100644 --- a/tests/unit/intake_rubicon/test_viz.py +++ b/tests/unit/intake_rubicon/test_viz.py @@ -4,6 +4,7 @@ DataframePlotDataSource, ExperimentsTableDataSource, MetricCorrelationPlotDataSource, + MetricListComparisonDataSource, ) root = os.path.dirname(__file__) @@ -93,3 +94,20 @@ def test_datatable_plot_source(): assert visualization.y == catalog_data_sample["y"] source.close() + + +def test_metric_list_source(): + catalog_data_sample = {"columns_names": None, "selected_metric": None} + + source = MetricListComparisonDataSource(catalog_data_sample) + assert source is not None + + source.discover() + + visualization = source.read() + + assert visualization is not None + assert visualization.columns_names == catalog_data_sample["columns_names"] + assert visualization.selected_metric == catalog_data_sample["selected_metric"] + + source.close() From a61a268beb9c4563ffba9ca8c393b8494101af24 Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Mon, 22 Jul 2024 14:34:14 -0400 Subject: [PATCH 16/24] updated formatting --- rubicon_ml/intake_rubicon/__init__.py | 2 +- rubicon_ml/intake_rubicon/publish.py | 2 -- rubicon_ml/intake_rubicon/viz.py | 3 +-- tests/unit/intake_rubicon/test_publish.py | 1 - 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/rubicon_ml/intake_rubicon/__init__.py b/rubicon_ml/intake_rubicon/__init__.py index ad42634c..30c3a338 100644 --- a/rubicon_ml/intake_rubicon/__init__.py +++ b/rubicon_ml/intake_rubicon/__init__.py @@ -13,5 +13,5 @@ "ExperimentsTableDataSource", "MetricCorrelationPlotDataSource", "DataframePlotDataSource", - "MetricListComparisonDataSource" + "MetricListComparisonDataSource", ] diff --git a/rubicon_ml/intake_rubicon/publish.py b/rubicon_ml/intake_rubicon/publish.py index dec4e1df..ca7f2ae8 100644 --- a/rubicon_ml/intake_rubicon/publish.py +++ b/rubicon_ml/intake_rubicon/publish.py @@ -106,7 +106,6 @@ def _update_catalog( def _build_catalog(experiments, visualization): - from rubicon_ml.viz import DataframePlot from rubicon_ml.viz import DataframePlot from rubicon_ml.viz.experiments_table import ExperimentsTable from rubicon_ml.viz.metric_correlation_plot import MetricCorrelationPlot @@ -157,7 +156,6 @@ def _build_catalog(experiments, visualization): } catalog["sources"]["experiment_table"] = appended_visualization_catalog - if isinstance(visualization, MetricCorrelationPlot): appended_visualization_catalog = { "driver": "rubicon_ml_metric_correlation_plot", diff --git a/rubicon_ml/intake_rubicon/viz.py b/rubicon_ml/intake_rubicon/viz.py index bcf49e74..f2b35e44 100644 --- a/rubicon_ml/intake_rubicon/viz.py +++ b/rubicon_ml/intake_rubicon/viz.py @@ -66,7 +66,7 @@ def _get_schema(self): self._visualization_object = DataframePlot(**self._catalog_data) return super()._get_schema() - + class MetricListComparisonDataSource(VizDataSourceMixin): """An Intake data source for reading `rubicon` Metric List Comparison visualizations.""" @@ -87,4 +87,3 @@ def _get_schema(self): self._visualization_object = MetricListsComparison(**self._catalog_data) return super()._get_schema() - diff --git a/tests/unit/intake_rubicon/test_publish.py b/tests/unit/intake_rubicon/test_publish.py index f272af81..ecdfb14f 100644 --- a/tests/unit/intake_rubicon/test_publish.py +++ b/tests/unit/intake_rubicon/test_publish.py @@ -3,7 +3,6 @@ from rubicon_ml import Rubicon, publish from rubicon_ml.viz.dataframe_plot import DataframePlot -from rubicon_ml.viz.dataframe_plot import DataframePlot from rubicon_ml.viz.experiments_table import ExperimentsTable from rubicon_ml.viz.metric_correlation_plot import MetricCorrelationPlot from rubicon_ml.viz.metric_lists_comparison import MetricListsComparison From 7fda1c9025ada589326064cea41a64660c9c438f Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Mon, 22 Jul 2024 14:41:01 -0400 Subject: [PATCH 17/24] removed duplicate test in test_viz.py --- rubicon_ml/intake_rubicon/viz.py | 27 +++++++++++---------- tests/unit/intake_rubicon/test_viz.py | 34 --------------------------- 2 files changed, 14 insertions(+), 47 deletions(-) diff --git a/rubicon_ml/intake_rubicon/viz.py b/rubicon_ml/intake_rubicon/viz.py index f2b35e44..6713f78a 100644 --- a/rubicon_ml/intake_rubicon/viz.py +++ b/rubicon_ml/intake_rubicon/viz.py @@ -67,23 +67,24 @@ def _get_schema(self): return super()._get_schema() - class MetricListComparisonDataSource(VizDataSourceMixin): - """An Intake data source for reading `rubicon` Metric List Comparison visualizations.""" - version = __version__ +class MetricListComparisonDataSource(VizDataSourceMixin): + """An Intake data source for reading `rubicon` Metric List Comparison visualizations.""" - container = "python" - name = "rubicon_ml_metric_list" + version = __version__ - def __init__(self, metadata=None, **catalog_data): - self._catalog_data = catalog_data or {} + container = "python" + name = "rubicon_ml_metric_list" - super().__init__(metadata=metadata) + def __init__(self, metadata=None, **catalog_data): + self._catalog_data = catalog_data or {} - def _get_schema(self): - """Creates a Dataframe Plot visualization and sets it as the visualization object attribute""" - from rubicon_ml.viz import MetricListsComparison + super().__init__(metadata=metadata) - self._visualization_object = MetricListsComparison(**self._catalog_data) + def _get_schema(self): + """Creates a Dataframe Plot visualization and sets it as the visualization object attribute""" + from rubicon_ml.viz import MetricListsComparison - return super()._get_schema() + self._visualization_object = MetricListsComparison(**self._catalog_data) + + return super()._get_schema() diff --git a/tests/unit/intake_rubicon/test_viz.py b/tests/unit/intake_rubicon/test_viz.py index 4d9b30a5..25d79657 100644 --- a/tests/unit/intake_rubicon/test_viz.py +++ b/tests/unit/intake_rubicon/test_viz.py @@ -96,40 +96,6 @@ def test_datatable_plot_source(): source.close() -def test_datatable_plot_source(): - catalog_data_sample = { - "dataframe_name": "dataframe_name", - "experiments": None, - "plotting_func": None, - "plotting_func_kwargs": None, - "x": None, - "y": None, - } - - source = DataframePlotDataSource( - dataframe_name="dataframe_name", - experiments=None, - plotting_func=None, - plotting_func_kwargs=None, - x=None, - y=None, - ) - assert source is not None - - source.discover() - - visualization = source.read() - - assert visualization is not None - assert visualization.dataframe_name == catalog_data_sample["dataframe_name"] - assert visualization.plotting_func == catalog_data_sample["plotting_func"] - assert visualization.plotting_func_kwargs == catalog_data_sample["plotting_func_kwargs"] - assert visualization.x == catalog_data_sample["x"] - assert visualization.y == catalog_data_sample["y"] - - source.close() - - def test_metric_list_source(): catalog_data_sample = {"columns_names": None, "selected_metric": None} From 39912be3dd7bf0f14b38124a86f8a35571c58061 Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Mon, 22 Jul 2024 14:59:52 -0400 Subject: [PATCH 18/24] edit metriclist types and removing experiments from metriclistcomparison in publish.py --- rubicon_ml/intake_rubicon/publish.py | 3 +-- rubicon_ml/viz/metric_lists_comparison.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/rubicon_ml/intake_rubicon/publish.py b/rubicon_ml/intake_rubicon/publish.py index ca7f2ae8..87a99d2c 100644 --- a/rubicon_ml/intake_rubicon/publish.py +++ b/rubicon_ml/intake_rubicon/publish.py @@ -167,7 +167,7 @@ def _build_catalog(experiments, visualization): } catalog["sources"]["metric_correlation_plot"] = appended_visualization_catalog - # vizualization is an DataframePlot + # vizualization is an DataframePlot tests/unit/intake_rubicon/test_publish.py if isinstance(visualization, DataframePlot): appended_visualization_catalog = { "driver": "rubicon_ml_dataframe_plot", @@ -189,7 +189,6 @@ def _build_catalog(experiments, visualization): "driver": "rubicon_ml_metric_list", "args": { "column_names": visualization.column_names, - "experiments": visualization.experiments, "selected_metric": visualization.selected_metric, }, } diff --git a/rubicon_ml/viz/metric_lists_comparison.py b/rubicon_ml/viz/metric_lists_comparison.py index b0e6a2f9..ad11b51c 100644 --- a/rubicon_ml/viz/metric_lists_comparison.py +++ b/rubicon_ml/viz/metric_lists_comparison.py @@ -78,7 +78,7 @@ def load_experiment_data(self): for experiment in self.experiments: for metric in experiment.metrics(): - if isinstance(metric.value, float): + if isinstance(metric.value, list): self.metric_names.add(metric.name) experiment_record = self.experiment_records.get(experiment.id, {}) @@ -154,7 +154,7 @@ def update_metric_heatmap(*args): data_array = np.array(heatmap_data) numerator = data_array - data_array.min(axis=0) - denominator = np.array(data_array.max(axis=0) - data_array.min(axis=0)) + denominator = data_array.max(axis=0) - data_array.min(axis=0) denominator[denominator == 0] = 1 scaled_heatmap_data = numerator / denominator From f19ae27cdf2aab181a3fe5d07b250cba08a0b34c Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Mon, 22 Jul 2024 15:06:51 -0400 Subject: [PATCH 19/24] edit test_viz.py metric list parameter names --- tests/unit/intake_rubicon/test_viz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/intake_rubicon/test_viz.py b/tests/unit/intake_rubicon/test_viz.py index 25d79657..f8f664f4 100644 --- a/tests/unit/intake_rubicon/test_viz.py +++ b/tests/unit/intake_rubicon/test_viz.py @@ -97,7 +97,7 @@ def test_datatable_plot_source(): def test_metric_list_source(): - catalog_data_sample = {"columns_names": None, "selected_metric": None} + catalog_data_sample = {"column_names": None, "selected_metric": None} source = MetricListComparisonDataSource(catalog_data_sample) assert source is not None From df99dcd241aa8ef06bedc046d9c6330046003575 Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Mon, 22 Jul 2024 15:10:01 -0400 Subject: [PATCH 20/24] update metric list tests --- tests/unit/intake_rubicon/test_viz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/intake_rubicon/test_viz.py b/tests/unit/intake_rubicon/test_viz.py index f8f664f4..31534669 100644 --- a/tests/unit/intake_rubicon/test_viz.py +++ b/tests/unit/intake_rubicon/test_viz.py @@ -107,7 +107,7 @@ def test_metric_list_source(): visualization = source.read() assert visualization is not None - assert visualization.columns_names == catalog_data_sample["columns_names"] + assert visualization.column_names == catalog_data_sample["column_names"] assert visualization.selected_metric == catalog_data_sample["selected_metric"] source.close() From 48236da3bcc5a6087db906d8d690a66914c80eaf Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Mon, 22 Jul 2024 17:14:16 -0400 Subject: [PATCH 21/24] edit comments --- rubicon_ml/intake_rubicon/publish.py | 6 ++++-- rubicon_ml/intake_rubicon/viz.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/rubicon_ml/intake_rubicon/publish.py b/rubicon_ml/intake_rubicon/publish.py index 87a99d2c..f70ab975 100644 --- a/rubicon_ml/intake_rubicon/publish.py +++ b/rubicon_ml/intake_rubicon/publish.py @@ -140,6 +140,7 @@ def _build_catalog(experiments, visualization): catalog["sources"][experiment_catalog_name] = appended_experiment_catalog # create visualization entry to the catalog file + # visualization is an ExperimentsTable if visualization is not None: if isinstance(visualization, ExperimentsTable): appended_visualization_catalog = { @@ -156,6 +157,7 @@ def _build_catalog(experiments, visualization): } catalog["sources"]["experiment_table"] = appended_visualization_catalog + # vizualization is a MetricCorrelationPlot if isinstance(visualization, MetricCorrelationPlot): appended_visualization_catalog = { "driver": "rubicon_ml_metric_correlation_plot", @@ -167,7 +169,7 @@ def _build_catalog(experiments, visualization): } catalog["sources"]["metric_correlation_plot"] = appended_visualization_catalog - # vizualization is an DataframePlot tests/unit/intake_rubicon/test_publish.py + # vizualization is a DataframePlot if isinstance(visualization, DataframePlot): appended_visualization_catalog = { "driver": "rubicon_ml_dataframe_plot", @@ -183,7 +185,7 @@ def _build_catalog(experiments, visualization): # append visualization object to end of catalog file - # vizualization is an MetricListsComparison + # vizualization is a MetricListsComparison if isinstance(visualization, MetricListsComparison): appended_visualization_catalog = { "driver": "rubicon_ml_metric_list", diff --git a/rubicon_ml/intake_rubicon/viz.py b/rubicon_ml/intake_rubicon/viz.py index 6713f78a..78ff88fb 100644 --- a/rubicon_ml/intake_rubicon/viz.py +++ b/rubicon_ml/intake_rubicon/viz.py @@ -82,7 +82,7 @@ def __init__(self, metadata=None, **catalog_data): super().__init__(metadata=metadata) def _get_schema(self): - """Creates a Dataframe Plot visualization and sets it as the visualization object attribute""" + """Creates a Metric List Comparison visualization and sets it as the visualization object attribute""" from rubicon_ml.viz import MetricListsComparison self._visualization_object = MetricListsComparison(**self._catalog_data) From fbf69f927c4b933bbfdd1b8d3cb41910c06cee7f Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Thu, 25 Jul 2024 14:18:23 -0400 Subject: [PATCH 22/24] remove error for no dataframe logged to each experiment --- rubicon_ml/viz/dataframe_plot.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rubicon_ml/viz/dataframe_plot.py b/rubicon_ml/viz/dataframe_plot.py index a08f72ba..6b7d9b33 100644 --- a/rubicon_ml/viz/dataframe_plot.py +++ b/rubicon_ml/viz/dataframe_plot.py @@ -89,8 +89,13 @@ def load_experiment_data(self): `dataframe_name` must have the same schema. """ self.data_df = None + count = 0 for experiment in self.experiments: + if (len(experiment.dataframes())==0) : + print(f"WARNING: Experiment {experiment.name} does not have any dataframes logged to it. ") + continue + count += 1 dataframe = experiment.dataframe(name=self.dataframe_name) data_df = dataframe.get_data() @@ -116,6 +121,9 @@ def load_experiment_data(self): len(self.experiments), ) + if (count == 0): + raise Exception(f"No dataframe with name {self.dataframe_name} found!") + def register_callbacks(self, link_experiment_table=False): outputs = [ Output("dataframe-plot", "figure"), From 5084131063d980f865d934e1c4d3ead4cf5cba11 Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Thu, 25 Jul 2024 14:19:21 -0400 Subject: [PATCH 23/24] update code styling --- rubicon_ml/viz/dataframe_plot.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rubicon_ml/viz/dataframe_plot.py b/rubicon_ml/viz/dataframe_plot.py index 6b7d9b33..a232cfbf 100644 --- a/rubicon_ml/viz/dataframe_plot.py +++ b/rubicon_ml/viz/dataframe_plot.py @@ -92,8 +92,10 @@ def load_experiment_data(self): count = 0 for experiment in self.experiments: - if (len(experiment.dataframes())==0) : - print(f"WARNING: Experiment {experiment.name} does not have any dataframes logged to it. ") + if len(experiment.dataframes()) == 0: + print( + f"WARNING: Experiment {experiment.name} does not have any dataframes logged to it. " + ) continue count += 1 dataframe = experiment.dataframe(name=self.dataframe_name) @@ -121,7 +123,7 @@ def load_experiment_data(self): len(self.experiments), ) - if (count == 0): + if count == 0: raise Exception(f"No dataframe with name {self.dataframe_name} found!") def register_callbacks(self, link_experiment_table=False): From 5d8e61016f175bcdf2dda85f820554c3de3e6c55 Mon Sep 17 00:00:00 2001 From: Jacqueline Hui Date: Thu, 25 Jul 2024 15:18:58 -0400 Subject: [PATCH 24/24] make dataframe_name default to 'None' and take the dataframe name of the first experiment's dataframe --- rubicon_ml/viz/dataframe_plot.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rubicon_ml/viz/dataframe_plot.py b/rubicon_ml/viz/dataframe_plot.py index a232cfbf..4bc051a6 100644 --- a/rubicon_ml/viz/dataframe_plot.py +++ b/rubicon_ml/viz/dataframe_plot.py @@ -43,7 +43,7 @@ class DataframePlot(VizBase): def __init__( self, - dataframe_name, + dataframe_name=None, experiments=None, plotting_func=px.line, plotting_func_kwargs={}, @@ -51,9 +51,14 @@ def __init__( y=None, ): super().__init__(dash_title="plot dataframes") - - self.dataframe_name = dataframe_name self.experiments = experiments + if experiments != None: + if len(experiments[0].dataframes()) == 0: + raise Exception("No dataframe logged to experiment") + else: + self.dataframe_name = self.experiments[0].dataframes()[0].name + else: + self.dataframe_name = dataframe_name self.plotting_func = plotting_func self.plotting_func_kwargs = plotting_func_kwargs self.x = x