Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Kedro 19 #1680

Merged
merged 27 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0963718
initial draft fix with failing pytests
ravi-kumar-pilla Dec 12, 2023
abe2047
Merge branch 'main' into fix/kedro19-compat
ravi-kumar-pilla Dec 12, 2023
b80f4a4
update e2e starter project
ravi-kumar-pilla Dec 12, 2023
574425b
Merge branch 'fix/kedro19-compat' of https://github.com/kedro-org/ked…
ravi-kumar-pilla Dec 12, 2023
ee216e6
update starter to a common project for kedro18 and kedro19
ravi-kumar-pilla Dec 12, 2023
49ca1f7
fix lint issues
ravi-kumar-pilla Dec 12, 2023
7148f28
Merge branch 'main' into fix/kedro19-compat
ravi-kumar-pilla Dec 12, 2023
771a37b
fix lint
ravi-kumar-pilla Dec 12, 2023
e823950
Merge branch 'fix/kedro19-compat' of https://github.com/kedro-org/ked…
ravi-kumar-pilla Dec 12, 2023
911f003
adjust requirements path
ravi-kumar-pilla Dec 13, 2023
ca8f64b
fix e2e tests
ravi-kumar-pilla Dec 13, 2023
802db91
fix e2e req path
ravi-kumar-pilla Dec 13, 2023
11028a6
remove try imports from tests
ravi-kumar-pilla Dec 13, 2023
b13d5d7
add older version comments
ravi-kumar-pilla Dec 13, 2023
31b1584
fix pytest with task node id change and no layer
ravi-kumar-pilla Dec 13, 2023
6cc2872
add timeout for flaky cypress test
ravi-kumar-pilla Dec 13, 2023
ef0e424
add timeout for flaky cypress test
ravi-kumar-pilla Dec 13, 2023
355d097
Cypress test fix
jitu5 Dec 14, 2023
6b7501f
add layers back
rashidakanchwala Dec 14, 2023
0599628
fix lint
rashidakanchwala Dec 14, 2023
21bb31c
added support for Kedro 0.18.x
rashidakanchwala Dec 14, 2023
b6bf138
add defaultCommandTImeout
rashidakanchwala Dec 14, 2023
3bdfc3f
update datasets to 2.0 on demo-project
rashidakanchwala Dec 15, 2023
4ed441d
fix reqs
rashidakanchwala Dec 15, 2023
d27fde6
fix version for datasets
rashidakanchwala Dec 15, 2023
1d22102
datasets to <=2.0
rashidakanchwala Dec 15, 2023
5a161f1
fix-tests-for-datasets-2.0
rashidakanchwala Dec 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { defineConfig } = require('cypress');

