Skip to content

Commit

Permalink
Hot fix for backward compatiblity of kedro datasets (#1600)
Browse files Browse the repository at this point in the history
* hot fix for backward compatiblity in kedro datasets and viz

Signed-off-by: ravi-kumar-pilla <[email protected]>

* upgrade plotly

Signed-off-by: ravi-kumar-pilla <[email protected]>

* upgrading plotly as per kedro datasets

Signed-off-by: ravi-kumar-pilla <[email protected]>

---------

Signed-off-by: ravi-kumar-pilla <[email protected]>
  • Loading branch information
ravi-kumar-pilla authored Oct 24, 2023
1 parent 8da0cf4 commit 7922698
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package/features/steps/lower_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fsspec==2021.4
aiofiles==22.1.0
uvicorn[standard]==0.22.0
watchgod==0.8.2
plotly==4.0
plotly==4.8
packaging==23.0
pandas==1.3; python_version < '3.10'
pandas==1.5; python_version >= '3.10'
Expand Down
13 changes: 9 additions & 4 deletions package/kedro_viz/integrations/kedro/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,22 +212,27 @@ def matplotlib_writer_load(dataset: matplotlib.MatplotlibWriter) -> str:
getattr(plotly, "JSONDataset") # Trigger import
plotly.JSONDataset._load = json_dataset.JSONDataset._load
except (ImportError, AttributeError):
pass
getattr(plotly, "JSONDataSet") # Trigger import
plotly.JSONDataSet._load = json_dataset.JSONDataSet._load


try:
getattr(plotly, "PlotlyDataset") # Trigger import
plotly.PlotlyDataset._load = json_dataset.JSONDataset._load
except (ImportError, AttributeError):
pass
getattr(plotly, "PlotlyDataSet") # Trigger import
plotly.PlotlyDataSet._load = json_dataset.JSONDataSet._load

try:
getattr(tracking, "JSONDataset") # Trigger import
tracking.JSONDataset._load = json_dataset.JSONDataset._load
except (ImportError, AttributeError):
pass
getattr(tracking, "JSONDataSet") # Trigger import
tracking.JSONDataSet._load = json_dataset.JSONDataSet._load

try:
getattr(tracking, "MetricsDataset") # Trigger import
tracking.MetricsDataset._load = json_dataset.JSONDataset._load
except (ImportError, AttributeError):
pass
getattr(tracking, "MetricsDataSet") # Trigger import
tracking.MetricsDataSet._load = json_dataset.JSONDataSet._load
4 changes: 4 additions & 0 deletions package/kedro_viz/models/experiment_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class TrackingDatasetGroup(str, Enum):
"matplotlib.matplotlib_writer.MatplotlibWriter": TrackingDatasetGroup.PLOT,
"tracking.metrics_dataset.MetricsDataset": TrackingDatasetGroup.METRIC,
"tracking.json_dataset.JSONDataset": TrackingDatasetGroup.JSON,
"plotly.plotly_dataset.PlotlyDataSet": TrackingDatasetGroup.PLOT,
"plotly.json_dataset.JSONDataSet": TrackingDatasetGroup.PLOT,
"tracking.metrics_dataset.MetricsDataSet": TrackingDatasetGroup.METRIC,
"tracking.json_dataset.JSONDataSet": TrackingDatasetGroup.JSON,
}


Expand Down
12 changes: 10 additions & 2 deletions package/kedro_viz/models/flowchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ def is_plot_node(self):
return self.dataset_type in (
"plotly.plotly_dataset.PlotlyDataset",
"plotly.json_dataset.JSONDataset",
"plotly.plotly_dataset.PlotlyDataSet",
"plotly.json_dataset.JSONDataSet",
)

def is_image_node(self):
Expand All @@ -476,11 +478,17 @@ def is_image_node(self):

def is_metric_node(self):
"""Check if the current node is a metrics node."""
return self.dataset_type in ("tracking.metrics_dataset.MetricsDataset",)
return self.dataset_type in (
"tracking.metrics_dataset.MetricsDataset",
"tracking.metrics_dataset.MetricsDataSet",
)

def is_json_node(self):
"""Check if the current node is a JSONDataset node."""
return self.dataset_type in ("tracking.json_dataset.JSONDataset",)
return self.dataset_type in (
"tracking.json_dataset.JSONDataset",
"tracking.json_dataset.JSONDataSet",
)

def is_tracking_node(self):
"""Checks if the current node is a tracking data node"""
Expand Down
4 changes: 4 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ export const shortTypeMapping = {
'matplotlib.matplotlib_writer.MatplotlibWriter': 'image',
'tracking.json_dataset.JSONDataset': 'JSONTracking',
'tracking.metrics_dataset.MetricsDataset': 'metricsTracking',
'plotly.plotly_dataset.PlotlyDataSet': 'plotly',
'plotly.json_dataset.JSONDataSet': 'plotly',
'tracking.json_dataset.JSONDataSet': 'JSONTracking',
'tracking.metrics_dataset.MetricsDataSet': 'metricsTracking',
};

export const tabLabels = ['Overview', 'Metrics', 'Plots'];
Expand Down

0 comments on commit 7922698

Please sign in to comment.