Skip to content

Commit

Permalink
Add e2e test for lite mode and support earliest Kedro version (#2148)
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi-kumar-pilla authored Oct 25, 2024
1 parent ddb2386 commit 712c5cf
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 4 deletions.
6 changes: 6 additions & 0 deletions package/features/viz.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ Feature: Viz plugin in new project
When I execute the kedro viz run command
Then kedro-viz should start successfully

Scenario: Execute viz lite with the earliest Kedro version that it supports
Given I have installed kedro version "0.18.3"
And I have run a non-interactive kedro new with pandas-iris starter
When I execute the kedro viz run command with lite option
Then kedro-viz should start successfully

Scenario: Execute viz lite with latest Kedro
Given I have installed kedro version "latest"
And I have run a non-interactive kedro new with spaceflights-pandas starter
Expand Down
9 changes: 8 additions & 1 deletion package/kedro_viz/data_access/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@

import networkx as nx
from kedro.io import DataCatalog
from kedro.io.core import DatasetError

try:
# kedro 0.18.11 onwards
from kedro.io.core import DatasetError
except ImportError: # pragma: no cover
# older versions
from kedro.io.core import DataSetError as DatasetError # type: ignore

from kedro.pipeline import Pipeline as KedroPipeline
from kedro.pipeline.node import Node as KedroNode
from sqlalchemy.orm import sessionmaker
Expand Down
15 changes: 14 additions & 1 deletion package/kedro_viz/integrations/kedro/abstract_dataset_lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,20 @@
import logging
from typing import Any, Optional

from kedro.io.core import AbstractDataset, DatasetError
try:
# kedro 0.18.11 onwards
from kedro.io.core import DatasetError
except ImportError: # pragma: no cover
# older versions
from kedro.io.core import DataSetError as DatasetError # type: ignore

try:
# kedro 0.18.12 onwards
from kedro.io.core import AbstractDataset
except ImportError: # pragma: no cover
# older versions
from kedro.io.core import AbstractDataSet as AbstractDataset # type: ignore


from kedro_viz.integrations.utils import UnavailableDataset

Expand Down
9 changes: 8 additions & 1 deletion package/kedro_viz/integrations/kedro/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,14 @@ def _load_data_helper(
# patch the AbstractDataset class for a custom
# implementation to handle kedro.io.core.DatasetError
if is_lite:
with patch("kedro.io.data_catalog.AbstractDataset", AbstractDatasetLite):
# kedro 0.18.12 onwards
if hasattr(sys.modules["kedro.io.data_catalog"], "AbstractDataset"):
abstract_ds_patch_target = "kedro.io.data_catalog.AbstractDataset"
else: # pragma: no cover
# older versions
abstract_ds_patch_target = "kedro.io.data_catalog.AbstractDataSet"

with patch(abstract_ds_patch_target, AbstractDatasetLite):
catalog = context.catalog
else:
catalog = context.catalog
Expand Down
7 changes: 6 additions & 1 deletion package/kedro_viz/integrations/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

from typing import Any, Union

from kedro.io.core import AbstractDataset
try:
# kedro 0.18.12 onwards
from kedro.io.core import AbstractDataset
except ImportError: # pragma: no cover
# older versions
from kedro.io.core import AbstractDataSet as AbstractDataset # type: ignore

_EMPTY = object()

Expand Down

0 comments on commit 712c5cf

Please sign in to comment.