Skip to content

Commit

Permalink
refactor(lib): use isRegrouped validation logic in computeNode function
Browse files Browse the repository at this point in the history
  • Loading branch information
narekhovhannisyan committed Jan 10, 2025
1 parent 9f3273d commit dac9c17
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/if-run/lib/compute.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {PluginParams} from '@grnsft/if-core/types';

import {Regroup} from './regroup';
import {isRegrouped, Regroup} from './regroup';
import {addExplainData} from './explain';

import {debugLogger} from '../../common/util/debug-logger';
Expand All @@ -23,7 +23,7 @@ const {
SKIPPING_REGROUP,
} = STRINGS;

const childNames = new Set();
const childNames = new Set<string>();

/**
* Traverses all child nodes based on children grouping.
Expand Down Expand Up @@ -147,16 +147,7 @@ const computeNode = async (node: Node, params: ComputeParams): Promise<any> => {
if ((noFlags || params.regroup) && pipelineCopy.regroup) {
const originalOutputs = params.append ? node.outputs || [] : [];

// Grabs all the values according to grouping criteria.
const regroupValues = pipelineCopy.regroup
.map(group => [...new Set(outputStorage.map(output => output[group]))])
.flat();
// Checks if regroup values are present in the children list.
const isRegrouped = regroupValues.every(one =>
[...childNames].includes(one)
);

if (!isRegrouped) {
if (!isRegrouped(pipelineCopy.regroup, outputStorage, childNames)) {
node.children = Regroup(
outputStorage,
originalOutputs,
Expand Down

0 comments on commit dac9c17

Please sign in to comment.