Skip to content

Commit 31eef9b

Browse files
authored
Only upload project files when an api has a request handler (#452)
1 parent 00e4c71 commit 31eef9b

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

pkg/operator/context/context.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,27 @@ func New(
5959
consts.MetadataDir,
6060
)
6161

62-
ctx.ProjectID = hash.Bytes(projectBytes)
63-
64-
ctx.ProjectKey = filepath.Join(consts.ProjectsDir, ctx.ProjectID+".zip")
65-
if err = config.AWS.UploadBytesToS3(projectBytes, ctx.ProjectKey); err != nil {
66-
return nil, err
67-
}
62+
projectID := hash.Bytes(projectBytes)
6863

6964
ctx.StatusPrefix = statusPrefix(ctx.App.Name)
70-
apis, err := getAPIs(userconf, ctx.DeploymentVersion, ctx.ProjectID)
65+
apis, err := getAPIs(userconf, ctx.DeploymentVersion, projectID)
7166

7267
if err != nil {
7368
return nil, err
7469
}
7570
ctx.APIs = apis
7671

72+
for _, api := range ctx.APIs {
73+
if api.RequestHandler != nil {
74+
ctx.ProjectID = projectID
75+
ctx.ProjectKey = filepath.Join(consts.ProjectsDir, ctx.ProjectID+".zip")
76+
if err = config.AWS.UploadBytesToS3(projectBytes, ctx.ProjectKey); err != nil {
77+
return nil, err
78+
}
79+
break
80+
}
81+
}
82+
7783
err = ctx.Validate()
7884
if err != nil {
7985
return nil, err

pkg/operator/workloads/api_workload.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,15 @@ func tfAPISpec(
269269
To: path.Join(consts.EmptyDirMountPath, "model"),
270270
ItemName: "model",
271271
},
272-
{
272+
}
273+
274+
if api.RequestHandler != nil {
275+
downloadArgs = append(downloadArgs, downloadContainerArg{
273276
From: config.AWS.S3Path(ctx.ProjectKey),
274277
To: path.Join(consts.EmptyDirMountPath, "project"),
275278
Unzip: true,
276279
ItemName: "project code",
277-
},
280+
})
278281
}
279282

280283
downloadArgsBytes, _ := json.Marshal(downloadArgs)
@@ -441,12 +444,15 @@ func onnxAPISpec(
441444
To: path.Join(consts.EmptyDirMountPath, "model"),
442445
ItemName: "model",
443446
},
444-
{
447+
}
448+
449+
if api.RequestHandler != nil {
450+
downloadArgs = append(downloadArgs, downloadContainerArg{
445451
From: config.AWS.S3Path(ctx.ProjectKey),
446452
To: path.Join(consts.EmptyDirMountPath, "project"),
447453
Unzip: true,
448454
ItemName: "project code",
449-
},
455+
})
450456
}
451457

452458
downloadArgsBytes, _ := json.Marshal(downloadArgs)

0 commit comments

Comments
 (0)