-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Huong Nguyen <[email protected]>
- Loading branch information
Huong Nguyen
committed
Jan 3, 2025
1 parent
d4c54eb
commit af73fd6
Showing
1 changed file
with
16 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
import { createSelector } from 'reselect'; | ||
|
||
const getSlicedPipelineState = (state) => state.slice; | ||
const getNodesRunCommand = (state) => state.node.runCommand; | ||
const getSlicedPipeline = (state) => state.slice; | ||
const getNodesNames = (state) => state.node.fullName; | ||
const getNodesTypes = (state) => state.node.type; | ||
|
||
export const getRunCommand = createSelector( | ||
[getSlicedPipelineState, getNodesRunCommand], | ||
(slicedPipelineState, nodeRunCommand) => { | ||
const { from, to } = slicedPipelineState; | ||
[getSlicedPipeline, getNodesNames, getNodesTypes], | ||
(slicedPipeline, nodesNames, nodesTypes) => { | ||
const { from, to } = slicedPipeline; | ||
|
||
if (!from || !to) { | ||
return null; | ||
} | ||
|
||
const slicingPipelineCommand = | ||
nodeRunCommand[to] || 'please define a run command for this node'; | ||
return slicingPipelineCommand; | ||
const fromNodeName = nodesNames[from]; | ||
const toNodeName = nodesNames[to]; | ||
const fromNodeType = nodesTypes[from]; | ||
const toNodeType = nodesTypes[to]; | ||
|
||
// Determine the correct flag based on the node type | ||
const fromFlag = fromNodeType === 'data' ? '--from-inputs' : '--from-nodes'; | ||
const toFlag = toNodeType === 'data' ? '--to-outputs' : '--to-nodes'; | ||
|
||
return `kedro run ${fromFlag}=${fromNodeName} ${toFlag}=${toNodeName}`; | ||
} | ||
); |