Skip to content

Commit ca6b04c

Browse files
Dev AgentRader
authored andcommitted
fix notebook issue
1 parent 2834396 commit ca6b04c

1 file changed

Lines changed: 38 additions & 22 deletions

File tree

api/workflow/activity/deploy_activity.go

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -514,12 +514,22 @@ func (a *DeployActivity) createDeployRequest(ctx context.Context, task *database
514514
return nil, fmt.Errorf("failed to get git access token: %w", err)
515515
}
516516

517-
pathParts := strings.Split(repoInfo.Path, "/")
518517
deployInfo, err := a.ds.GetDeployByID(ctx, task.DeployID)
519518
if err != nil {
520519
return nil, fmt.Errorf("failed to get deploy with error: %w", err)
521520
}
522521

522+
pathParts := strings.Split(repoInfo.Path, "/")
523+
orgName, repoName := "", ""
524+
if deployInfo.Type == types.NotebookType {
525+
//just a placeholder value
526+
orgName = "notebook"
527+
repoName = deployInfo.SvcName
528+
} else if len(pathParts) >= 2 {
529+
orgName = pathParts[0]
530+
repoName = pathParts[1]
531+
}
532+
523533
var engineArgsTemplates []types.EngineArg
524534
var toolCallParsers map[string]string
525535
if len(deployInfo.RuntimeFramework) > 0 {
@@ -578,8 +588,8 @@ func (a *DeployActivity) createDeployRequest(ctx context.Context, task *database
578588

579589
return &types.RunRequest{
580590
ID: targetID,
581-
OrgName: pathParts[0],
582-
RepoName: pathParts[1],
591+
OrgName: orgName,
592+
RepoName: repoName,
583593
RepoType: repoInfo.RepoType,
584594
UserName: repoInfo.UserName,
585595
Annotation: annotationMap,
@@ -646,27 +656,33 @@ func (a *DeployActivity) makeDeployEnv(ctx context.Context, hardware types.HardW
646656
}
647657
}
648658

649-
pathParts := strings.Split(repoInfo.Path, "/")
650-
commit, err := a.gs.GetRepoLastCommit(ctx, gitserver.GetRepoLastCommitReq{
651-
Namespace: pathParts[0],
652-
Name: pathParts[1],
653-
Ref: deployInfo.GitBranch,
654-
RepoType: types.RepositoryType(repoInfo.RepoType),
655-
})
656-
657-
if err != nil {
658-
return nil, err
659-
}
660-
661-
commitID, err := utilcommon.ShortenCommitID7(commit.ID)
662-
if err != nil {
663-
return nil, errorx.ErrInvalidCommitID
664-
}
665659
envMap["S3_INTERNAL"] = fmt.Sprintf("%v", a.cfg.S3Internal)
666-
envMap["HTTPCloneURL"] = a.getHttpCloneURLWithToken(repoInfo.HTTPCloneURL, accessToken.User.Username, accessToken.Token)
667660
envMap["ACCESS_TOKEN"] = accessToken.Token
668-
envMap["REPO_ID"] = repoInfo.Path // "namespace/name"
669-
envMap["REVISION"] = commitID // branch
661+
662+
// Notebook has no git repo; skip GetRepoLastCommit and use empty git-related env
663+
if deployInfo.Type != types.NotebookType {
664+
pathParts := strings.Split(repoInfo.Path, "/")
665+
commit, err := a.gs.GetRepoLastCommit(ctx, gitserver.GetRepoLastCommitReq{
666+
Namespace: pathParts[0],
667+
Name: pathParts[1],
668+
Ref: deployInfo.GitBranch,
669+
RepoType: types.RepositoryType(repoInfo.RepoType),
670+
})
671+
if err != nil {
672+
return nil, err
673+
}
674+
commitID, err := utilcommon.ShortenCommitID7(commit.ID)
675+
if err != nil {
676+
return nil, errorx.ErrInvalidCommitID
677+
}
678+
envMap["HTTPCloneURL"] = a.getHttpCloneURLWithToken(repoInfo.HTTPCloneURL, accessToken.User.Username, accessToken.Token)
679+
envMap["REPO_ID"] = repoInfo.Path // "namespace/name"
680+
envMap["REVISION"] = commitID // branch
681+
} else {
682+
envMap["HTTPCloneURL"] = ""
683+
envMap["REPO_ID"] = ""
684+
envMap["REVISION"] = ""
685+
}
670686

671687
if len(engineArgsTemplates) > 0 {
672688
var engineArgs strings.Builder

0 commit comments

Comments
 (0)