Skip to content

Commit

Permalink
fix: fix code and add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
chuang8511 committed Nov 4, 2024
1 parent 778ca3d commit 53c009a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pkg/component/ai/instillmodel/v0/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ func (e *execution) trigger(ctx context.Context, job *base.Job) error {

ctx = metadata.NewOutgoingContext(ctx, getRequestMetadata(e.SystemVariables))

input := &structpb.Struct{}
err := job.Input.ReadData(ctx, input)
// Read() is deprecated and will be removed in a future version.
// However, Instill Model is still using structpb.Struct for input and output.
// When we move out Read(), we will need to update the Instill Model as well.
input, err := job.Input.Read(ctx)

if err != nil {
return fmt.Errorf("reading input data: %w", err)
Expand Down Expand Up @@ -50,7 +52,16 @@ func (e *execution) trigger(ctx context.Context, job *base.Job) error {
return fmt.Errorf("triggering model: get empty task outputs")
}

return job.Output.WriteData(ctx, res.TaskOutputs[0])
// Write() is deprecated and will be removed in a future version.
// However, Instill Model is still using structpb.Struct for input and output.
// When we move out Write(), we will need to update the Instill Model as well.
err = job.Output.Write(ctx, res.TaskOutputs[0])

if err != nil {
return fmt.Errorf("writing output data: %w", err)
}

return nil
}

func getTriggerInfo(input *structpb.Struct) (*triggerInfo, error) {
Expand Down

0 comments on commit 53c009a

Please sign in to comment.