File tree Expand file tree Collapse file tree 2 files changed +25
-24
lines changed
pkg/component/ai/instillmodel/v0 Expand file tree Collapse file tree 2 files changed +25
-24
lines changed Original file line number Diff line number Diff line change @@ -224,27 +224,3 @@ type triggerInfo struct {
224
224
modelID string
225
225
version string
226
226
}
227
-
228
- func getTriggerInfo (input * structpb.Struct ) (* triggerInfo , error ) {
229
- if input == nil {
230
- return nil , fmt .Errorf ("input is nil" )
231
- }
232
- data , ok := input .Fields ["data" ]
233
- if ! ok {
234
- return nil , fmt .Errorf ("data field not found" )
235
- }
236
- model , ok := data .GetStructValue ().Fields ["model" ]
237
-
238
- if ! ok {
239
- return nil , fmt .Errorf ("model field not found" )
240
- }
241
- modelNameSplits := strings .Split (model .GetStringValue (), "/" )
242
- if len (modelNameSplits ) != 3 {
243
- return nil , fmt .Errorf ("model name should be in the format of <namespace>/<model>/<version>" )
244
- }
245
- return & triggerInfo {
246
- nsID : modelNameSplits [0 ],
247
- modelID : modelNameSplits [1 ],
248
- version : modelNameSplits [2 ],
249
- }, nil
250
- }
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package instillmodel
3
3
import (
4
4
"context"
5
5
"fmt"
6
+ "strings"
6
7
"time"
7
8
8
9
"google.golang.org/grpc/metadata"
@@ -51,3 +52,27 @@ func (e *execution) trigger(ctx context.Context, job *base.Job) error {
51
52
52
53
return job .Output .WriteData (ctx , res .TaskOutputs [0 ])
53
54
}
55
+
56
+ func getTriggerInfo (input * structpb.Struct ) (* triggerInfo , error ) {
57
+ if input == nil {
58
+ return nil , fmt .Errorf ("input is nil" )
59
+ }
60
+ data , ok := input .Fields ["data" ]
61
+ if ! ok {
62
+ return nil , fmt .Errorf ("data field not found" )
63
+ }
64
+ model , ok := data .GetStructValue ().Fields ["model" ]
65
+
66
+ if ! ok {
67
+ return nil , fmt .Errorf ("model field not found" )
68
+ }
69
+ modelNameSplits := strings .Split (model .GetStringValue (), "/" )
70
+ if len (modelNameSplits ) != 3 {
71
+ return nil , fmt .Errorf ("model name should be in the format of <namespace>/<model>/<version>" )
72
+ }
73
+ return & triggerInfo {
74
+ nsID : modelNameSplits [0 ],
75
+ modelID : modelNameSplits [1 ],
76
+ version : modelNameSplits [2 ],
77
+ }, nil
78
+ }
You can’t perform that action at this time.
0 commit comments