Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prepopulate output literals with TaskNode interface output variables
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Rammer <[email protected]>
hamersaw committed Mar 20, 2024
1 parent eb24107 commit c817216
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions flytepropeller/pkg/controller/nodes/array/handler.go
Original file line number Diff line number Diff line change
@@ -478,7 +478,38 @@ func (a *arrayNodeHandler) Handle(ctx context.Context, nCtx interfaces.NodeExecu
gatherOutputsRequests = append(gatherOutputsRequests, gatherOutputsRequest)
}

// attempt best effort at initializing outputLiterals with output variable names. currently
// only TaskNode and WorkflowNode contain node interfaces.
outputLiterals := make(map[string]*idlcore.Literal)

switch arrayNode.GetSubNodeSpec().GetKind() {
case v1alpha1.NodeKindTask:
taskID := *arrayNode.GetSubNodeSpec().TaskRef
taskNode, err := nCtx.ExecutionContext().GetTask(taskID)
if err != nil {
return handler.DoTransition(handler.TransitionTypeEphemeral, handler.PhaseInfoFailure(idlcore.ExecutionError_SYSTEM,
errors.BadSpecificationError, fmt.Sprintf("failed to find ArrayNode subNode task with id: '%s'", taskID), nil)), nil
}

Check warning on line 492 in flytepropeller/pkg/controller/nodes/array/handler.go

Codecov / codecov/patch

flytepropeller/pkg/controller/nodes/array/handler.go#L486-L492

Added lines #L486 - L492 were not covered by tests

if outputs := taskNode.CoreTask().GetInterface().GetOutputs(); outputs != nil {
for name := range outputs.Variables {
outputLiteral := &idlcore.Literal{
Value: &idlcore.Literal_Collection{
Collection: &idlcore.LiteralCollection{
Literals: make([]*idlcore.Literal, 0, len(arrayNodeState.SubNodePhases.GetItems())),
},
},
}

outputLiterals[name] = outputLiteral
}

Check warning on line 505 in flytepropeller/pkg/controller/nodes/array/handler.go

Codecov / codecov/patch

flytepropeller/pkg/controller/nodes/array/handler.go#L494-L505

Added lines #L494 - L505 were not covered by tests
}
case v1alpha1.NodeKindWorkflow:
fallthrough

Check warning on line 508 in flytepropeller/pkg/controller/nodes/array/handler.go

Codecov / codecov/patch

flytepropeller/pkg/controller/nodes/array/handler.go#L507-L508

Added lines #L507 - L508 were not covered by tests
default:
logger.Warnf(ctx, "ArrayNode does not support pre-populating outputLiteral collections for node kind '%s'", arrayNode.GetSubNodeSpec().GetKind())
}

workerErrorCollector := errorcollector.NewErrorMessageCollector()
for i, gatherOutputsRequest := range gatherOutputsRequests {
outputResponse := <-gatherOutputsRequest.responseChannel

0 comments on commit c817216

Please sign in to comment.