Skip to content

Commit

Permalink
Demo slicing pipeline final (#2036)
Browse files Browse the repository at this point in the history
* set actions - filters

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* set reducers - filters

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* set reducers - filtered-pipeline

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* user getFilteredPipeline in disabled

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* set eslint

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* first setup in flowchart

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* include isDisabledViaFilters in disabled

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* highlight multi-select nodes

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* use local state instead

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* remove extra action

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* shifting the logic around for shift hold the node

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* create a separate state for highlighting node

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* firt working version of highlighting the node list

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* remove the extra selector and action

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* first draft of highlighting the node list

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* hide the slicing button

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* remove extra node selector

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* set click outside to clear highlighting node

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* slice pipeline component

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* handle click on the third node

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* reset filter nodes on click on the node list

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* create utils function for filtering nodes in draw.js

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* adding comments for componentDidUpdate

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* remove un-used selectors

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* rename filteredPipeline state and classname

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* include filters in normalize data

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update normalize data

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* test for reducers

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* write test for selector

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* changes to test the tests locally

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* responsive cta button

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update failed test

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* fix failed e2e tests

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* adding transformX value for button

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* add slice btn functionality

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* remove unused props

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* fix console error where the same id applies twice

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* prevent resetting on onclick slice btn

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* first working version of dilerting node list

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* filtering node list on the left

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* filter out modular pipeline if no nodes selected

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* include reset button

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* cy:test close the hint feature so can click on a node

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* run command selector

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* include command copier

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* UI for command line

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* avoid reseting when clicking on a node while filters is activated

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* Add comment

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* test to cover the run-command selector

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* no holdshift click on nodes when filters are applied

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* rename component and apply light theme

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* move theme to shared variable

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* fix typo

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* close the hint feature in cy test

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* lower case for one of the cy test

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* remove pretify name as its already set

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update component name

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* fix merge conflict and update classname for FilteredPipelineActionBar

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update classnames to match the new component name

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* change the styling for filtered nodes

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* refactor the logic to make it clearer

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* temporary solution for styling highlighting state

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update name for selector and flowchart, draw and node-list components

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* rename for state and action

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update name for action bar

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update name for css

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* add notification

Signed-off-by: Sajid Alam <[email protected]>

* rename

Signed-off-by: Sajid Alam <[email protected]>

* Use SlicedPipelineActionBar

Signed-off-by: Sajid Alam <[email protected]>

* fix other merge conflict

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* Update flowchart.test.js

Signed-off-by: Sajid Alam <[email protected]>

* styling for long run command

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* adjust some styling

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* remove the styling for node list

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update failed test and use visibleSidebar instead

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* fix typo

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* tidy up code

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update name in test

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* add tests for util functions

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update logic for selector nodes

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* remove --over-write class on row as it's causing a bug

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* merge

Signed-off-by: Sajid Alam <[email protected]>

* Update flowchart.js

Signed-off-by: Sajid Alam <[email protected]>

* remove overwrite styling as it causing a bug

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* Revert "Merge branch 'feature/slicing-pipeline--run-command' into feature/slicing-notification"

This reverts commit dd0d30b, reversing
changes made to 5e02618.

* include 2 new props in flowchart test

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* change the position when meta panel opens

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update some colour with the new design changes

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* selecting a node from bottom to top, the order should not matter

Signed-off-by: Sajid Alam <[email protected]>

* Update flowchart.js

Signed-off-by: Sajid Alam <[email protected]>

* center the notification

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* center the action bar

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* using existing function to update state

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* use redux instead of local state

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* tidy up code

Signed-off-by: Sajid Alam <[email protected]>

* update colours

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* only style from to pipeline if both of them are defined

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* fix the fading styling

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* add test

Signed-off-by: Sajid Alam <[email protected]>

* simplify the code

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* changes based on review

Signed-off-by: Sajid Alam <[email protected]>

* update variable names

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* adding comments to explain

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* rename ActionBar to slicePipelineActionBar

Signed-off-by: Sajid Alam <[email protected]>

* reorder code

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update comment and function name

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* set minimum transformX value

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update function name in test

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* Adjust the transform value to 0.3s

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update config value for calculating postion

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update positioning logic

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* removed unncesscary this.props.slicedPipeline

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* include extra check for data.name

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* add || rather than &&

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* add hover style for the slice button

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* hover style for reset button

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* hover style for copy button

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* fix padding for action bar

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* first working version of box shadow

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* fix position and transition issue

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* fix the issue when selecting on the node again the second time

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* set button heigh and position of the tooltip

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update slicing notification when metadata panel is closed

Signed-off-by: Sajid Alam <[email protected]>

* Update flowchart.js

Signed-off-by: Sajid Alam <[email protected]>

* remove line at end of notification bar

Signed-off-by: Sajid Alam <[email protected]>

* persist from node from user selection

Signed-off-by: Sajid Alam <[email protected]>

* box shadow using after class

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* fix the from node bug

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* increase box shadow length

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* fix bug

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update buffer name

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update function name

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* fix merge commit

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* separate action bar and notification

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* remove unused mixin

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* include extra check for run command length

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* include test for notification

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* fix bug on highlighting node list in slicing mode

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* new animation for action bar

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* fix bug about the number of sliced pipeline

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* add new props in test

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* Feature/slicing pipeline add notification (#2003)

* change order only when store updated

Signed-off-by: Sajid Alam <[email protected]>

* update tests

Signed-off-by: Sajid Alam <[email protected]>

* changes based on review

Signed-off-by: Sajid Alam <[email protected]>

* Set showSlicingNotification to true if a single node is clicked

Signed-off-by: Sajid Alam <[email protected]>

* Update flowchart.js

Signed-off-by: Sajid Alam <[email protected]>

* enable notification when single node is clicked

Signed-off-by: Sajid Alam <[email protected]>

* Delete sliced-pipeline-action-bar.test.js

Signed-off-by: Sajid Alam <[email protected]>

* add comments

Signed-off-by: Sajid Alam <[email protected]>

* merge

Signed-off-by: Sajid Alam <[email protected]>

---------

Signed-off-by: Sajid Alam <[email protected]>

* highlight modularpipeline when collasped in slicing mode

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update slice button color

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* removed unused props

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update name for slicePipeline

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update test with new name for SET_SLICE_PIPELINE

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* get runCommand based on type of the element

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update run command to get from metadata

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* add comments

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update test for sliced-pipeline

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update run-command test with new logic

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* Disable slicing feature in embedded mode (#2072)

* Disable slicing feature in embedded mode

Signed-off-by: Jitendra Gundaniya <[email protected]>

* test fix

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Name fix

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Moved visibleSlicing prop under visible

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Test fix

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Remove unused code

Signed-off-by: Jitendra Gundaniya <[email protected]>

---------

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Telemetry/slicing pipeline (#2054)

* adding data-test

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* include getDataTestAttribute

Signed-off-by: Huong Nguyen <huongg1409@gmail>

---------

Signed-off-by: Huong Nguyen <huongg1409@gmail>
Co-authored-by: Huong Nguyen <huongg1409@gmail>

* fix the highlight of modular pipeline

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* fix the position of run command

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* use 1.5 instead 2 for divided value

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* Documentation: slicing pipeline in kedro-viz (#2043)

* first draft

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* fix typo

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* include gif

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* use uncapital words

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* remove the word just

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* remove #

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* use verb instead of slicing

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* use stable version

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* include new gif and increase the size

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* remove un-used gif

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* remove ./ in path

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* revert back to previous syntax

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* reuploaded gif files

Signed-off-by: Huong Nguyen <huongg1409@gmail>

* update text

Co-authored-by: rashidakanchwala <[email protected]>
Signed-off-by: Huong Nguyen <[email protected]>

* update text

Co-authored-by: rashidakanchwala <[email protected]>
Signed-off-by: Huong Nguyen <[email protected]>

* update text

Co-authored-by: rashidakanchwala <[email protected]>
Signed-off-by: Huong Nguyen <[email protected]>

* update text

Co-authored-by: rashidakanchwala <[email protected]>
Signed-off-by: Huong Nguyen <[email protected]>

---------

Signed-off-by: Huong Nguyen <huongg1409@gmail>
Signed-off-by: Huong Nguyen <[email protected]>
Co-authored-by: Huong Nguyen <huongg1409@gmail>
Co-authored-by: rashidakanchwala <[email protected]>

* update release note

Signed-off-by: Huong Nguyen <huongg1409@gmail>

---------

Signed-off-by: Huong Nguyen <huongg1409@gmail>
Signed-off-by: Sajid Alam <[email protected]>
Signed-off-by: Sajid Alam <[email protected]>
Signed-off-by: Jitendra Gundaniya <[email protected]>
Signed-off-by: Huong Nguyen <[email protected]>
Co-authored-by: Huong Nguyen <huongg1409@gmail>
Co-authored-by: Sajid Alam <[email protected]>
Co-authored-by: Sajid Alam <[email protected]>
Co-authored-by: Jitendra Gundaniya <[email protected]>
Co-authored-by: rashidakanchwala <[email protected]>
  • Loading branch information
6 people committed Sep 6, 2024
1 parent 0ff262e commit cc1a119
Show file tree
Hide file tree
Showing 49 changed files with 1,338 additions and 59 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"curly": ["error"],
"valid-typeof": ["error"],
"camelcase": "error",
"id-length": ["error", { "min": 3, "exceptions": ["_","a","b","d","e","i","j","k","x","y","id","el","pi","PI","up"] }],
"no-var": ["error"],
"id-length": ["error", { "min": 3, "exceptions": ["_","a","b","d","e","i","j","k","x","y","id","el","pi","PI","up","to"] }], "no-var": ["error"],
"lines-between-class-members": ["error", "always"]
}
}
Expand Down
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Please follow the established format:
## Major features and improvements

- Introduce `onActionCallback` prop in Kedro-Viz react component. (#2022)
- Slice a pipeline functionality. (#2036)

## Bug fixes and other changes

Expand Down
7 changes: 4 additions & 3 deletions cypress/tests/ui/flowchart/flowchart.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ describe('Flowchart DAG', () => {

beforeEach(() => {
cy.enablePrettyNames(); // Enable pretty names using the custom command
cy.wait(500);
cy.get('.feature-hints__close').click(); // Close the feature hints so can click on a node
cy.wait(500);
});

it('verifies that users can expand a collapsed modular pipeline in the flowchart. #TC-23', () => {
const modularPipelineText = 'feature_engineering';
const taskNodeText = 'Create Derived Features';

cy.enablePrettyNames();
const taskNodeText = 'create_derived_features';

// Assert before action
cy.get('.pipeline-node > .pipeline-node__text').should(
Expand Down
7 changes: 4 additions & 3 deletions cypress/tests/ui/flowchart/menu.cy.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// All E2E Tests Related to Flowchart Menu goes here.

import { prettifyName } from '../../../../src/utils';

describe('Flowchart Menu', () => {
beforeEach(() => {
cy.enablePrettyNames(); // Enable pretty names using the custom command
cy.wait(500);
cy.get('.feature-hints__close').click(); // Close the feature hints so can click on a node
cy.wait(500);
});

it('verifies that users can select a section of the flowchart through the drop down. #TC-16', () => {
Expand Down Expand Up @@ -144,7 +145,7 @@ describe('Flowchart Menu', () => {
.invoke('text')
.then((focusedNodesText) =>
expect(focusedNodesText.toLowerCase()).to.contains(
prettifyName(nodeToFocusText).toLowerCase()
nodeToFocusText
)
);
cy.get('.pipeline-node--active > .pipeline-node__text').should(
Expand Down
3 changes: 2 additions & 1 deletion cypress/tests/ui/flowchart/panel.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe('Pipeline Minimap Toolbar', () => {
cy.__waitForPageLoad__(() => {
let initialZoomValue;
let zoomInValue;

cy.get('@zoomScale')
.invoke('text')
.then((text) => {
Expand Down Expand Up @@ -155,6 +155,7 @@ describe('Pipeline Minimap Toolbar', () => {
cy.get('@zoomScale')
.invoke('text')
.should((text) => {
initialZoomValue = parseFloat(text.replace('%', ''));
expect(initialZoomValue).to.be.eq(parseFloat(text.replace('%', '')));
});
});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/images/slice_pipeline_slice_reset.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Take a look at the <a href="https://demo.kedro.org/" target="_blank" rel="noopen
kedro-viz_visualisation
share_kedro_viz
preview_datasets
slice_a_pipeline
experiment_tracking
```

Expand Down
33 changes: 33 additions & 0 deletions docs/source/slice_a_pipeline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Slice a pipeline

Slicing a pipeline in Kedro refers to creating a subset of a pipeline's nodes, which can help in focusing on specific parts of the pipeline. There are two primary ways to achieve this:

1. **Programmatically with the Kedro CLI.** This method is suitable for those comfortable with command-line tools. Detailed steps on how to achieve this are available in the kedro documentation: [Slice a Pipeline](https://docs.kedro.org/en/stable/nodes_and_pipelines/slice_a_pipeline.html).

2. **Visually through Kedro-Viz:** This approach allows you to visually select and slice pipeline nodes, which then generates a run command for executing the slice within your Kedro project.

## Benefits of Kedro-Viz slicing

- **Visual Representation:** View the relationships between nodes and identify which ones are part of your slice.
- **Immediate Command Generation:** Get a ready-to-use CLI command for executing the sliced pipeline.
- **Interactive Control:** Visually select and reset slices with a couple of clicks.

## Steps to slice in Kedro-Viz

Kedro-Viz offers a user-friendly visual interface for slicing pipelines. Follow these steps to use the slicing feature:

1. **Select elements in the flowchart:** In Kedro-Viz, select two elements to set the boundaries for your slice:
- Click on the first node you want to include.
- Hold the Shift key and select the second node.

![](./images/slice_pipeline_multiple_click.gif)

2. **Highlighted selection:** The flowchart will highlight all nodes between the selected elements, and the corresponding nodes in the list on the left will also be highlighted.

3. **View the run command:** After selecting the nodes, Kedro-Viz generates a CLI command for the sliced pipeline. You can copy this command and use it directly in your Kedro project to run the slice.

4. **Slice the pipeline:** When you're ready, click the "Slice" button. This opens a new view where you can directly interact with the sliced pipeline.

5. **Reset:** To discard your selection and return to the full pipeline view, click the "Reset" button. This will clear the slice and restore the default view.

![](./images/slice_pipeline_slice_reset.gif)
28 changes: 28 additions & 0 deletions src/actions/slice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export const APPLY_SLICE_PIPELINE = 'APPLY_SLICE_PIPELINE';

export const applySlicePipeline = (apply) => {
return async function (dispatch) {
dispatch({
type: APPLY_SLICE_PIPELINE,
apply,
});
};
};

export const SET_SLICE_PIPELINE = 'SET_SLICE_PIPELINE';

export const setSlicePipeline = (from, to) => {
return async function (dispatch) {
dispatch({
type: SET_SLICE_PIPELINE,
slice: { from, to },
});
};
};

export const RESET_SLICE_PIPELINE = 'RESET_SLICE_PIPELINE';

export const resetSlicePipeline = () => ({
type: RESET_SLICE_PIPELINE,
slice: { from: null, to: null },
});
2 changes: 1 addition & 1 deletion src/components/app/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
--color-bg-1: #{colors.$white-800};
--color-bg-2: #{colors.$grey-0};
--color-bg-3: #{colors.$white-200};
--color-bg-4: #{colors.$white-0};
--color-bg-4: #{colors.$white-200};
--color-bg-5: #{colors.$white-600};
--color-bg-alt: #{colors.$black-700};
--color-bg-list: #{colors.$white-100};
Expand Down
1 change: 0 additions & 1 deletion src/components/app/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { localStorageName } from '../../config';
import { prepareNonPipelineState } from '../../store/initial-state';
import reducer from '../../reducers/index';
import { TOGGLE_GRAPH_LOADING } from '../../actions/graph';
import { prettifyName } from '../../utils/index';

describe('App', () => {
const getState = (wrapper) => wrapper.instance().store.getState();
Expand Down
38 changes: 38 additions & 0 deletions src/components/flowchart/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ const toSinglePoint = (value) => parseFloat(value).toFixed(1);
*/
const limitPrecision = (path) => path.replace(matchFloats, toSinglePoint);

/**
* Creates a mapping of node IDs to a boolean indicating if the node ID is included in the given values.
* @param {Array} nodes - Array of nodes to process.
* @param {Array} values - Array of values to check against node IDs.
* @returns {Object} An object mapping node IDs to booleans.
*/
function createNodeStateMap(nodes, values) {
const valueSet = new Set(values); // Convert to Set for efficient lookup
return nodes.reduce((acc, { id }) => {
acc[id] = valueSet.has(id);
return acc;
}, {});
}

/**
* Render layer bands
*/
Expand Down Expand Up @@ -135,7 +149,20 @@ export const drawNodes = function (changed) {
nodes,
focusMode,
hoveredFocusMode,
isSlicingPipelineApplied,
} = this.props;
const {
from: slicedPipelineFromId,
to: slicedPipelineToId,
range,
} = this.state.slicedPipelineState;

const slicedPipelineFromTo =
slicedPipelineFromId &&
slicedPipelineToId &&
createNodeStateMap(nodes, [slicedPipelineFromId, slicedPipelineToId]);

const slicedPipelineRange = createNodeStateMap(nodes, range);

const isInputOutputNode = (nodeID) =>
focusMode !== null && inputOutputDataNodes[nodeID];
Expand Down Expand Up @@ -241,6 +268,17 @@ export const drawNodes = function (changed) {
allNodes
.classed('pipeline-node--active', (node) => nodeActive[node.id])
.classed('pipeline-node--selected', (node) => nodeSelected[node.id])
.classed(
'pipeline-node--sliced-pipeline',
(node) => !isSlicingPipelineApplied && slicedPipelineRange[node.id]
)
.classed(
'pipeline-node--from-to-sliced-pipeline',
(node) =>
!isSlicingPipelineApplied &&
slicedPipelineFromTo &&
slicedPipelineFromTo[node.id]
)
.classed(
'pipeline-node--collapsed-hint',
(node) =>
Expand Down
Loading

0 comments on commit cc1a119

Please sign in to comment.