Merge pull request 'updated downloadalgorithmcode logic' (#153) from tzwang/pcm-coordinator:master into master
Former-commit-id: 49e88aea084397aafe5c78eff8cadd873af3b4ca
This commit is contained in:
commit
e863fbc3c8
|
@ -971,10 +971,10 @@ service pcm {
|
||||||
post /schedule/getOverview returns (ScheduleOverviewResp)
|
post /schedule/getOverview returns (ScheduleOverviewResp)
|
||||||
|
|
||||||
@handler DownloadAlgothmCodeHandler
|
@handler DownloadAlgothmCodeHandler
|
||||||
get /schedule/getDownloadAlgothmCode (DownloadAlgorithmCodeReq) returns (DownloadAlgorithmCodeResp)
|
get /schedule/downloadAlgorithmCode (DownloadAlgorithmCodeReq) returns (DownloadAlgorithmCodeResp)
|
||||||
|
|
||||||
@handler UploadAlgothmCodeHandler
|
@handler UploadAlgothmCodeHandler
|
||||||
post /schedule/getDownloadAlgothmCode (UploadAlgorithmCodeReq) returns (UploadAlgorithmCodeResp)
|
post /schedule/uploadAlgorithmCode (UploadAlgorithmCodeReq) returns (UploadAlgorithmCodeResp)
|
||||||
|
|
||||||
@handler GetComputeCardsByClusterHandler
|
@handler GetComputeCardsByClusterHandler
|
||||||
get /schedule/getComputeCardsByCluster/:adapterId/:clusterId (GetComputeCardsByClusterReq) returns (GetComputeCardsByClusterResp)
|
get /schedule/getComputeCardsByCluster/:adapterId/:clusterId (GetComputeCardsByClusterReq) returns (GetComputeCardsByClusterResp)
|
||||||
|
|
|
@ -109,11 +109,10 @@ type (
|
||||||
TaskType string `form:"taskType"`
|
TaskType string `form:"taskType"`
|
||||||
Dataset string `form:"dataset"`
|
Dataset string `form:"dataset"`
|
||||||
Algorithm string `form:"algorithm"`
|
Algorithm string `form:"algorithm"`
|
||||||
Code string `form:"code"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadAlgorithmCodeResp {
|
DownloadAlgorithmCodeResp {
|
||||||
Code string `json:"algorithms"`
|
Code string `json:"code"`
|
||||||
}
|
}
|
||||||
|
|
||||||
UploadAlgorithmCodeReq {
|
UploadAlgorithmCodeReq {
|
||||||
|
|
|
@ -1212,12 +1212,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
Path: "/schedule/getDownloadAlgothmCode",
|
Path: "/schedule/downloadAlgorithmCode",
|
||||||
Handler: schedule.DownloadAlgothmCodeHandler(serverCtx),
|
Handler: schedule.DownloadAlgothmCodeHandler(serverCtx),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Method: http.MethodPost,
|
Method: http.MethodPost,
|
||||||
Path: "/schedule/getDownloadAlgothmCode",
|
Path: "/schedule/uploadAlgorithmCode",
|
||||||
Handler: schedule.UploadAlgothmCodeHandler(serverCtx),
|
Handler: schedule.UploadAlgothmCodeHandler(serverCtx),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,22 +7,19 @@ import (
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DownloadAlgothmCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func DownloadAlgothmCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.DownloadAlgorithmCodeReq
|
var req types.DownloadAlgorithmCodeReq
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
result.ParamErrorResult(r, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := schedule.NewDownloadAlgothmCodeLogic(r.Context(), svcCtx)
|
l := schedule.NewDownloadAlgothmCodeLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.DownloadAlgothmCode(&req)
|
resp, err := l.DownloadAlgorithmCode(&req)
|
||||||
if err != nil {
|
result.HttpResult(r, w, resp, err)
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
} else {
|
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,22 +7,19 @@ import (
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
)
|
)
|
||||||
|
|
||||||
func UploadAlgothmCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func UploadAlgothmCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.UploadAlgorithmCodeReq
|
var req types.UploadAlgorithmCodeReq
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
result.ParamErrorResult(r, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := schedule.NewUploadAlgothmCodeLogic(r.Context(), svcCtx)
|
l := schedule.NewUploadAlgothmCodeLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.UploadAlgothmCode(&req)
|
resp, err := l.UploadAlgorithmCode(&req)
|
||||||
if err != nil {
|
result.HttpResult(r, w, resp, err)
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
} else {
|
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,14 @@ func NewDownloadAlgothmCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *DownloadAlgothmCodeLogic) DownloadAlgothmCode(req *types.DownloadAlgorithmCodeReq) (resp *types.DownloadAlgorithmCodeResp, err error) {
|
func (l *DownloadAlgothmCodeLogic) DownloadAlgorithmCode(req *types.DownloadAlgorithmCodeReq) (resp *types.DownloadAlgorithmCodeResp, err error) {
|
||||||
// todo: add your logic here and delete this line
|
resp = &types.DownloadAlgorithmCodeResp{}
|
||||||
|
code, err := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[req.AdapterId][req.ClusterId].DownloadAlgorithmCode(l.ctx,
|
||||||
|
req.ResourceType, req.Card, req.TaskType, req.Dataset, req.Algorithm)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
resp.Code = code
|
||||||
|
|
||||||
return
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,13 @@ func NewUploadAlgothmCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *UploadAlgothmCodeLogic) UploadAlgothmCode(req *types.UploadAlgorithmCodeReq) (resp *types.UploadAlgorithmCodeResp, err error) {
|
func (l *UploadAlgothmCodeLogic) UploadAlgorithmCode(req *types.UploadAlgorithmCodeReq) (resp *types.UploadAlgorithmCodeResp, err error) {
|
||||||
// todo: add your logic here and delete this line
|
resp = &types.UploadAlgorithmCodeResp{}
|
||||||
|
err = l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[req.AdapterId][req.ClusterId].UploadAlgorithmCode(l.ctx,
|
||||||
|
req.ResourceType, req.Card, req.TaskType, req.Dataset, req.Algorithm, req.Code)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ const (
|
||||||
CAMBRICON = "cambricon"
|
CAMBRICON = "cambricon"
|
||||||
TRAIN_CMD = "cd /code; python train.py"
|
TRAIN_CMD = "cd /code; python train.py"
|
||||||
VERSION = "V1"
|
VERSION = "V1"
|
||||||
|
DOMAIN = "http://192.168.242.41:8001/"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -340,7 +341,44 @@ func (o *OctopusLink) GetAlgorithms(ctx context.Context) ([]*collector.Algorithm
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OctopusLink) DownloadAlgorithmCode(ctx context.Context, resourceType string, card 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
|
dcReq := &octopus.DownloadCompressReq{
|
||||||
|
Platform: o.platform,
|
||||||
|
Version: VERSION,
|
||||||
|
AlgorithmId: "",
|
||||||
|
}
|
||||||
|
dcResp, err := o.octopusRpc.DownloadCompress(ctx, dcReq)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !dcResp.Success {
|
||||||
|
return "", errors.New(dcResp.Error.Message)
|
||||||
|
}
|
||||||
|
|
||||||
|
daReq := &octopus.DownloadAlgorithmReq{
|
||||||
|
Platform: o.platform,
|
||||||
|
Version: VERSION,
|
||||||
|
AlgorithmId: "",
|
||||||
|
CompressAt: dcResp.Payload.CompressAt,
|
||||||
|
Domain: DOMAIN,
|
||||||
|
}
|
||||||
|
daResp, err := o.octopusRpc.DownloadAlgorithm(ctx, daReq)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if !daResp.Success {
|
||||||
|
return "", errors.New(dcResp.Error.Message)
|
||||||
|
}
|
||||||
|
urlReq := &octopus.AlgorithmUrlReq{
|
||||||
|
Platform: o.platform,
|
||||||
|
Url: daResp.Payload.DownloadUrl,
|
||||||
|
}
|
||||||
|
urlResp, err := o.octopusRpc.DownloadAlgorithmUrl(ctx, urlReq)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return urlResp.Algorithm, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OctopusLink) UploadAlgorithmCode(ctx context.Context, resourceType string, card 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 {
|
||||||
|
|
|
@ -5695,11 +5695,10 @@ type DownloadAlgorithmCodeReq struct {
|
||||||
TaskType string `form:"taskType"`
|
TaskType string `form:"taskType"`
|
||||||
Dataset string `form:"dataset"`
|
Dataset string `form:"dataset"`
|
||||||
Algorithm string `form:"algorithm"`
|
Algorithm string `form:"algorithm"`
|
||||||
Code string `form:"code"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type DownloadAlgorithmCodeResp struct {
|
type DownloadAlgorithmCodeResp struct {
|
||||||
Code string `json:"algorithms"`
|
Code string `json:"code"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UploadAlgorithmCodeReq struct {
|
type UploadAlgorithmCodeReq struct {
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -26,7 +26,7 @@ require (
|
||||||
github.com/zeromicro/go-zero v1.6.3
|
github.com/zeromicro/go-zero v1.6.3
|
||||||
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240426095603-549fefd8bece
|
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240426095603-549fefd8bece
|
||||||
gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c
|
gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c
|
||||||
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240424085753-6899615e9142
|
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240510133934-6a5526289b35
|
||||||
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203
|
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203
|
||||||
gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5
|
gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5
|
||||||
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d
|
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -1082,8 +1082,8 @@ gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240426095603-549fefd8bece h1:W3yBnvAVV
|
||||||
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240426095603-549fefd8bece/go.mod h1:w3Nb5TNymCItQ7K3x4Q0JLuoq9OerwAzAWT2zsPE9Xo=
|
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240426095603-549fefd8bece/go.mod h1:w3Nb5TNymCItQ7K3x4Q0JLuoq9OerwAzAWT2zsPE9Xo=
|
||||||
gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c h1:2Wl/hvaSFjh6fmCSIQhjkr9llMRREQeqcXNLZ/HPY18=
|
gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c h1:2Wl/hvaSFjh6fmCSIQhjkr9llMRREQeqcXNLZ/HPY18=
|
||||||
gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c/go.mod h1:lSRfGs+PxFvw7CcndHWRd6UlLlGrZn0b0hp5cfaMNGw=
|
gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c/go.mod h1:lSRfGs+PxFvw7CcndHWRd6UlLlGrZn0b0hp5cfaMNGw=
|
||||||
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240424085753-6899615e9142 h1:+po0nesBDSWsgCySBG7eEXk7i9Ytd58wqvjL1M9y6d8=
|
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240510133934-6a5526289b35 h1:E2QfpS3Y0FjR8Zyv5l2Ti/2NetQFqHG66c8+T/+J1u0=
|
||||||
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240424085753-6899615e9142/go.mod h1:QOD5+/l2D+AYBjF2h5T0mdJyfGAmF78QmeKdbBXbjLQ=
|
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240510133934-6a5526289b35/go.mod h1:QOD5+/l2D+AYBjF2h5T0mdJyfGAmF78QmeKdbBXbjLQ=
|
||||||
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 h1:s6PsZ1+bev294IWdZRlV7mnOwI1+UzFcldVW/BqhQzI=
|
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 h1:s6PsZ1+bev294IWdZRlV7mnOwI1+UzFcldVW/BqhQzI=
|
||||||
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203/go.mod h1:i2rrbMQ+Fve345BY9Heh4MUqVTAimZQElQhzzRee5B8=
|
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203/go.mod h1:i2rrbMQ+Fve345BY9Heh4MUqVTAimZQElQhzzRee5B8=
|
||||||
gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 h1:+/5vnzkJBfMRnya1NrhOzlroUtRa5ePiYbPKlHLoLV0=
|
gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 h1:+/5vnzkJBfMRnya1NrhOzlroUtRa5ePiYbPKlHLoLV0=
|
||||||
|
|
Loading…
Reference in New Issue