added algorithmscode api
Former-commit-id: 60b3ed6bb4c24d801afeec3b4cee108788cd2bea
This commit is contained in:
parent
9b8c7d36e6
commit
0e155cb657
|
@ -954,6 +954,12 @@ service pcm {
|
|||
|
||||
@handler ScheduleGetOverviewHandler
|
||||
post /schedule/getOverview returns (ScheduleOverviewResp)
|
||||
|
||||
@handler DownloadAlgothmCodeHandler
|
||||
get /schedule/getDownloadAlgothmCode (DownloadAlgorithmCodeReq) returns (DownloadAlgorithmCodeResp)
|
||||
|
||||
@handler UploadAlgothmCodeHandler
|
||||
post /schedule/getDownloadAlgothmCode (UploadAlgorithmCodeReq) returns (UploadAlgorithmCodeResp)
|
||||
}
|
||||
|
||||
@server(
|
||||
|
|
|
@ -100,4 +100,33 @@ type (
|
|||
StartTime string `json:"startTime,omitempty" db:"start_time"`
|
||||
EndTime string `json:"endTime,omitempty" db:"end_time"`
|
||||
}
|
||||
|
||||
DownloadAlgorithmCodeReq {
|
||||
AdapterId string `form:"adapterId"`
|
||||
ClusterId string `form:"clusterId"`
|
||||
ResourceType string `form:"resourceType"`
|
||||
Card string `form:"card"`
|
||||
TaskType string `form:"taskType"`
|
||||
Dataset string `form:"dataset"`
|
||||
Algorithm string `form:"algorithm"`
|
||||
Code string `form:"code"`
|
||||
}
|
||||
|
||||
DownloadAlgorithmCodeResp {
|
||||
Code string `json:"algorithms"`
|
||||
}
|
||||
|
||||
UploadAlgorithmCodeReq {
|
||||
AdapterId string `json:"adapterId"`
|
||||
ClusterId string `json:"clusterId"`
|
||||
ResourceType string `json:"resourceType"`
|
||||
Card string `json:"card"`
|
||||
TaskType string `json:"taskType"`
|
||||
Dataset string `json:"dataset"`
|
||||
Algorithm string `json:"algorithm"`
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
UploadAlgorithmCodeResp {
|
||||
}
|
||||
)
|
|
@ -8,6 +8,7 @@ import (
|
|||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type GetCenterOverviewLogic struct {
|
||||
|
@ -71,9 +72,14 @@ func (l *GetCenterOverviewLogic) GetCenterOverview() (resp *types.CenterOverview
|
|||
}
|
||||
resp.CardNum = cardNum
|
||||
resp.PowerInTops = totalTops
|
||||
<-ch
|
||||
|
||||
select {
|
||||
case _ = <-ch:
|
||||
return resp, nil
|
||||
case <-time.After(2 * time.Second):
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (l *GetCenterOverviewLogic) updateClusterResource(mu *sync.RWMutex, ch chan<- struct{}, list []*types.AdapterInfo) {
|
||||
|
|
|
@ -73,9 +73,14 @@ func (l *GetCenterTaskListLogic) GetCenterTaskList() (resp *types.CenterTaskList
|
|||
resp.List = append(resp.List, t)
|
||||
}
|
||||
}
|
||||
<-ch
|
||||
|
||||
select {
|
||||
case _ = <-ch:
|
||||
return resp, nil
|
||||
case <-time.After(1 * time.Second):
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (l *GetCenterTaskListLogic) updateAiTaskStatus(mu *sync.RWMutex, ch chan<- struct{}, list []*types.AdapterInfo) {
|
||||
|
|
|
@ -8,8 +8,8 @@ type AiCollector interface {
|
|||
GetAlgorithms(ctx context.Context) ([]*Algorithm, error)
|
||||
GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error)
|
||||
GetTrainingTask(ctx context.Context, taskId string) (*Task, error)
|
||||
DownloadAlgorithmCode(ctx context.Context, resourceType string, taskType string, dataset string, algorithm string) (string, error)
|
||||
UploadAlgorithmCode(ctx context.Context, resourceType string, taskType string, dataset string, algorithm string, code string) error
|
||||
DownloadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string) (string, error)
|
||||
UploadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string, code string) error
|
||||
}
|
||||
|
||||
type ResourceStats struct {
|
||||
|
|
|
@ -162,11 +162,11 @@ func (m *ModelArtsLink) GetAlgorithms(ctx context.Context) ([]*collector.Algorit
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *ModelArtsLink) DownloadAlgorithmCode(ctx context.Context, resourceType string, taskType string, dataset string, algorithm string) (string, error) {
|
||||
func (m *ModelArtsLink) DownloadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (m *ModelArtsLink) UploadAlgorithmCode(ctx context.Context, resourceType string, taskType string, dataset string, algorithm string, code string) error {
|
||||
func (m *ModelArtsLink) UploadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string, code string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -339,11 +339,11 @@ func (o *OctopusLink) GetAlgorithms(ctx context.Context) ([]*collector.Algorithm
|
|||
return algorithms, nil
|
||||
}
|
||||
|
||||
func (o *OctopusLink) DownloadAlgorithmCode(ctx context.Context, resourceType string, taskType string, dataset string, algorithm string) (string, error) {
|
||||
func (o *OctopusLink) DownloadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (o *OctopusLink) UploadAlgorithmCode(ctx context.Context, resourceType string, taskType string, dataset string, algorithm string, code string) error {
|
||||
func (o *OctopusLink) UploadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string, code string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -447,11 +447,32 @@ func (s *ShuguangAi) GetAlgorithms(ctx context.Context) ([]*collector.Algorithm,
|
|||
return algorithms, nil
|
||||
}
|
||||
|
||||
func (s *ShuguangAi) DownloadAlgorithmCode(ctx context.Context, resourceType string, taskType string, dataset string, algorithm string) (string, error) {
|
||||
return "", nil
|
||||
func (s *ShuguangAi) DownloadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string) (string, error) {
|
||||
algoName := dataset + DASH + algorithm
|
||||
req := &hpcAC.GetFileReq{
|
||||
Path: ALGORITHM_DIR + FORWARD_SLASH + taskType + FORWARD_SLASH + algoName + FORWARD_SLASH + TRAIN_FILE,
|
||||
}
|
||||
resp, err := s.aCRpc.GetFile(ctx, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp.Content, nil
|
||||
}
|
||||
|
||||
func (s *ShuguangAi) UploadAlgorithmCode(ctx context.Context, resourceType string, taskType string, dataset string, algorithm string, code string) error {
|
||||
func (s *ShuguangAi) UploadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string, code string) error {
|
||||
algoName := dataset + DASH + algorithm
|
||||
req := &hpcAC.UploadFileReq{
|
||||
Path: ALGORITHM_DIR + FORWARD_SLASH + taskType + FORWARD_SLASH + algoName + FORWARD_SLASH,
|
||||
Cover: "cover",
|
||||
File: code,
|
||||
}
|
||||
|
||||
_, err := s.aCRpc.UploadFile(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue