Skip to content

Commit

Permalink
Merge branch 'main' into flowchart-orientation
Browse files Browse the repository at this point in the history
  • Loading branch information
rashidakanchwala authored Feb 5, 2025
2 parents 5955b99 + 60b6a81 commit e0b7677
Show file tree
Hide file tree
Showing 22 changed files with 401 additions and 49 deletions.
6 changes: 3 additions & 3 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Please follow the established format:
- Include the ID number for the related PR (or PRs) in parentheses
-->

# Release 10.2.0
# Release 10.2.0


## Major features and improvements
## Deprecations
- Added a deprecation warning for the removal of the Experiment Tracking feature, which will be deprecated in Kedro-Viz version 11.0.0. For more details, please refer to our [blog post](https://kedro.org/blog/deprecate-experiment-tracking-kedro-viz). (#2248, #2263)

## Bug fixes and other changes

Expand Down
13 changes: 11 additions & 2 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Add any reusable custom commands here
import { join } from 'path';
import { localStorageETDeprecationBannerSeen } from '../../src/config';

/**
* Custom command for intercepting network requests using fixtures for GraphQL
Expand Down Expand Up @@ -167,11 +168,19 @@ Cypress.Commands.add('__conditionalVisit__', () => {
cy.__interceptGql__('getRunData');
cy.__interceptGql__('getMetricPlotData');

cy.visit('/experiment-tracking');
cy.visit('/experiment-tracking', {
onBeforeLoad(win) {
win.localStorage.setItem(localStorageETDeprecationBannerSeen, JSON.stringify(true));
}
});

cy.wait(['@getRunsList', '@getRunData', '@getMetricPlotData']);
} else {
cy.visit('/');
cy.visit('/', {
onBeforeLoad(win) {
win.localStorage.setItem(localStorageETDeprecationBannerSeen, JSON.stringify(true));
}
});
}
});

Expand Down
4 changes: 0 additions & 4 deletions cypress/tests/ui/flowchart/banners.cy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
describe('Banners in Kedro-Viz', () => {
beforeEach(() => {
// Clears localStorage before each test
cy.clearLocalStorage();
});

it("shows a missing dependencies banner in viz lite mode if the kedro project dependencies are not installed.", () => {
// Intercept the network request to mock with a fixture
Expand Down
4 changes: 0 additions & 4 deletions cypress/tests/ui/flowchart/shareable-urls.cy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
describe('Shareable URLs with empty localStorage', () => {
beforeEach(() => {
// Clears localStorage before each test
cy.clearLocalStorage();
});

it('verifies that users can open the Deploy Kedro-Viz modal if the localStorage is empty. #TC-52', () => {
// Intercept the network request to mock with a fixture
Expand Down
7 changes: 6 additions & 1 deletion cypress/tests/ui/toolbar/global-toolbar.cy.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
// All E2E Tests Related to global-toolbar goes here.

import { prettifyName, stripNamespace } from '../../../../src/utils';
import { localStorageETDeprecationBannerSeen } from '../../../../src/config';

describe('Global Toolbar', () => {
before(() => {
cy.visit('/'); // Visit the application
cy.visit('/', {
onBeforeLoad(win) {
win.localStorage.setItem(localStorageETDeprecationBannerSeen, JSON.stringify(true));
}
});
cy.enablePrettyNames(); // Enable pretty names using the custom command
});

Expand Down
2 changes: 1 addition & 1 deletion demo-project/.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.1.0
10.2.0
2 changes: 1 addition & 1 deletion demo-project/lightsail.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"serviceName": "kedro-viz-live-demo",
"containers": {
"kedro-viz-live-demo": {
"image": "public.ecr.aws/g0x0s3o2/kedro-viz-live-demo:10.1.0",
"image": "public.ecr.aws/g0x0s3o2/kedro-viz-live-demo:10.2.0",
"ports": {
"4141": "HTTP"
}
Expand Down
2 changes: 1 addition & 1 deletion docs/source/experiment_tracking.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Experiment tracking in Kedro-Viz

```{important}
Starting from version 8.0.0 of Kedro-Viz, Experiment Tracking is exclusively supported for users with kedro-datasets version 2.1.0 or higher.
Starting from Kedro-Viz 11.0.0, native experiment tracking will be deprecated in Kedro and Kedro-Viz. To enable experiment tracking in Kedro with MLflow, follow the migrate to [`kedro-mlflow` documentation](./migrate_experiment_tracking.md).
```

Experiment tracking is the process of saving all the metadata related to an experiment each time you run it. It enables you to compare different runs of a machine-learning model as part of the experimentation process.
Expand Down
1 change: 1 addition & 0 deletions docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ share_kedro_viz
preview_datasets
slice_a_pipeline
experiment_tracking
migrate_experiment_tracking
```

```{toctree}
Expand Down
139 changes: 139 additions & 0 deletions docs/source/migrate_experiment_tracking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Migration from Kedro-Viz native experiment tracking to `kedro-mlflow`

With the deprecation of Kedro-Viz experiment tracking from version 11.0.0, transitioning to [`kedro-mlflow`](https://kedro-mlflow.readthedocs.io/en/stable/) offers enhanced experiment tracking and artifact management. This guide outlines the steps to:

1. **Remove deprecated Kedro-Viz experiment tracking configurations.**
2. **Update existing dataset configurations in the catalog to use `kedro-mlflow`.**
3. **Optionally, delete old experiment tracking data.**

## Remove deprecated Kedro-Viz experiment tracking configurations

### 1. Remove session store setup

In `src/<project_name>/settings.py`, locate and remove the session store configuration:

```python
from kedro_viz.integrations.kedro.sqlite_store import SQLiteStore

SESSION_STORE_CLASS = SQLiteStore
SESSION_STORE_ARGS = {"path": str(Path(__file__).parents[2] / "data")}
```

### 2. Remove environment variables
Remove any environment variables associated with collaborative tracking:

```bash
unset KEDRO_SQLITE_STORE_USERNAME
```

### 3. Delete SQLite database
If a `session_store.db` SQLite database was created, you can delete it to clean up your project. This file is typically located in one of the following directories:

- The project root
- The `.viz` folder within the project root
- The `data` folder

## Update dataset configurations in catalog to use `kedro-mlflow`

Update the dataset configurations in your `catalog.yml` to transition to `kedro-mlflow`. Refer to the table below for the changes:

### Dataset migration table

| Kedro-Viz Dataset Type | MLflow Dataset Type | Update Instructions |
|---------------------------------|----------------------------|---------------------------------------------------------|
| `tracking.MetricsDataset` | `MlflowMetricDataset` | Update type to [`MlflowMetricDataset`](https://kedro-mlflow.readthedocs.io/en/stable/source/31_API/kedro_mlflow.io.html#kedro_mlflow.io.metrics.mlflow_metric_dataset.MlflowMetricDataset). |
| `tracking.JSONDataset` | `MlflowArtifactDataset` | Wrap within [`MlflowArtifactDataset`](https://kedro-mlflow.readthedocs.io/en/stable/source/31_API/kedro_mlflow.io.html#kedro_mlflow.io.artifacts.mlflow_artifact_dataset.MlflowArtifactDataset) as `json.JSONDataset`. |
| `plotly.plotlyDataset` | `MlflowArtifactDataset` | Wrap within [`MlflowArtifactDataset`](https://kedro-mlflow.readthedocs.io/en/stable/source/31_API/kedro_mlflow.io.html#kedro_mlflow.io.artifacts.mlflow_artifact_dataset.MlflowArtifactDataset) as `plotly.HTMLDataset`. |
| `plotly.JSONDataset` | `MlflowArtifactDataset` | Wrap within [`MlflowArtifactDataset`](https://kedro-mlflow.readthedocs.io/en/stable/source/31_API/kedro_mlflow.io.html#kedro_mlflow.io.artifacts.mlflow_artifact_dataset.MlflowArtifactDataset) as `plotly.HTMLDataset`. |
| `matplotlib.MatplotlibWriter` | `MlflowArtifactDataset` | Wrap within [`MlflowArtifactDataset`](https://kedro-mlflow.readthedocs.io/en/stable/source/31_API/kedro_mlflow.io.html#kedro_mlflow.io.artifacts.mlflow_artifact_dataset.MlflowArtifactDataset). |

### Metrics dataset
For `tracking.MetricsDataset`, update its type to [`MlflowMetricDataset`](https://kedro-mlflow.readthedocs.io/en/stable/source/31_API/kedro_mlflow.io.html#kedro_mlflow.io.metrics.mlflow_metric_dataset.MlflowMetricDataset):

Before:
```yaml
metrics:
type: tracking.MetricsDataset
filepath: data/09_tracking/metrics.json
versioned: true
```
After:
```yaml
metrics:
type: kedro_mlflow.io.metrics.MlflowMetricDataset
```
### JSON dataset
For `tracking.JSONDataset`, wrap it within [`MlflowArtifactDataset`](https://kedro-mlflow.readthedocs.io/en/stable/source/31_API/kedro_mlflow.io.html#kedro_mlflow.io.artifacts.mlflow_artifact_dataset.MlflowArtifactDataset) and configure it as `json.JSONDataset`:

Before:
```yaml
companies_columns:
type: tracking.JSONDataset
filepath: data/09_tracking/json_data.json
versioned: true
```

After:
```yaml
companies_columns:
type: kedro_mlflow.io.artifacts.MlflowArtifactDataset
dataset:
type: json.JSONDataset
filepath: data/02_intermediate/companies_columns.json
```

### Plotly dataset
For `plotly.plotlyDataset` and `plotly.JSONDataset`, wrap it within [`MlflowArtifactDataset`](https://kedro-mlflow.readthedocs.io/en/stable/source/31_API/kedro_mlflow.io.html#kedro_mlflow.io.artifacts.mlflow_artifact_dataset.MlflowArtifactDataset) and configure it as `plotly.HTMLDataset` to render interactive plots in the MLflow UI:

Before:
```yaml
plotly_json_data:
type: plotly.JSONDataset
filepath: data/09_tracking/plotly.json
```

After:
```yaml
plotly_json_data:
type: kedro_mlflow.io.artifacts.MlflowArtifactDataset
dataset:
type: plotly.HTMLDataset
filepath: data/08_reporting/plotly.html
```

### Matplotlib writer
For `matplotlib.MatplotlibWriter`, wrap it within [`MlflowArtifactDataset`](https://kedro-mlflow.readthedocs.io/en/stable/source/31_API/kedro_mlflow.io.html#kedro_mlflow.io.artifacts.mlflow_artifact_dataset.MlflowArtifactDataset):

Before:
```yaml
confusion_matrix:
type: matplotlib.MatplotlibWriter
filepath: data/09_tracking/confusion_matrix.png
versioned: true
```

After:
```yaml
confusion_matrix:
type: kedro_mlflow.io.artifacts.MlflowArtifactDataset
dataset:
type: matplotlib.MatplotlibWriter
filepath: data/08_reporting/confusion_matrix.png
```

## [Optional] Delete old tracking data

Old experiment tracking data stored in `data/09_tracking/` is no longer needed. You can delete this directory to clean up your project:

```bash
rm -rf data/09_tracking/
```

## Refer to the `kedro-mlflow` documentation for further setup

After completing these steps, follow the below MLflow documentation to complete your experiment tracking setup with MLflow.

- [The official Kedro + MLflow guide in the Kedro documentation](https://docs.kedro.org/en/stable/integrations/mlflow.html)
- The documentation of [`kedro-mlflow`](https://docs.kedro.org/en/latest/integrations/mlflow.html) plugin
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@quantumblack/kedro-viz",
"version": "10.1.0",
"version": "10.2.0",
"description": "Kedro-Viz is an interactive development tool for building data science pipelines with Kedro.",
"main": "lib/components/app/index.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion package/kedro_viz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
import warnings

__version__ = "10.1.0"
__version__ = "10.2.0"


class KedroVizPythonVersionWarning(UserWarning):
Expand Down
17 changes: 13 additions & 4 deletions package/kedro_viz/integrations/kedro/lite_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,17 @@ def parse(self, target_path: Path) -> Union[Dict[str, Set[str]], None]:
unresolved_imports: Dict[str, Set[str]] = {}

if target_path.is_file():
missing_dependencies = self._get_unresolved_imports(target_path)
if len(missing_dependencies) > 0:
unresolved_imports[str(target_path)] = missing_dependencies
try:
missing_dependencies = self._get_unresolved_imports(target_path)
if len(missing_dependencies) > 0:
unresolved_imports[str(target_path)] = missing_dependencies
except Exception as exc: # noqa: BLE001
logger.error(
"An error occurred in LiteParser while mocking dependencies in %s : %s",
target_path,
exc,
)

return unresolved_imports

# handling directories
Expand All @@ -263,7 +271,8 @@ def parse(self, target_path: Path) -> Union[Dict[str, Set[str]], None]:
unresolved_imports[str(file_path)] = missing_dependencies
except Exception as exc: # noqa: BLE001 # pragma: no cover
logger.error(
"An error occurred in LiteParser while mocking dependencies : %s",
"An error occurred in LiteParser while mocking dependencies in %s : %s",
file_path,
exc,
)
continue
Expand Down
6 changes: 6 additions & 0 deletions package/kedro_viz/launchers/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ def run( # noqa: PLR0915
)
return

display_cli_message(
"WARNING: Experiment Tracking on Kedro-viz will be deprecated in Kedro-Viz 11.0.0. "
"Please refer to the Kedro documentation for migration guidance.",
"yellow",
)

installed_version = parse(__version__)
latest_version = get_latest_version()
if is_running_outdated_version(installed_version, latest_version):
Expand Down
2 changes: 1 addition & 1 deletion package/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Tracker = "https://github.com/kedro-org/kedro-viz/issues"

[project.optional-dependencies]
docs = [
"kedro-sphinx-theme==2024.10.2",
"kedro-sphinx-theme==2024.10.3",
]
aws = ["s3fs>=2021.4"]
azure = ["adlfs>=2021.4"]
Expand Down
19 changes: 19 additions & 0 deletions package/tests/test_integrations/test_lite_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,25 @@ def test_file_parse(self, lite_parser, sample_project_path):

assert unresolved_imports == {str(file_path): {"nonexistentmodule"}}

def test_parse_logs_error_on_exception(self, lite_parser, tmp_path, caplog):
file_path = Path(tmp_path / "mock_spaceflights/data_processing_non_utf.py")
file_path.parent.mkdir(parents=True, exist_ok=True)

# Write non-UTF characters (e.g., using ISO-8859-1 encoding)
non_utf_content = "This is a test with non-UTF characters: é, ñ, ü"

# Write the file in ISO-8859-1 encoding
with open(file_path, "w", encoding="ISO-8859-1") as f:
f.write(non_utf_content)

assert file_path.exists()

lite_parser.parse(file_path)
assert (
f"An error occurred in LiteParser while mocking dependencies in {str(file_path)}"
in caplog.text
)

def test_directory_parse(self, lite_parser, sample_project_path):
unresolved_imports = lite_parser.parse(sample_project_path)
expected_file_path = Path(
Expand Down
Loading

0 comments on commit e0b7677

Please sign in to comment.