Skip to content

Commit

Permalink
show full run command syntax
Browse files Browse the repository at this point in the history
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.
24 changes: 16 additions & 8 deletions src/selectors/run-command.js
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}`;
}
);

0 comments on commit af73fd6

Please sign in to comment.