fix: add instance center of ai

This commit is contained in:
qiwang 2024-09-30 11:29:04 +08:00
parent a10d98ac46
commit 016e9a2296
9 changed files with 8706 additions and 6538 deletions

View File

@ -260,7 +260,7 @@ type (
Code int32 `json:"code"`
Msg string `json:"msg"`
}
ScheduleVmResult struct {
ScheduleVmResult {
ClusterId string `json:"clusterId"`
TaskId string `json:"taskId"`
Strategy string `json:"strategy"`
@ -1225,7 +1225,7 @@ type (
TaskName string `json:"taskName"`
Incident string `json:"incident"`
}
ListNoticeReq struct{}
ListNoticeReq {}
ListNoticeResp {
Code int64 `json:"code"`

View File

@ -33,6 +33,24 @@ type (
ModelNames []string `json:"models"`
}
/******************image inference*************************/
/******************instance center*************************/
InstanceCenterResp {
InstanceCenterList []InstanceCenterList `json:"instanceCenterList" copier:"InstanceCenterList"`
Code int32 `json:"code,omitempty"`
Msg string `json:"msg,omitempty"`
ErrorMsg string `json:"errorMsg,omitempty"`
TotalCount int `json:"totalCount"`
}
InstanceCenterList {
LogoPath string `json:"logo_path"`
InstanceName string `json:"instance_name"`
InstanceType int32 `json:"instance_type"`
InstanceClass string `json:"instance_class"`
Description string `json:"description"`
Version string `json:"version"`
}
/******************instance center*************************/
ImageInferenceReq {
TaskName string `form:"taskName"`

View File

@ -13,18 +13,18 @@ import (
"inference/inference.api"
)
info(
title: "pcm api service"
desc: "type desc here"
author: "type author here"
email: "type email here"
info (
title: "pcm api service"
desc: "type desc here"
author: "type author here"
email: "type email here"
version: "type version here"
)
//core端接口
@server(
@server (
prefix: pcm/v1
group: core
group: core
)
service pcm {
@doc "查询P端服务列表"
@ -133,7 +133,7 @@ service pcm {
@doc "Statistical task status"
@handler countTaskStatus
get /core/task/countTaskStatus () returns (TaskStatusResp)
get /core/task/countTaskStatus returns (TaskStatusResp)
@doc "Home Page Overview"
@handler homeOverviewHandler
@ -141,7 +141,7 @@ service pcm {
@doc "task details"
@handler taskDetails
get /core/task/details (FId) returns(TaskDetailsResp)
get /core/task/details (FId) returns (TaskDetailsResp)
@doc "Get Public Image"
@handler getPublicImageHandler
@ -157,22 +157,21 @@ service pcm {
@doc "screen"
@handler getDomainResourceHandler
get /core/getDomainResource returns (DomainResourceResp)
get /core/getDomainResource returns (DomainResourceResp)
@doc "screen"
@handler getScreenInfoHandler
get /core/getScreenInfo returns (ScreenInfoResp)
get /core/getScreenInfo returns (ScreenInfoResp)
@doc "screen"
@handler getScreenChartHandler
get /core/getScreenChart returns (ScreenChartResp)
get /core/getScreenChart returns (ScreenChartResp)
}
//hpc二级接口
@server(
@server (
prefix: pcm/v1
group: hpc
group: hpc
)
service pcm {
@doc "提交超算任务"
@ -201,9 +200,9 @@ service pcm {
}
//cloud二级接口
@server(
@server (
prefix: pcm/v1
group: cloud
group: cloud
)
service pcm {
@doc "云算任务列表"
@ -232,16 +231,16 @@ service pcm {
@doc "Create cloud computing common tasks"
@handler commitGeneralTask
post /cloud/task/create (GeneralTaskReq) returns ()
post /cloud/task/create (GeneralTaskReq)
@handler podLogs
post /cloud/pod/logs (PodLogsReq) returns (string)
}
//智算二级接口
@server(
@server (
prefix: pcm/v1
group: ai
group: ai
)
service pcm {
@doc "训练任务统计"
@ -382,19 +381,19 @@ service pcm {
@doc "创建虚拟化任务"
@handler createVisualizationJobHandler
post /ai/CreateVisualizationJob (CreateVisualizationJobReq) returns (CreateVisualizationJobResp)
/******************Visualization Job Method start*************************/
/******************Visualization Job Method start*************************/
/***********chat***********/
@doc "文本识别"
@handler ChatHandler
post /ai/chat (ChatReq) returns (ChatResult)
/******chat end***********/
/******chat end***********/
}
//screen接口
@server(
@server (
prefix: pcm/v1
group: storage
group: storage
)
service pcm {
@doc "存储概览"
@ -403,17 +402,17 @@ service pcm {
@doc "日常算力查询"
@handler dailyPowerScreenHandler
get /storage/dailyPowerScreen returns (DailyPowerScreenResp)
get /storage/dailyPowerScreen returns (DailyPowerScreenResp)
@doc "算力中心算力情况"
@handler perCenterComputerPowersHandler
get /storage/perCenterComputerPowers returns (PerCenterComputerPowersResp)
get /storage/perCenterComputerPowers returns (PerCenterComputerPowersResp)
}
//openstack 接口
@server(
@server (
prefix: pcm/v1
group: vm
group: vm
)
service pcm {
@doc "openstack计算中心概览"
@ -810,9 +809,9 @@ service pcm {
}
//存算联动 接口
@server(
@server (
prefix: pcm/v1
group: storelink
group: storelink
)
service pcm {
@handler UploadLinkImageHandler
@ -841,9 +840,9 @@ service pcm {
}
// 接口
@server(
@server (
prefix: pcm/v1
group: adapters
group: adapters
)
service pcm {
@handler AdaptersListHandler
@ -883,9 +882,9 @@ service pcm {
get /adapter/clusterSum (clusterSumReq) returns (clusterSumReqResp)
}
@server(
@server (
prefix: pcm/v1
group: schedule
group: schedule
)
service pcm {
@handler ScheduleGetAiResourceTypesHandler
@ -925,9 +924,9 @@ service pcm {
get /schedule/getClusterBalanceById/:adapterId/:clusterId (GetClusterBalanceByIdReq) returns (GetClusterBalanceByIdResp)
}
@server(
@server (
prefix: pcm/v1
group: inference
group: inference
)
service pcm {
@handler TextToTextInferenceHandler
@ -939,6 +938,9 @@ service pcm {
@handler ModelTypesHandler
get /inference/modelTypes returns (ModelTypesResp)
@handler InstanceCenterHandler
get /inference/instanceCenter returns (InstanceCenterResp)
@handler ModelNamesByTypeHandler
get /inference/modelNames (ModelNamesReq) returns (ModelNamesResp)
@ -979,9 +981,9 @@ service pcm {
get /inference/getAdaptersByModel (GetAdaptersByModelReq) returns (GetAdaptersByModelResp)
}
@server(
@server (
prefix: pcm/v1
group: dictionary
group: dictionary
)
service pcm {
@handler GetDict
@ -1018,9 +1020,9 @@ service pcm {
get /dictItem/code/:dictCode (DictCodeReq) returns (PageResult)
}
@server(
@server (
prefix: pcm/v1
group: monitoring
group: monitoring
)
service pcm {
@handler CreateAlertRuleHandler
@ -1056,5 +1058,6 @@ service pcm {
get /monitoring/adapter/info (adapterInfoReq) returns (adapterInfoResp)
@handler scheduleSituationHandler
get /monitoring/schedule/situation returns (scheduleSituationResp)
}
get /monitoring/schedule/situation returns (scheduleSituationResp)
}

View File

@ -0,0 +1,21 @@
package inference
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/inference"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
)
func InstanceCenterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
l := inference.NewInstanceCenterLogic(r.Context(), svcCtx)
resp, err := l.InstanceCenter()
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,54 @@
package inference
import (
"context"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type InstanceCenterLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewInstanceCenterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InstanceCenterLogic {
return &InstanceCenterLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *InstanceCenterLogic) InstanceCenter() (*types.InstanceCenterResp, error) {
// todo: add your logic here and delete this line
var resp types.InstanceCenterResp
var InstanceCenter *[]models.AiInstanceCenter
var InstanceCenterLists []types.InstanceCenterList
l.svcCtx.DbEngin.Raw("select * from ai_instance_center").Scan(&InstanceCenter)
var instanceCenter = *InstanceCenter
for _, instanceCenter := range instanceCenter {
var instanceCenterlist types.InstanceCenterList
instanceCenterlist.InstanceName = instanceCenter.InstanceName
instanceCenterlist.InstanceType = instanceCenter.InstanceType
instanceCenterlist.InstanceClass = instanceCenter.InstanceClass
instanceCenterlist.Description = instanceCenter.Description
instanceCenterlist.Version = instanceCenter.Version
instanceCenterlist.LogoPath = instanceCenter.LogoPath
InstanceCenterLists = append(InstanceCenterLists, instanceCenterlist)
}
resp.Code = 200
resp.Msg = "success"
resp.InstanceCenterList = InstanceCenterLists
resp.TotalCount = len(InstanceCenterLists)
return &resp, nil
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,29 @@
package models
import "github.com/zeromicro/go-zero/core/stores/sqlx"
var _ AiInstanceCenterModel = (*customAiInstanceCenterModel)(nil)
type (
// AiInstanceCenterModel is an interface to be customized, add more methods here,
// and implement the added methods in customAiInstanceCenterModel.
AiInstanceCenterModel interface {
aiInstanceCenterModel
withSession(session sqlx.Session) AiInstanceCenterModel
}
customAiInstanceCenterModel struct {
*defaultAiInstanceCenterModel
}
)
// NewAiInstanceCenterModel returns a model for the database table.
func NewAiInstanceCenterModel(conn sqlx.SqlConn) AiInstanceCenterModel {
return &customAiInstanceCenterModel{
defaultAiInstanceCenterModel: newAiInstanceCenterModel(conn),
}
}
func (m *customAiInstanceCenterModel) withSession(session sqlx.Session) AiInstanceCenterModel {
return NewAiInstanceCenterModel(sqlx.NewSqlConnFromSession(session))
}

View File

@ -0,0 +1,90 @@
// Code generated by goctl. DO NOT EDIT.
package models
import (
"context"
"database/sql"
"fmt"
"strings"
"github.com/zeromicro/go-zero/core/stores/builder"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"github.com/zeromicro/go-zero/core/stringx"
)
var (
aiInstanceCenterFieldNames = builder.RawFieldNames(&AiInstanceCenter{})
aiInstanceCenterRows = strings.Join(aiInstanceCenterFieldNames, ",")
aiInstanceCenterRowsExpectAutoSet = strings.Join(stringx.Remove(aiInstanceCenterFieldNames, "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
aiInstanceCenterRowsWithPlaceHolder = strings.Join(stringx.Remove(aiInstanceCenterFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
)
type (
aiInstanceCenterModel interface {
Insert(ctx context.Context, data *AiInstanceCenter) (sql.Result, error)
FindOne(ctx context.Context, id int64) (*AiInstanceCenter, error)
Update(ctx context.Context, data *AiInstanceCenter) error
Delete(ctx context.Context, id int64) error
}
defaultAiInstanceCenterModel struct {
conn sqlx.SqlConn
table string
}
AiInstanceCenter struct {
Id int64 `db:"id"` // 平台唯一id
LogoPath string `db:"logo_path"` // logo图像的位置
InstanceName string `db:"instance_name"` // 实例名称
InstanceType int32 `db:"instance_type"` // 实例类型1是应用实例2是模型实例
InstanceClass string `db:"instance_class"` // 实例类别
Description string `db:"description"` // 描述
Version string `db:"version"` // 版本
CreateTime string `db:"create_time"` // 创建时间
UpdateTime string `db:"update_time"` // 更新时间
}
)
func newAiInstanceCenterModel(conn sqlx.SqlConn) *defaultAiInstanceCenterModel {
return &defaultAiInstanceCenterModel{
conn: conn,
table: "`ai_instance_center`",
}
}
func (m *defaultAiInstanceCenterModel) Delete(ctx context.Context, id int64) error {
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
_, err := m.conn.ExecCtx(ctx, query, id)
return err
}
func (m *defaultAiInstanceCenterModel) FindOne(ctx context.Context, id int64) (*AiInstanceCenter, error) {
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", aiInstanceCenterRows, m.table)
var resp AiInstanceCenter
err := m.conn.QueryRowCtx(ctx, &resp, query, id)
switch err {
case nil:
return &resp, nil
case sqlx.ErrNotFound:
return nil, ErrNotFound
default:
return nil, err
}
}
func (m *defaultAiInstanceCenterModel) Insert(ctx context.Context, data *AiInstanceCenter) (sql.Result, error) {
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?)", m.table, aiInstanceCenterRowsExpectAutoSet)
ret, err := m.conn.ExecCtx(ctx, query, data.Id, data.LogoPath, data.InstanceName, data.InstanceType, data.InstanceClass, data.Description, data.Version)
return ret, err
}
func (m *defaultAiInstanceCenterModel) Update(ctx context.Context, data *AiInstanceCenter) error {
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, aiInstanceCenterRowsWithPlaceHolder)
_, err := m.conn.ExecCtx(ctx, query, data.LogoPath, data.InstanceName, data.InstanceType, data.InstanceClass, data.Description, data.Version, data.Id)
return err
}
func (m *defaultAiInstanceCenterModel) tableName() string {
return m.table
}