@@ -414,6 +414,7 @@ func DAG(ctx context.Context, opts Options, mlmd *metadata.Client) (execution *E
414
414
executorInput := & pipelinespec.ExecutorInput {
415
415
Inputs : inputs ,
416
416
}
417
+ glog .Infof ("executorInput value: %+v" , executorInput )
417
418
execution = & Execution {ExecutorInput : executorInput }
418
419
condition := opts .Task .GetTriggerPolicy ().GetCondition ()
419
420
if condition != "" {
@@ -436,14 +437,37 @@ func DAG(ctx context.Context, opts Options, mlmd *metadata.Client) (execution *E
436
437
return execution , fmt .Errorf ("ArtifactIterator is not implemented" )
437
438
}
438
439
isIterator := opts .Task .GetParameterIterator () != nil && opts .IterationIndex < 0
440
+ // Fan out iterations
439
441
if execution .WillTrigger () && isIterator {
440
442
iterator := opts .Task .GetParameterIterator ()
441
- value , ok := executorInput .GetInputs ().GetParameterValues ()[iterator .GetItems ().GetInputParameter ()]
442
443
report := func (err error ) error {
443
444
return fmt .Errorf ("iterating on item input %q failed: %w" , iterator .GetItemInput (), err )
444
445
}
445
- if ! ok {
446
- return execution , report (fmt .Errorf ("cannot find input parameter" ))
446
+ // Check the items type of parameterIterator:
447
+ // It can be "inputParameter" or "Raw"
448
+ var value * structpb.Value
449
+ switch iterator .GetItems ().GetKind ().(type ) {
450
+ case * pipelinespec.ParameterIteratorSpec_ItemsSpec_InputParameter :
451
+ var ok bool
452
+ value , ok = executorInput .GetInputs ().GetParameterValues ()[iterator .GetItems ().GetInputParameter ()]
453
+ if ! ok {
454
+ return execution , report (fmt .Errorf ("cannot find input parameter" ))
455
+ }
456
+ case * pipelinespec.ParameterIteratorSpec_ItemsSpec_Raw :
457
+ value_raw := iterator .GetItems ().GetRaw ()
458
+ var unmarshalled_raw interface {}
459
+ err = json .Unmarshal ([]byte (value_raw ), & unmarshalled_raw )
460
+ if err != nil {
461
+ return execution , fmt .Errorf ("error unmarshall raw string: %q" , err )
462
+ }
463
+ value , err = structpb .NewValue (unmarshalled_raw )
464
+ if err != nil {
465
+ return execution , fmt .Errorf ("error converting unmarshalled raw string into protobuf Value type: %q" , err )
466
+ }
467
+ // Add the raw input to the executor input
468
+ execution .ExecutorInput .Inputs .ParameterValues [iterator .GetItemInput ()] = value
469
+ default :
470
+ return execution , fmt .Errorf ("cannot find parameter iterator" )
447
471
}
448
472
items , err := getItems (value )
449
473
if err != nil {
@@ -724,7 +748,16 @@ func resolveInputs(ctx context.Context, dag *metadata.DAG, iterationIndex *int,
724
748
case task .GetArtifactIterator () != nil :
725
749
return nil , fmt .Errorf ("artifact iterator not implemented yet" )
726
750
case task .GetParameterIterator () != nil :
727
- itemsInput := task .GetParameterIterator ().GetItems ().GetInputParameter ()
751
+ var itemsInput string
752
+ if task .GetParameterIterator ().GetItems ().GetInputParameter () != "" {
753
+ // input comes from outside the component
754
+ itemsInput = task .GetParameterIterator ().GetItems ().GetInputParameter ()
755
+ } else if task .GetParameterIterator ().GetItemInput () != "" {
756
+ // input comes from static input
757
+ itemsInput = task .GetParameterIterator ().GetItemInput ()
758
+ } else {
759
+ return nil , fmt .Errorf ("cannot retrieve parameter iterator." )
760
+ }
728
761
items , err := getItems (inputs .ParameterValues [itemsInput ])
729
762
if err != nil {
730
763
return nil , err
0 commit comments