diff --git a/api/desc/ai/pcm-ai.api b/api/desc/ai/pcm-ai.api index 23cfff29..b0cf10fe 100644 --- a/api/desc/ai/pcm-ai.api +++ b/api/desc/ai/pcm-ai.api @@ -1717,10 +1717,10 @@ PayloadCreateTrainJob{ } CenterListResp { - List []*Center `json:"centerList,optional"` + List []*AiCenter `json:"centerList,optional"` } - Center { + AiCenter { Name string `json:"name,optional"` StackName string `json:"stack,optional"` Version string `json:"version,optional"` diff --git a/api/internal/handler/ai/getcenterlisthandler.go b/api/internal/handler/ai/getcenterlisthandler.go new file mode 100644 index 00000000..40a7dc01 --- /dev/null +++ b/api/internal/handler/ai/getcenterlisthandler.go @@ -0,0 +1,21 @@ +package ai + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" +) + +func GetCenterListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := ai.NewGetCenterListLogic(r.Context(), svcCtx) + resp, err := l.GetCenterList() + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/handler/ai/getcenteroverviewhandler.go b/api/internal/handler/ai/getcenteroverviewhandler.go new file mode 100644 index 00000000..84b97958 --- /dev/null +++ b/api/internal/handler/ai/getcenteroverviewhandler.go @@ -0,0 +1,21 @@ +package ai + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" +) + +func GetCenterOverviewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := ai.NewGetCenterOverviewLogic(r.Context(), svcCtx) + resp, err := l.GetCenterOverview() + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/handler/ai/getcenterqueueinghandler.go b/api/internal/handler/ai/getcenterqueueinghandler.go new file mode 100644 index 00000000..6577b34c --- /dev/null +++ b/api/internal/handler/ai/getcenterqueueinghandler.go @@ -0,0 +1,21 @@ +package ai + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" +) + +func GetCenterQueueingHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := ai.NewGetCenterQueueingLogic(r.Context(), svcCtx) + resp, err := l.GetCenterQueueing() + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/handler/ai/getcentertasklisthandler.go b/api/internal/handler/ai/getcentertasklisthandler.go new file mode 100644 index 00000000..37312b25 --- /dev/null +++ b/api/internal/handler/ai/getcentertasklisthandler.go @@ -0,0 +1,21 @@ +package ai + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" +) + +func GetCenterTaskListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := ai.NewGetCenterTaskListLogic(r.Context(), svcCtx) + resp, err := l.GetCenterTaskList() + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/handler/routes.go b/api/internal/handler/routes.go index 5402a03d..4db7721f 100644 --- a/api/internal/handler/routes.go +++ b/api/internal/handler/routes.go @@ -258,6 +258,26 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { server.AddRoutes( []rest.Route{ + { + Method: http.MethodGet, + Path: "/ai/getCenterOverview", + Handler: ai.GetCenterOverviewHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/getCenterQueueing", + Handler: ai.GetCenterQueueingHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/getCenterList", + Handler: ai.GetCenterListHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/getCenterTaskList", + Handler: ai.GetCenterTaskListHandler(serverCtx), + }, { Method: http.MethodGet, Path: "/ai/listDataSet/:projectId", @@ -1155,6 +1175,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/schedule/submit", Handler: schedule.ScheduleSubmitHandler(serverCtx), }, + { + Method: http.MethodPost, + Path: "/schedule/getOverview", + Handler: schedule.ScheduleGetOverviewHandler(serverCtx), + }, }, rest.WithPrefix("/pcm/v1"), ) diff --git a/api/internal/handler/schedule/schedulegetoverviewhandler.go b/api/internal/handler/schedule/schedulegetoverviewhandler.go new file mode 100644 index 00000000..bbf66cc7 --- /dev/null +++ b/api/internal/handler/schedule/schedulegetoverviewhandler.go @@ -0,0 +1,21 @@ +package schedule + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" +) + +func ScheduleGetOverviewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := schedule.NewScheduleGetOverviewLogic(r.Context(), svcCtx) + resp, err := l.ScheduleGetOverview() + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/logic/ai/getcenterlistlogic.go b/api/internal/logic/ai/getcenterlistlogic.go new file mode 100644 index 00000000..ce9db87d --- /dev/null +++ b/api/internal/logic/ai/getcenterlistlogic.go @@ -0,0 +1,30 @@ +package ai + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetCenterListLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetCenterListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCenterListLogic { + return &GetCenterListLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetCenterListLogic) GetCenterList() (resp *types.CenterListResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/api/internal/logic/ai/getcenteroverviewlogic.go b/api/internal/logic/ai/getcenteroverviewlogic.go new file mode 100644 index 00000000..0de00f18 --- /dev/null +++ b/api/internal/logic/ai/getcenteroverviewlogic.go @@ -0,0 +1,30 @@ +package ai + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetCenterOverviewLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetCenterOverviewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCenterOverviewLogic { + return &GetCenterOverviewLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetCenterOverviewLogic) GetCenterOverview() (resp *types.CenterOverviewResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/api/internal/logic/ai/getcenterqueueinglogic.go b/api/internal/logic/ai/getcenterqueueinglogic.go new file mode 100644 index 00000000..6ff23825 --- /dev/null +++ b/api/internal/logic/ai/getcenterqueueinglogic.go @@ -0,0 +1,30 @@ +package ai + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetCenterQueueingLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetCenterQueueingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCenterQueueingLogic { + return &GetCenterQueueingLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetCenterQueueingLogic) GetCenterQueueing() (resp *types.CenterQueueingResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/api/internal/logic/ai/getcentertasklistlogic.go b/api/internal/logic/ai/getcentertasklistlogic.go new file mode 100644 index 00000000..96242e9b --- /dev/null +++ b/api/internal/logic/ai/getcentertasklistlogic.go @@ -0,0 +1,30 @@ +package ai + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetCenterTaskListLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetCenterTaskListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCenterTaskListLogic { + return &GetCenterTaskListLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetCenterTaskListLogic) GetCenterTaskList() (resp *types.CenterTaskListResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/api/internal/logic/schedule/schedulegetoverviewlogic.go b/api/internal/logic/schedule/schedulegetoverviewlogic.go new file mode 100644 index 00000000..f3ab02af --- /dev/null +++ b/api/internal/logic/schedule/schedulegetoverviewlogic.go @@ -0,0 +1,30 @@ +package schedule + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ScheduleGetOverviewLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewScheduleGetOverviewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleGetOverviewLogic { + return &ScheduleGetOverviewLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ScheduleGetOverviewLogic) ScheduleGetOverview() (resp *types.ScheduleOverviewResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/api/internal/types/types.go b/api/internal/types/types.go index 52164d6e..9120e293 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -2707,6 +2707,43 @@ type Nfs struct { ReadOnly bool `json:"readOnly,optional"` } +type CenterOverviewResp struct { + CenterNum int32 `json:"totalCenters,optional"` + TaskNum int32 `json:"totalTasks,optional"` + CardNum int32 `json:"totalCards,optional"` + PowerInTops float64 `json:"totalPower,optional"` +} + +type CenterQueueingResp struct { + Current []*CenterQueue `json:"current,optional"` + History []*CenterQueue `json:"history,optional"` +} + +type CenterQueue struct { + Name string `json:"name,optional"` + QueueingNum int32 `json:"num,optional"` +} + +type CenterListResp struct { + List []*AiCenter `json:"centerList,optional"` +} + +type AiCenter struct { + Name string `json:"name,optional"` + StackName string `json:"stack,optional"` + Version string `json:"version,optional"` +} + +type CenterTaskListResp struct { + List []*AiTask `json:"taskList,optional"` +} + +type AiTask struct { + Name string `json:"name,optional"` + Status string `json:"status,optional"` + TimeElapsed int32 `json:"elapsed,optional"` +} + type StorageScreenReq struct { } @@ -5488,6 +5525,9 @@ type ScheduleResult struct { Msg string `json:"msg"` } +type ScheduleOverviewResp struct { +} + type AiOption struct { TaskName string `json:"taskName"` AdapterId string `json:"adapterId"`