Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Only upload project files when an api has a request handler
  • Loading branch information
vishalbollu committed Sep 11, 2019
commit ac0ca8a5bbe44431bbaf91b72a5b7dc821db6bc4
20 changes: 13 additions & 7 deletions pkg/operator/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,27 @@ func New(
consts.MetadataDir,
)

ctx.ProjectID = hash.Bytes(projectBytes)

ctx.ProjectKey = filepath.Join(consts.ProjectsDir, ctx.ProjectID+".zip")
if err = config.AWS.UploadBytesToS3(projectBytes, ctx.ProjectKey); err != nil {
return nil, err
}
projectID := hash.Bytes(projectBytes)

ctx.StatusPrefix = statusPrefix(ctx.App.Name)
apis, err := getAPIs(userconf, ctx.DeploymentVersion, ctx.ProjectID)
apis, err := getAPIs(userconf, ctx.DeploymentVersion, projectID)

if err != nil {
return nil, err
}
ctx.APIs = apis

for _, api := range ctx.APIs {
if api.RequestHandler != nil {
ctx.ProjectID = projectID
ctx.ProjectKey = filepath.Join(consts.ProjectsDir, ctx.ProjectID+".zip")
if err = config.AWS.UploadBytesToS3(projectBytes, ctx.ProjectKey); err != nil {
return nil, err
}
break
}
}

err = ctx.Validate()
if err != nil {
return nil, err
Expand Down
14 changes: 10 additions & 4 deletions pkg/operator/workloads/api_workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,15 @@ func tfAPISpec(
To: path.Join(consts.EmptyDirMountPath, "model"),
ItemName: "model",
},
{
}

if len(ctx.ProjectKey) != 0 {
downloadArgs = append(downloadArgs, downloadContainerArg{
From: config.AWS.S3Path(ctx.ProjectKey),
To: path.Join(consts.EmptyDirMountPath, "project"),
Unzip: true,
ItemName: "project code",
},
})
}

downloadArgsBytes, _ := json.Marshal(downloadArgs)
Expand Down Expand Up @@ -441,12 +444,15 @@ func onnxAPISpec(
To: path.Join(consts.EmptyDirMountPath, "model"),
ItemName: "model",
},
{
}

if len(ctx.ProjectKey) != 0 {
downloadArgs = append(downloadArgs, downloadContainerArg{
From: config.AWS.S3Path(ctx.ProjectKey),
To: path.Join(consts.EmptyDirMountPath, "project"),
Unzip: true,
ItemName: "project code",
},
})
}

downloadArgsBytes, _ := json.Marshal(downloadArgs)
Expand Down