module.exports = defineConfig({
defaultCommandTimeout: 10000,
env: {
apiBaseUrl: 'http://localhost:4142',
coverage: false,
Expand Down
2 changes: 1 addition & 1 deletion demo-project/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.kedro]
package_name = "demo_project"
project_name = "modular-spaceflights"
kedro_init_version = "0.18.14"
kedro_init_version = "0.19.0"

[tool.isort]
multi_line_output = 3
Expand Down
4 changes: 1 addition & 3 deletions demo-project/src/demo_project/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from kedro.framework.cli.utils import (
KedroCliError,
_config_file_callback,
_reformat_load_versions,
_split_params,
env_option,
split_string,
Expand Down Expand Up @@ -83,8 +82,7 @@ def cli():
"-lv",
type=str,
multiple=True,
help=LOAD_VERSION_HELP,
callback=_reformat_load_versions,
help=LOAD_VERSION_HELP
)
@click.option("--pipeline", type=str, default=None, help=PIPELINE_ARG_HELP)
@click.option(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import fsspec
import numpy as np
import PIL
from kedro.io.core import AbstractDataSet, get_protocol_and_path
from kedro.io.core import AbstractDataset, get_protocol_and_path
from PIL import Image


class ImageDataSet(AbstractDataSet):
class ImageDataSet(AbstractDataset):
"""``ImageDataSet`` loads / save image data from a given filepath as `numpy` array
using Pillow.

Expand Down
2 changes: 1 addition & 1 deletion demo-project/src/docker_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kedro~=0.18.0
kedro>=0.18.0
kedro-datasets[pandas.CSVDataSet,pandas.ExcelDataSet, pandas.ParquetDataSet, plotly.PlotlyDataSet, matplotlib.MatplotlibWriter]~=1.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would try to use kedro-datasets 2.0.0 if possible for the demo project so it's on the very latest release.

Suggested change
kedro-datasets[pandas.CSVDataSet,pandas.ExcelDataSet, pandas.ParquetDataSet, plotly.PlotlyDataSet, matplotlib.MatplotlibWriter]~=1.0
kedro-datasets[pandas.CSVDataset,pandas.ExcelDataset, pandas.ParquetDataset, plotly.PlotlyDataset, matplotlib.MatplotlibWriter]~=2.0

scikit-learn~=1.0
pillow~=9.0
Expand Down
12 changes: 10 additions & 2 deletions package/features/steps/cli_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import requests
import yaml
from behave import given, then, when
from packaging.version import parse

from features.steps.sh_run import ChildTerminatingPopen, run

Expand Down Expand Up @@ -76,8 +77,12 @@ def create_project_with_starter(context, starter):

@given("I have installed the project's requirements")
def install_project_requirements(context):
"""Run ``pip install -r src/requirements.txt``."""
requirements_path = str(context.root_project_dir) + "/src/requirements.txt"
"""Run ``pip install -r requirements.txt``."""
if context.kedro_version != "latest":
requirements_path = str(context.root_project_dir) + "/src/requirements.txt"
else:
requirements_path = str(context.root_project_dir) + "/requirements.txt"

cmd = [context.pip, "install", "-r", requirements_path]
res = run(cmd, env=context.env)

Expand All @@ -103,6 +108,9 @@ def install_lower_bound_requirements(context):
@given('I have installed kedro version "{version}"')
def install_kedro(context, version):
"""Install Kedro using pip."""
# add kedro_version to context
context.kedro_version = version

if version == "latest":
cmd = [context.pip, "install", "-U", "kedro"]
else:
Expand Down
4 changes: 2 additions & 2 deletions package/features/viz.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ Feature: Viz plugin in new project
Scenario: Execute viz with latest Kedro with lower-bound viz requirements
Given I have installed kedro version "latest"
And I have installed the lower-bound Kedro-viz requirements
And I have run a non-interactive kedro new with pandas-iris starter
And I have run a non-interactive kedro new with spaceflights-pandas starter
And I have installed the project's requirements
When I execute the kedro viz command
Then kedro-viz should start successfully

Scenario: Execute viz with latest Kedro
Given I have installed kedro version "latest"
And I have run a non-interactive kedro new with pandas-iris starter
And I have run a non-interactive kedro new with spaceflights-pandas starter
And I have installed the project's requirements
When I execute the kedro viz command
Then kedro-viz should start successfully
Expand Down
7 changes: 4 additions & 3 deletions package/kedro_viz/data_access/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ def resolve_dataset_factory_patterns(
them against the datasets in the pipelines.
"""
for pipeline in pipelines.values():
if hasattr(pipeline, "datasets"):
datasets = pipeline.datasets() # kedro 0.19.0 onwards
else:
if hasattr(pipeline, "data_sets"):
# Support for Kedro 0.18.x
datasets = pipeline.data_sets()
else:
datasets = pipeline.datasets()

for dataset_name in datasets:
try:
Expand Down
11 changes: 5 additions & 6 deletions package/kedro_viz/data_access/repositories/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
from kedro.io import DatasetNotFoundError, MemoryDataset
except ImportError: # pragma: no cover
# older versions
from kedro.io import DataSetNotFoundError as DatasetNotFoundError
from kedro.io import MemoryDataSet as MemoryDataset
from kedro.io import DataSetNotFoundError as DatasetNotFoundError # type: ignore
from kedro.io import MemoryDataSet as MemoryDataset # type: ignore

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

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -86,8 +86,8 @@ def layers_mapping(self):
except Exception: # pragma: no cover
datasets = self._catalog._datasets

# Maps layers according to the old format
if KEDRO_VERSION < parse("0.19.0"):
# Support for Kedro 0.18.x
if KEDRO_VERSION < parse("0.19.0"): # pragma: no cover
if self._catalog.layers is None:
self._layers_mapping = {
_strip_transcoding(dataset_name): None for dataset_name in datasets
Expand All @@ -100,7 +100,6 @@ def layers_mapping(self):
self._validate_layers_for_transcoding(dataset_name, layer)
self._layers_mapping[dataset_name] = layer

# Maps layers according to the new format
for dataset_name in datasets:
dataset = self._catalog._get_dataset(dataset_name)
metadata = getattr(dataset, "metadata", None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
from kedro.io import AbstractVersionedDataset
except ImportError:
# older versions
from kedro.io import AbstractVersionedDataSet as AbstractVersionedDataset
from kedro.io import ( # type: ignore # isort:skip
AbstractVersionedDataSet as AbstractVersionedDataset,
)


class TrackingDatasetsRepository:
Expand Down
5 changes: 3 additions & 2 deletions package/kedro_viz/integrations/kedro/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ def after_catalog_created(self, catalog: DataCatalog):
"""
# Temporary try/except block so the Kedro develop branch can work with Viz.
try:
self.datasets = catalog._data_sets
self.datasets = catalog._datasets
except Exception: # pragma: no cover
self.datasets = catalog._datasets # type: ignore[attr-defined]
# Support for Kedro 0.18.x
self.datasets = catalog._data_sets # type: ignore[attr-defined]

@hook_impl
def after_dataset_loaded(self, dataset_name: str, data: Any):
Expand Down
4 changes: 3 additions & 1 deletion package/kedro_viz/models/experiment_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
from kedro.io import AbstractVersionedDataset
except ImportError:
# older versions
from kedro.io import AbstractVersionedDataSet as AbstractVersionedDataset
from kedro.io import ( # type: ignore # isort:skip
AbstractVersionedDataSet as AbstractVersionedDataset,
)

logger = logging.getLogger(__name__)
Base = declarative_base()
Expand Down
4 changes: 2 additions & 2 deletions package/kedro_viz/models/flowchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
from kedro.io.core import DatasetError
except ImportError: # pragma: no cover
# older versions
from kedro.io.core import DataSetError as DatasetError
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
from kedro.io.core import AbstractDataSet as AbstractDataset # type: ignore

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion package/kedro_viz/models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from kedro.io.core import AbstractDataset
except ImportError: # pragma: no cover
# older versions
from kedro.io.core import AbstractDataSet as AbstractDataset
from kedro.io.core import AbstractDataSet as AbstractDataset # type: ignore


def get_dataset_type(dataset: "AbstractDataset") -> str:
Expand Down
29 changes: 11 additions & 18 deletions package/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest
from fastapi.testclient import TestClient
from kedro.framework.session.store import BaseSessionStore
from kedro.io import DataCatalog, Version
from kedro.io import DataCatalog, MemoryDataset, Version
from kedro.pipeline import Pipeline, node
from kedro.pipeline.modular_pipeline import pipeline
from kedro_datasets import pandas, tracking
Expand All @@ -20,13 +20,6 @@
from kedro_viz.models.flowchart import GraphNode
from kedro_viz.server import populate_data

try:
# kedro 0.18.11 onwards
from kedro.io import MemoryDataset
except ImportError:
# older versions
from kedro.io import MemoryDataSet as MemoryDataset


@pytest.fixture
def data_access_manager():
Expand Down Expand Up @@ -97,21 +90,20 @@ def train_model(model_inputs, parameters):
@pytest.fixture
def example_catalog():
yield DataCatalog(
data_sets={
"uk.data_processing.raw_data": pandas.CSVDataset(filepath="raw_data.csv"),
"model_inputs": pandas.CSVDataset(filepath="model_inputs.csv"),
datasets={
"uk.data_processing.raw_data": pandas.CSVDataset(
filepath="raw_data.csv", metadata={"kedro-viz": {"layer": "raw"}}
),
"model_inputs": pandas.CSVDataset(
filepath="model_inputs.csv",
metadata={"kedro-viz": {"layer": "model_inputs"}},
),
"uk.data_science.model": MemoryDataset(),
},
feed_dict={
"parameters": {"train_test_split": 0.1, "num_epochs": 1000},
"params:uk.data_processing.train_test_split": 0.1,
},
layers={
"raw": {
"uk.data_processing.raw_data",
},
"model_inputs": {"model_inputs"},
},
dataset_patterns={
"{dataset_name}#csv": {
"type": "pandas.CSVDataset",
Expand Down Expand Up @@ -157,7 +149,7 @@ def train_model(model_inputs, parameters):
@pytest.fixture
def example_transcoded_catalog():
yield DataCatalog(
data_sets={
datasets={
"model_inputs@pandas": pandas.ParquetDataset(
filepath="model_inputs.parquet"
),
Expand Down Expand Up @@ -324,6 +316,7 @@ def pipeline_with_datasets_mock():


# Create a mock for KedroPipeline with data_sets method
# older versions
@pytest.fixture
def pipeline_with_data_sets_mock():
pipeline = mock.MagicMock()
Expand Down
20 changes: 10 additions & 10 deletions package/tests/test_api/main
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"nodes": [
{
"id": "f2e4bf0e",
"id": "782e4a43",
"name": "process_data",
"tags": ["split"],
"pipelines": ["data_processing", "__default__"],
Expand Down Expand Up @@ -40,7 +40,7 @@
"dataset_type": "pandas.csv_dataset.CSVDataset"
},
{
"id": "7b140b3f",
"id": "f2b25286",
"name": "train_model",
"tags": ["train"],
"pipelines": ["__default__", "data_science"],
Expand Down Expand Up @@ -100,20 +100,20 @@
}
],
"edges": [
{ "source": "f1f1425b", "target": "7b140b3f" },
{ "source": "f1f1425b", "target": "f2b25286" },
{ "source": "0ecea0de", "target": "uk.data_science" },
{ "source": "f0ebef01", "target": "uk" },
{ "source": "7b140b3f", "target": "d5a8b994" },
{ "source": "f2b25286", "target": "d5a8b994" },
{ "source": "f0ebef01", "target": "uk.data_processing" },
{ "source": "13399a82", "target": "f2e4bf0e" },
{ "source": "13399a82", "target": "782e4a43" },
{ "source": "uk.data_science", "target": "d5a8b994" },
{ "source": "f1f1425b", "target": "uk" },
{ "source": "0ecea0de", "target": "7b140b3f" },
{ "source": "0ecea0de", "target": "f2b25286" },
{ "source": "uk", "target": "d5a8b994" },
{ "source": "f1f1425b", "target": "uk.data_science" },
{ "source": "f2e4bf0e", "target": "0ecea0de" },
{ "source": "782e4a43", "target": "0ecea0de" },
{ "source": "uk.data_processing", "target": "0ecea0de" },
{ "source": "f0ebef01", "target": "f2e4bf0e" },
{ "source": "f0ebef01", "target": "782e4a43" },
{ "source": "13399a82", "target": "uk" },
{ "source": "13399a82", "target": "uk.data_processing" }
],
Expand Down Expand Up @@ -146,7 +146,7 @@
"outputs": ["0ecea0de"],
"children": [
{ "id": "13399a82", "type": "data" },
{ "id": "f2e4bf0e", "type": "task" }
{ "id": "782e4a43", "type": "task" }
]
},
"uk": {
Expand All @@ -166,7 +166,7 @@
"outputs": ["d5a8b994"],
"children": [
{ "id": "d5a8b994", "type": "data" },
{ "id": "7b140b3f", "type": "task" }
{ "id": "f2b25286", "type": "task" }
]
}
},
Expand Down
8 changes: 4 additions & 4 deletions package/tests/test_api/test_graphql/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def savefig(cls, bytes_buffer, **kwargs):
matplotlib_dataset.save(MockMatplotData)

catalog = DataCatalog(
data_sets={
datasets={
"metrics": metrics_dataset,
"csv_dataset": csv_dataset,
"more_metrics": more_metrics,
Expand All @@ -180,7 +180,7 @@ def example_multiple_run_tracking_catalog(example_run_ids, tmp_path):
new_data = {"col1": 3, "col2": 3.23}
new_metrics_dataset.save(new_data)
catalog = DataCatalog(
data_sets={
datasets={
"new_metrics": new_metrics_dataset,
}
)
Expand All @@ -202,7 +202,7 @@ def example_multiple_run_tracking_catalog_at_least_one_empty_run(
version=Version(None, example_run_ids[0]),
)
catalog = DataCatalog(
data_sets={
datasets={
"new_metrics": new_metrics_dataset,
}
)
Expand All @@ -221,7 +221,7 @@ def example_multiple_run_tracking_catalog_all_empty_runs(example_run_ids, tmp_pa
version=Version(None, example_run_ids[0]),
)
catalog = DataCatalog(
data_sets={
datasets={
"new_metrics": new_metrics_dataset,
}
)
Expand Down
Loading