diff --git a/adaptor/PCM-AI/PCM-HANWUJI/rpc/etc/pcmhanwuji.yaml b/adaptor/PCM-AI/PCM-HANWUJI/rpc/etc/pcmhanwuji.yaml deleted file mode 100644 index ad831862..00000000 --- a/adaptor/PCM-AI/PCM-HANWUJI/rpc/etc/pcmhanwuji.yaml +++ /dev/null @@ -1,15 +0,0 @@ -NacosConfig: - DataId: pcm-hanwuji-rpc.yaml - Group: DEFAULT_GROUP - ServerConfigs: -# - IpAddr: 127.0.0.1 -# Port: 8848 - - IpAddr: 10.101.15.7 - Port: 8848 - ClientConfig: - NamespaceId: test - TimeoutMs: 5000 - NotLoadCacheAtStart: true - LogDir: - CacheDir: - LogLevel: debug \ No newline at end of file diff --git a/adaptor/PCM-AI/PCM-HANWUJI/rpc/hanwuji/pcm-hanwuji.pb.go b/adaptor/PCM-AI/PCM-HANWUJI/rpc/hanwuji/pcm-hanwuji.pb.go deleted file mode 100644 index a08a7f8a..00000000 --- a/adaptor/PCM-AI/PCM-HANWUJI/rpc/hanwuji/pcm-hanwuji.pb.go +++ /dev/null @@ -1,250 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.19.4 -// source: pcm-hanwuji.proto - -package hanwuji - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type CreateDataSetReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ApplyIds []string `protobuf:"bytes,1,rep,name=applyIds,proto3" json:"applyIds,omitempty"` // @gotags: copier:"ApplyIds" - Desc string `protobuf:"bytes,2,opt,name=desc,proto3" json:"desc,omitempty"` // @gotags: copier:"Desc" - Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` // @gotags: copier:"Name" - TypeId string `protobuf:"bytes,4,opt,name=typeId,proto3" json:"typeId,omitempty"` // @gotags: copier:"TypeId" -} - -func (x *CreateDataSetReq) Reset() { - *x = CreateDataSetReq{} - if protoimpl.UnsafeEnabled { - mi := &file_pcm_hanwuji_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateDataSetReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateDataSetReq) ProtoMessage() {} - -func (x *CreateDataSetReq) ProtoReflect() protoreflect.Message { - mi := &file_pcm_hanwuji_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreateDataSetReq.ProtoReflect.Descriptor instead. -func (*CreateDataSetReq) Descriptor() ([]byte, []int) { - return file_pcm_hanwuji_proto_rawDescGZIP(), []int{0} -} - -func (x *CreateDataSetReq) GetApplyIds() []string { - if x != nil { - return x.ApplyIds - } - return nil -} - -func (x *CreateDataSetReq) GetDesc() string { - if x != nil { - return x.Desc - } - return "" -} - -func (x *CreateDataSetReq) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *CreateDataSetReq) GetTypeId() string { - if x != nil { - return x.TypeId - } - return "" -} - -type CreateDataSetResq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // @gotags: copier:"Id" - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` // @gotags: copier:"Version" -} - -func (x *CreateDataSetResq) Reset() { - *x = CreateDataSetResq{} - if protoimpl.UnsafeEnabled { - mi := &file_pcm_hanwuji_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateDataSetResq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateDataSetResq) ProtoMessage() {} - -func (x *CreateDataSetResq) ProtoReflect() protoreflect.Message { - mi := &file_pcm_hanwuji_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreateDataSetResq.ProtoReflect.Descriptor instead. -func (*CreateDataSetResq) Descriptor() ([]byte, []int) { - return file_pcm_hanwuji_proto_rawDescGZIP(), []int{1} -} - -func (x *CreateDataSetResq) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *CreateDataSetResq) GetVersion() string { - if x != nil { - return x.Version - } - return "" -} - -var File_pcm_hanwuji_proto protoreflect.FileDescriptor - -var file_pcm_hanwuji_proto_rawDesc = []byte{ - 0x0a, 0x11, 0x70, 0x63, 0x6d, 0x2d, 0x68, 0x61, 0x6e, 0x77, 0x75, 0x6a, 0x69, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x68, 0x61, 0x6e, 0x77, 0x75, 0x6a, 0x69, 0x22, 0x6e, 0x0a, 0x10, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x61, 0x74, 0x61, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, - 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x49, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x09, 0x52, 0x08, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x49, 0x64, 0x73, 0x12, 0x12, 0x0a, 0x04, - 0x64, 0x65, 0x73, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x65, 0x73, 0x63, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x79, 0x70, 0x65, 0x49, 0x64, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x79, 0x70, 0x65, 0x49, 0x64, 0x22, 0x3d, 0x0a, 0x11, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x61, 0x74, 0x61, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, - 0x71, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, - 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x32, 0x51, 0x0a, 0x07, 0x48, - 0x61, 0x6e, 0x77, 0x75, 0x6a, 0x69, 0x12, 0x46, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x44, 0x61, 0x74, 0x61, 0x53, 0x65, 0x74, 0x12, 0x19, 0x2e, 0x68, 0x61, 0x6e, 0x77, 0x75, 0x6a, - 0x69, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x61, 0x74, 0x61, 0x53, 0x65, 0x74, 0x52, - 0x65, 0x71, 0x1a, 0x1a, 0x2e, 0x68, 0x61, 0x6e, 0x77, 0x75, 0x6a, 0x69, 0x2e, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x44, 0x61, 0x74, 0x61, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, 0x71, 0x42, 0x0a, - 0x5a, 0x08, 0x2f, 0x68, 0x61, 0x6e, 0x77, 0x75, 0x6a, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, -} - -var ( - file_pcm_hanwuji_proto_rawDescOnce sync.Once - file_pcm_hanwuji_proto_rawDescData = file_pcm_hanwuji_proto_rawDesc -) - -func file_pcm_hanwuji_proto_rawDescGZIP() []byte { - file_pcm_hanwuji_proto_rawDescOnce.Do(func() { - file_pcm_hanwuji_proto_rawDescData = protoimpl.X.CompressGZIP(file_pcm_hanwuji_proto_rawDescData) - }) - return file_pcm_hanwuji_proto_rawDescData -} - -var file_pcm_hanwuji_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_pcm_hanwuji_proto_goTypes = []interface{}{ - (*CreateDataSetReq)(nil), // 0: hanwuji.CreateDataSetReq - (*CreateDataSetResq)(nil), // 1: hanwuji.CreateDataSetResq -} -var file_pcm_hanwuji_proto_depIdxs = []int32{ - 0, // 0: hanwuji.Hanwuji.CreateDataSet:input_type -> hanwuji.CreateDataSetReq - 1, // 1: hanwuji.Hanwuji.CreateDataSet:output_type -> hanwuji.CreateDataSetResq - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_pcm_hanwuji_proto_init() } -func file_pcm_hanwuji_proto_init() { - if File_pcm_hanwuji_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_pcm_hanwuji_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateDataSetReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcm_hanwuji_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateDataSetResq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_pcm_hanwuji_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_pcm_hanwuji_proto_goTypes, - DependencyIndexes: file_pcm_hanwuji_proto_depIdxs, - MessageInfos: file_pcm_hanwuji_proto_msgTypes, - }.Build() - File_pcm_hanwuji_proto = out.File - file_pcm_hanwuji_proto_rawDesc = nil - file_pcm_hanwuji_proto_goTypes = nil - file_pcm_hanwuji_proto_depIdxs = nil -} diff --git a/adaptor/PCM-AI/PCM-HANWUJI/rpc/hanwuji/pcm-hanwuji_grpc.pb.go b/adaptor/PCM-AI/PCM-HANWUJI/rpc/hanwuji/pcm-hanwuji_grpc.pb.go deleted file mode 100644 index 0b2d95e0..00000000 --- a/adaptor/PCM-AI/PCM-HANWUJI/rpc/hanwuji/pcm-hanwuji_grpc.pb.go +++ /dev/null @@ -1,107 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.19.4 -// source: pcm-hanwuji.proto - -package hanwuji - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -// HanwujiClient is the client API for Hanwuji service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type HanwujiClient interface { - //get modelarts Token - CreateDataSet(ctx context.Context, in *CreateDataSetReq, opts ...grpc.CallOption) (*CreateDataSetResq, error) -} - -type hanwujiClient struct { - cc grpc.ClientConnInterface -} - -func NewHanwujiClient(cc grpc.ClientConnInterface) HanwujiClient { - return &hanwujiClient{cc} -} - -func (c *hanwujiClient) CreateDataSet(ctx context.Context, in *CreateDataSetReq, opts ...grpc.CallOption) (*CreateDataSetResq, error) { - out := new(CreateDataSetResq) - err := c.cc.Invoke(ctx, "/hanwuji.Hanwuji/CreateDataSet", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// HanwujiServer is the server API for Hanwuji service. -// All implementations must embed UnimplementedHanwujiServer -// for forward compatibility -type HanwujiServer interface { - //get modelarts Token - CreateDataSet(context.Context, *CreateDataSetReq) (*CreateDataSetResq, error) - mustEmbedUnimplementedHanwujiServer() -} - -// UnimplementedHanwujiServer must be embedded to have forward compatible implementations. -type UnimplementedHanwujiServer struct { -} - -func (UnimplementedHanwujiServer) CreateDataSet(context.Context, *CreateDataSetReq) (*CreateDataSetResq, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateDataSet not implemented") -} -func (UnimplementedHanwujiServer) mustEmbedUnimplementedHanwujiServer() {} - -// UnsafeHanwujiServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to HanwujiServer will -// result in compilation errors. -type UnsafeHanwujiServer interface { - mustEmbedUnimplementedHanwujiServer() -} - -func RegisterHanwujiServer(s grpc.ServiceRegistrar, srv HanwujiServer) { - s.RegisterService(&Hanwuji_ServiceDesc, srv) -} - -func _Hanwuji_CreateDataSet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateDataSetReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(HanwujiServer).CreateDataSet(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/hanwuji.Hanwuji/CreateDataSet", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(HanwujiServer).CreateDataSet(ctx, req.(*CreateDataSetReq)) - } - return interceptor(ctx, in, info, handler) -} - -// Hanwuji_ServiceDesc is the grpc.ServiceDesc for Hanwuji service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Hanwuji_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "hanwuji.Hanwuji", - HandlerType: (*HanwujiServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "CreateDataSet", - Handler: _Hanwuji_CreateDataSet_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "pcm-hanwuji.proto", -} diff --git a/adaptor/PCM-AI/PCM-HANWUJI/rpc/hanwujiclient/hanwuji.go b/adaptor/PCM-AI/PCM-HANWUJI/rpc/hanwujiclient/hanwuji.go deleted file mode 100644 index fe831a56..00000000 --- a/adaptor/PCM-AI/PCM-HANWUJI/rpc/hanwujiclient/hanwuji.go +++ /dev/null @@ -1,39 +0,0 @@ -// Code generated by goctl. DO NOT EDIT. -// Source: pcm-hanwuji.proto - -package hanwujiclient - -import ( - "context" - - "PCM/adaptor/PCM-AI/PCM-HANWUJI/rpc/hanwuji" - - "github.com/zeromicro/go-zero/zrpc" - "google.golang.org/grpc" -) - -type ( - CreateDataSetReq = hanwuji.CreateDataSetReq - CreateDataSetResq = hanwuji.CreateDataSetResq - - Hanwuji interface { - // get modelarts Token - CreateDataSet(ctx context.Context, in *CreateDataSetReq, opts ...grpc.CallOption) (*CreateDataSetResq, error) - } - - defaultHanwuji struct { - cli zrpc.Client - } -) - -func NewHanwuji(cli zrpc.Client) Hanwuji { - return &defaultHanwuji{ - cli: cli, - } -} - -// get modelarts Token -func (m *defaultHanwuji) CreateDataSet(ctx context.Context, in *CreateDataSetReq, opts ...grpc.CallOption) (*CreateDataSetResq, error) { - client := hanwuji.NewHanwujiClient(m.cli.Conn()) - return client.CreateDataSet(ctx, in, opts...) -} diff --git a/adaptor/PCM-AI/PCM-HANWUJI/rpc/internal/config/config.go b/adaptor/PCM-AI/PCM-HANWUJI/rpc/internal/config/config.go deleted file mode 100644 index c1f85b99..00000000 --- a/adaptor/PCM-AI/PCM-HANWUJI/rpc/internal/config/config.go +++ /dev/null @@ -1,7 +0,0 @@ -package config - -import "github.com/zeromicro/go-zero/zrpc" - -type Config struct { - zrpc.RpcServerConf -} diff --git a/adaptor/PCM-AI/PCM-HANWUJI/rpc/internal/server/hanwujiserver.go b/adaptor/PCM-AI/PCM-HANWUJI/rpc/internal/server/hanwujiserver.go deleted file mode 100644 index cc1970f7..00000000 --- a/adaptor/PCM-AI/PCM-HANWUJI/rpc/internal/server/hanwujiserver.go +++ /dev/null @@ -1,29 +0,0 @@ -// Code generated by goctl. DO NOT EDIT. -// Source: pcm-hanwuji.proto - -package server - -import ( - "context" - - "PCM/adaptor/PCM-AI/PCM-HANWUJI/rpc/hanwuji" - "PCM/adaptor/PCM-AI/PCM-HANWUJI/rpc/internal/logic" - "PCM/adaptor/PCM-AI/PCM-HANWUJI/rpc/internal/svc" -) - -type HanwujiServer struct { - svcCtx *svc.ServiceContext - hanwuji.UnimplementedHanwujiServer -} - -func NewHanwujiServer(svcCtx *svc.ServiceContext) *HanwujiServer { - return &HanwujiServer{ - svcCtx: svcCtx, - } -} - -// get modelarts Token -func (s *HanwujiServer) CreateDataSet(ctx context.Context, in *hanwuji.CreateDataSetReq) (*hanwuji.CreateDataSetResq, error) { - l := logic.NewCreateDataSetLogic(ctx, s.svcCtx) - return l.CreateDataSet(in) -} diff --git a/adaptor/PCM-AI/PCM-HANWUJI/rpc/internal/svc/servicecontext.go b/adaptor/PCM-AI/PCM-HANWUJI/rpc/internal/svc/servicecontext.go deleted file mode 100644 index 4469d449..00000000 --- a/adaptor/PCM-AI/PCM-HANWUJI/rpc/internal/svc/servicecontext.go +++ /dev/null @@ -1,13 +0,0 @@ -package svc - -import "PCM/adaptor/PCM-AI/PCM-HANWUJI/rpc/internal/config" - -type ServiceContext struct { - Config config.Config -} - -func NewServiceContext(c config.Config) *ServiceContext { - return &ServiceContext{ - Config: c, - } -} diff --git a/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/logic/getdatasetlistlogic.go b/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/logic/getdatasetlistlogic.go index 21b553ca..3fa32511 100644 --- a/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/logic/getdatasetlistlogic.go +++ b/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/logic/getdatasetlistlogic.go @@ -1,13 +1,18 @@ package logic import ( + "APIGW-go-sdk/core" "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" "PCM/common/tool" + "bytes" "context" + "fmt" "github.com/zeromicro/go-zero/core/logx" + "io/ioutil" "k8s.io/apimachinery/pkg/util/json" + "net/http" "strconv" "strings" ) @@ -32,20 +37,63 @@ func (l *GetDatasetListLogic) GetDatasetList(in *modelarts.DataSetReq) (*modelar var resp modelarts.DataSetResp offset := strconv.Itoa(int(in.Offset)) judgeLimit := strconv.Itoa(int(in.Limit)) - token := common.GetToken() - statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, "https://modelarts.cn-north-4.myhuaweicloud.com/v2/"+projectId+"/datasets?offset="+offset+"&"+"limit="+judgeLimit, strings.NewReader(``), token) - //statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, "https://modelarts.cn-north-4.myhuaweicloud.com/v2/"+projectId+"/datasets", strings.NewReader(``), token) - if err != nil { - return nil, err + var limit string + if judgeLimit != "0" { + limit = strconv.Itoa(int(in.Limit)) + } else { + limit = "10" } - if statusCode == 200 { + //根据智算类型判断走华为智算还是南京智算 + modelArtsType := in.ModelArtsType + if modelArtsType == "huawei" { + modelArtsUrl := l.svcCtx.Config.ModelArtsUrl + token := common.GetToken() + statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, modelArtsUrl+"v2/"+projectId+"/datasets?offset="+offset+"&"+"limit="+limit, strings.NewReader(``), token) + if err != nil { + return nil, err + } + if statusCode == 200 { + json.Unmarshal(body, &resp) + resp.Code = 200 + resp.Msg = "Success" + } else if statusCode != 200 { + json.Unmarshal(body, &resp) + resp.Code = 400 + resp.Msg = "Failure" + } + } else if modelArtsType == "nanjing" { + AK := l.svcCtx.Config.AK + SK := l.svcCtx.Config.SK + NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl + XProjectId := l.svcCtx.Config.XProjectId + XDomainId := l.svcCtx.Config.XDomainId + s := core.Signer{ + Key: AK, + Secret: SK, + } + r, err := http.NewRequest("GET", NanjingModelArtsUrl+in.ProjectId+"/datasets?offset="+offset+"&"+"limit="+limit, + bytes.NewBuffer([]byte("foo=bar"))) + if err != nil { + fmt.Println(err) + //return + } + r.Header.Add("content-type", "application/json;charset=UTF-8") + r.Header.Add("X-Project-Id", XProjectId) + r.Header.Add("X-Domain-Id", XDomainId) + r.Header.Add("x-stage", "RELEASE") + s.Sign(r) + client := http.DefaultClient + res, err := client.Do(r) + if err != nil { + fmt.Println(err) + } + defer res.Body.Close() + body, err := ioutil.ReadAll(res.Body) + if err != nil { + fmt.Println(err) + } json.Unmarshal(body, &resp) - resp.Code = 200 - resp.Msg = "Success" - } else if statusCode != 200 { - json.Unmarshal(body, &resp) - resp.Code = 400 - resp.Msg = "Failure" } + return &resp, nil } diff --git a/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/logic/getlisttrainingjobslogic.go b/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/logic/getlisttrainingjobslogic.go index ce25d2e6..25ab0680 100644 --- a/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/logic/getlisttrainingjobslogic.go +++ b/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/logic/getlisttrainingjobslogic.go @@ -1,12 +1,16 @@ package logic import ( + "APIGW-go-sdk/core" "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" "PCM/common/tool" "context" + "fmt" + "io/ioutil" "k8s.io/apimachinery/pkg/util/json" + "net/http" "strconv" "strings" @@ -30,27 +34,70 @@ func NewGetListTrainingJobsLogic(ctx context.Context, svcCtx *svc.ServiceContext // get ListTrainingJobs1 func (l *GetListTrainingJobsLogic) GetListTrainingJobs(in *modelarts.ListTrainingJobsreq) (*modelarts.ListTrainingJobsresp, error) { var resp modelarts.ListTrainingJobsresp - limit := strconv.Itoa(int(in.Limit)) + judgeLimit := strconv.Itoa(int(in.Limit)) offset := strconv.Itoa(int(in.OffSet)) - url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/" + in.ProjectId + "/training-job-searches?limit=" + limit + "&offset=" + offset - reqByte, err := json.Marshal(in) - payload := strings.NewReader(string(reqByte)) - token := common.GetToken() - statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, url, payload, token) - if err != nil { - return nil, err + var limit string + if judgeLimit != "0" { + limit = strconv.Itoa(int(in.Limit)) + } else { + limit = "10" } - if statusCode == 200 { - json.Unmarshal(body, &resp) - resp.Code = 200 - resp.Msg = "Success" - for index, _ := range resp.Items { - resp.Items[index].ProjectId = in.ProjectId + //根据智算类型判断走华为智算还是南京智算 + modelArtsType := in.ModelArtsType + if modelArtsType == "huawei" { + modelArtsUrl := l.svcCtx.Config.ModelArtsUrl + url := modelArtsUrl + "v2/" + in.ProjectId + "/training-job-searches?limit=" + limit + "&offset=" + offset + reqByte, err := json.Marshal(in) + payload := strings.NewReader(string(reqByte)) + token := common.GetToken() + statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, url, payload, token) + if err != nil { + return nil, err + } + if statusCode == 200 { + json.Unmarshal(body, &resp) + resp.Code = 200 + resp.Msg = "Success" + for index, _ := range resp.Items { + resp.Items[index].ProjectId = in.ProjectId + } + } else if statusCode != 200 { + json.Unmarshal(body, &resp) + resp.Code = 400 + resp.Msg = "Failure" + } + } else if modelArtsType == "nanjing" { + AK := l.svcCtx.Config.AK + SK := l.svcCtx.Config.SK + NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl + XProjectId := l.svcCtx.Config.XProjectId + XDomainId := l.svcCtx.Config.XDomainId + s := core.Signer{ + Key: AK, + Secret: SK, + } + r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/training-job-searches?offset="+offset+"&"+"limit="+limit, + nil) + if err != nil { + fmt.Println(err) + //return + } + r.Header.Add("content-type", "application/json;charset=UTF-8") + r.Header.Add("X-Project-Id", XProjectId) + r.Header.Add("X-Domain-Id", XDomainId) + r.Header.Add("x-stage", "RELEASE") + s.Sign(r) + client := http.DefaultClient + res, err := client.Do(r) + if err != nil { + fmt.Println(err) + } + defer res.Body.Close() + body, err := ioutil.ReadAll(res.Body) + if err != nil { + fmt.Println(err) } - } else if statusCode != 200 { json.Unmarshal(body, &resp) - resp.Code = 400 - resp.Msg = "Failure" } return &resp, nil } diff --git a/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/logic/listalgorithmslogic.go b/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/logic/listalgorithmslogic.go index 51e2544a..a9d5cf3d 100644 --- a/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/logic/listalgorithmslogic.go +++ b/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/logic/listalgorithmslogic.go @@ -1,13 +1,18 @@ package logic import ( + "APIGW-go-sdk/core" "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" "PCM/common/tool" + "bytes" "context" + "fmt" "github.com/zeromicro/go-zero/core/logx" + "io/ioutil" "k8s.io/apimachinery/pkg/util/json" + "net/http" "strconv" ) @@ -36,20 +41,59 @@ func (l *ListAlgorithmsLogic) ListAlgorithms(in *modelarts.ListAlgorithmsReq) (* } else { limit = "10" } - url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/" + in.ProjectId + "/algorithms?offset=" + offset + "&" + "limit=" + limit - token := common.GetToken() - statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, url, nil, token) - if err != nil { - return nil, err - } - if statusCode == 200 { + //根据智算类型判断走华为智算还是南京智算 + modelArtsType := in.ModelArtsType + + if modelArtsType == "huawei" { + modelArtsUrl := l.svcCtx.Config.ModelArtsUrl + url := modelArtsUrl + in.ProjectId + "v2/" + "/algorithms?offset=" + offset + "&" + "limit=" + limit + token := common.GetToken() + statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, url, nil, token) + if err != nil { + return nil, err + } + if statusCode == 200 { + json.Unmarshal(body, &resp) + resp.Code = 200 + resp.Msg = "Success" + } else if statusCode != 200 { + json.Unmarshal(body, &resp) + resp.Code = 400 + resp.Msg = "Failure" + + } + } else if modelArtsType == "nanjing" { + AK := l.svcCtx.Config.AK + SK := l.svcCtx.Config.SK + NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl + XProjectId := l.svcCtx.Config.XProjectId + XDomainId := l.svcCtx.Config.XDomainId + s := core.Signer{ + Key: AK, + Secret: SK, + } + r, err := http.NewRequest("GET", NanjingModelArtsUrl+in.ProjectId+"/algorithms?offset="+offset+"&"+"limit="+limit, + bytes.NewBuffer([]byte("foo=bar"))) + if err != nil { + fmt.Println(err) + //return + } + r.Header.Add("content-type", "application/json;charset=UTF-8") + r.Header.Add("X-Project-Id", XProjectId) + r.Header.Add("X-Domain-Id", XDomainId) + r.Header.Add("x-stage", "RELEASE") + s.Sign(r) + client := http.DefaultClient + res, err := client.Do(r) + if err != nil { + fmt.Println(err) + } + defer res.Body.Close() + body, err := ioutil.ReadAll(res.Body) + if err != nil { + fmt.Println(err) + } json.Unmarshal(body, &resp) - resp.Code = 200 - resp.Msg = "Success" - } else if statusCode != 200 { - json.Unmarshal(body, &resp) - resp.Code = 400 - resp.Msg = "Failure" } return &resp, nil } diff --git a/adaptor/PCM-AI/PCM-MODELARTS/rpc/pb/pcm-modelarts.proto b/adaptor/PCM-AI/PCM-MODELARTS/rpc/pb/pcm-modelarts.proto index 2b6843d4..f9d19d1e 100644 --- a/adaptor/PCM-AI/PCM-MODELARTS/rpc/pb/pcm-modelarts.proto +++ b/adaptor/PCM-AI/PCM-MODELARTS/rpc/pb/pcm-modelarts.proto @@ -53,6 +53,7 @@ message DataSetReq{ string project_id = 1; // @gotags: copier:"ProjectId" int32 limit = 2; // @gotags: copier:"Limit" int32 offset = 3; // @gotags: copier:"Offset" + string modelArtsType =4; // @gotags: copier:"modelArtsType" } message DataSetResp{ @@ -89,6 +90,7 @@ message ImportTaskDataReq{ string dataset_id = 1; string project_id = 2; string import_path = 3; + string modelArtsType =4; // @gotags: copier:"modelArtsType" } message ImportTaskDataResp{ @@ -108,6 +110,7 @@ message ListImportTasksReq{ string project_id = 2; // @gotags: copier:"ProjectId" int32 limit = 3; // @gotags: copier:"Limit" int32 offset = 4; // @gotags: copier:"Offset" + string modelArtsType =5; // @gotags: copier:"modelArtsType" } @@ -193,6 +196,7 @@ message ListTrainingJobsreq{ string project_id = 1;//@gotags: copier:"ProjectId" int32 limit =2;//@gotags: copier:"Limit" int32 offSet =3;//@gotags: copier:"Offset" + string modelArtsType =4; // @gotags: copier:"modelArtsType" } message ListTrainingJobsresp{ @@ -480,6 +484,7 @@ message CreateTrainingJobReq { Algorithms algorithm = 3; // @gotags: copier:"AlgorithmsCtRq" SpecsC spec = 4; // @gotags: copier:"SpecsCtRq" string project_id =5; // @gotags: copier:"ProjectId" + string modelArtsType =6; // @gotags: copier:"modelArtsType" } //创建训练任务出参 message CreateTrainingJobResp{ @@ -572,6 +577,7 @@ message CreateTrainingJobConfigReq { int32 spec_id = 7; repeated ParameterS parameter = 8; string project_id =9; + string modelArtsType =10; // @gotags: copier:"modelArtsType" } message ParameterS { @@ -591,6 +597,7 @@ message CreateTrainingJobConfigResp{ message DeleteTrainingJobReq{ string project_id =1; //@gotags: copier:"Project_id" string training_job_id =2; //@gotags: copier:"Training_job_id" + string modelArtsType =3; // @gotags: copier:"modelArtsType" } message DeleteTrainingJobResp{ int32 code =1; //@gotags: copier:"Code" @@ -604,6 +611,7 @@ message DeleteTrainingJobResp{ message DeleteTrainingJobConfigReq{ string project_id =1; string config_name=2; + string modelArtsType =3; // @gotags: copier:"modelArtsType" } message DeleteTrainingJobConfigResp{ bool is_success =1; @@ -623,6 +631,7 @@ message ListTrainingJobConfigReq{ string order =5; string search_content =6; string config_type =7; + string modelArtsType =8; // @gotags: copier:"modelArtsType" } message ListTrainingJobConfigResp{ @@ -654,6 +663,7 @@ message CreateAlgorithmReq{ repeated ResourceRequirements resource_requirements = 3;// @gotags: copier:"ResourceRequirementsCARq" AdvancedConfigAl advanced_config = 4;// @gotags: copier:"AdvancedConfigCARq" string project_id =5;// @gotags: copier:"ProjectIdCARq" + string modelArtsType =6; // @gotags: copier:"modelArtsType" } message ResourceRequirements{ string key=1; @@ -843,9 +853,10 @@ message EngineAlRp { /******************ListAlgorithms start*************************/ message ListAlgorithmsReq{ - string project_id =1; // @gotags: copier:"ProjectId" - int32 offset =2; // @gotags: copier:"Offset" - int32 limit= 3; // @gotags: copier:"Limit" + string modelArtsType =1; // @gotags: copier:"modelArtsType" + string project_id =2; // @gotags: copier:"ProjectId" + int32 offset =3; // @gotags: copier:"Offset" + int32 limit= 4; // @gotags: copier:"Limit" } message ListAlgorithmsResp{ @@ -884,6 +895,7 @@ message JobConfigAlRq { message DeleteAlgorithmsReq{ string project_id =1; // @gotags: copier:"ProjectId" string algorithm_id =2; // @gotags: copier:"AlgorithmId" + string modelArtsType =3; // @gotags: copier:"modelArtsType" } message DeleteAlgorithmsResp{ @@ -897,6 +909,7 @@ message DeleteAlgorithmsResp{ message ShowAlgorithmByUuidReq{ string project_id =1; // @gotags: copier:"ProjectId" string algorithm_id =2; // @gotags: copier:"AlgorithmId" + string modelArtsType =3; // @gotags: copier:"modelArtsType" } message ShowAlgorithmByUuidResp{ @@ -927,7 +940,7 @@ message ExportTaskReq{ bool with_column_header = 12; // @gotags: copier:"WithColumnHeader" string dataset_id = 13; // @gotags: copier:"DatasetId" string project_id = 14; // @gotags: copier:"ProjectId" - + string modelArtsType =15; // @gotags: copier:"modelArtsType" } message ExportTaskDataResp{ @@ -1012,6 +1025,7 @@ message GetExportTasksOfDatasetReq{ int32 export_type = 3; // @gotags: copier:"ExportType" int32 limit = 4; // @gotags: copier:"Limit" int32 offset = 5; // @gotags: copier:"Offset" + string modelArtsType =6; // @gotags: copier:"modelArtsType" } message GetExportTasksOfDatasetResp{ @@ -1061,6 +1075,7 @@ message GetExportTaskStatusOfDatasetReq{ string resource_id = 1; // @gotags: copier:"ResourceId" string project_id = 2; // @gotags: copier:"ProjectId" string task_id = 3; // @gotags: copier:"TaskId" + string modelArtsType =4; // @gotags: copier:"modelArtsType" } message GetExportTaskStatusOfDatasetResp{ @@ -1099,7 +1114,7 @@ message CreateProcessorTaskReq{ string version_id = 8; WorkPath work_path = 9; string workspace_id = 10; - + string modelArtsType =11; // @gotags: copier:"modelArtsType" } message CreateProcessorTaskResp{ @@ -1145,6 +1160,7 @@ message OperatorParam { message DescribeProcessorTaskReq{ string project_id = 1; string task_id = 2; + string modelArtsType =4; // @gotags: copier:"modelArtsType" } message DescribeProcessorTaskResp{ @@ -1196,7 +1212,7 @@ message CreateModelReq{ string model_name = 22; repeated string install_type = 23; repeated CreateModelRequestInferParams input_params = 24; - + string modelArtsType =25; // @gotags: copier:"modelArtsType" } message CreateModelResp{ @@ -1262,6 +1278,7 @@ message DeleteModelReq{ string project_id = 1; string model_id = 2; bool cascade = 3; + string modelArtsType =4; // @gotags: copier:"modelArtsType" } message DeleteModelResp{ @@ -1290,6 +1307,7 @@ message ListModelReq{ string workspace_id = 9; string model_type = 10; string not_model_type = 11; + string modelArtsType =12; // @gotags: copier:"modelArtsType" } message ListModelResp{ @@ -1336,6 +1354,7 @@ message ModelSpecification{ message ShowModelReq{ string project_id = 1; string model_id = 2; + string modelArtsType =3; // @gotags: copier:"modelArtsType" } message ShowModelResp{ @@ -1411,7 +1430,7 @@ message CreateServiceReq{ string subnet_network_id = 9; // @gotags: copier:"SubnetNetworkId" repeated ServiceConfig config = 10; // @gotags: copier:"Config" string project_id = 11; // @gotags: copier:"ProjectId" - + string modelArtsType =12; // @gotags: copier:"modelArtsType" } message CreateServiceResp{ @@ -1459,6 +1478,7 @@ message CustomSpec{ message DeleteServiceReq{ string project_id = 1; // @gotags: copier:"ProjectId" string service_id = 2; // @gotags: copier:"ServiceId" + string modelArtsType =3; // @gotags: copier:"modelArtsType" } message DeleteServiceResp{ @@ -1474,6 +1494,7 @@ message DeleteServiceResp{ message ShowServiceReq{ string project_id = 1; // @gotags: copier:"ProjectId" string service_id = 2; // @gotags: copier:"ServiceId" + string modelArtsType =3; // @gotags: copier:"modelArtsType" } message ShowServiceResp{ @@ -1546,6 +1567,7 @@ message ListServicesReq{ string project_id = 1;//@gotags: copier:"ProjectId" int32 limit =2;//@gotags: copier:"Limit" int32 offSet =3;//@gotags: copier:"Offset" + string modelArtsType =4; // @gotags: copier:"modelArtsType" } message ListServicesResp{ @@ -1593,6 +1615,7 @@ message ListClustersReq{ int64 limit = 4; // @gotags: copier:"Limit" string sort_by = 5; // @gotags: copier:"SortBy" string order = 6; // @gotags: copier:"Order" + string modelArtsType =7; // @gotags: copier:"modelArtsType" } message ListClustersResp{ @@ -1640,6 +1663,7 @@ message CreateDataSetReq { string work_path = 5; // @gotags: copier:"WorkPath" int32 work_path_type = 6; // @gotags: copier:"WorkPathType" string project_id = 7; // @gotags: copier:"ProjectId" + string modelArtsType =8; // @gotags: copier:"modelArtsType" } message CreateDataSetResq{ @@ -1651,6 +1675,7 @@ message CreateDataSetResq{ message DeleteDataSetReq { string project_id = 1; // @gotags: copier:"ProjectId" string dataset_id = 2; // @gotags: copier:"DatasetId" + string modelArtsType =3; // @gotags: copier:"modelArtsType" } message DeleteDataSetResq{ @@ -1662,6 +1687,7 @@ message DeleteDataSetResq{ message ListNotebookReq{ string project_id = 1; // @gotags: copier:"ProjectId" ListNotebookParam param = 2; // @gotags: copier:"Param" + string modelArtsType =3; // @gotags: copier:"modelArtsType" } message ListNotebookResp{ int32 current = 1; // @gotags: copier:"Current" @@ -1690,6 +1716,7 @@ message ListNotebookParam{ message CreateNotebookReq{ string project_id = 1; // @gotags: copier:"ProjectId" CreateNotebookParam param = 2; // @gotags: copier:"Param" + string modelArtsType =3; // @gotags: copier:"modelArtsType" } message CreateNotebookResp{ NotebookResp notebookResp = 1; // @gotags: copier:"NotebookResp" @@ -1716,6 +1743,7 @@ message StartNotebookReq{ string id = 1; // @gotags: copier:"Id" string project_id = 2; // @gotags: copier:"ProjectId" StartNotebookParam param = 3; // @gotags: copier:"Param" + string modelArtsType =4; // @gotags: copier:"modelArtsType" } message StartNotebookResp{ @@ -1732,6 +1760,8 @@ message StartNotebookParam{ message StopNotebookReq{ string id = 1; // @gotags: copier:"Id" string project_id = 2; // @gotags: copier:"ProjectId" + string modelArtsType =3; // @gotags: copier:"modelArtsType" + } message StopNotebookResp{ NotebookResp notebookResp = 1; // @gotags: copier:"NotebookResp" @@ -1743,6 +1773,8 @@ message StopNotebookResp{ message GetNotebookStorageReq{ string instance_id = 1; // @gotags: copier:"InstanceId" string project_id = 2; // @gotags: copier:"ProjectId" + string modelArtsType =3; // @gotags: copier:"modelArtsType" + } message GetNotebookStorageResp{ int32 current = 1; // @gotags: copier:"Current" @@ -1755,6 +1787,8 @@ message MountNotebookStorageReq{ string instance_id = 1; // @gotags: copier:"InstanceId" string project_id = 2; // @gotags: copier:"ProjectId" MountNotebookStorageParam param = 3; // @gotags: copier:"Param" + string modelArtsType =4; // @gotags: copier:"modelArtsType" + } message MountNotebookStorageResp{ string category = 1; // @gotags: copier:"Category" @@ -1926,6 +1960,7 @@ message LeaseReq{ message GetVisualizationJobReq{ string project_id = 1; // @gotags: copier:"project_id" GetVisualizationJobParam param = 2; // @gotags: copier:"param" + string modelArtsType =3; // @gotags: copier:"modelArtsType" } message GetVisualizationJobResp{ bool is_success = 1; // @gotags: copier:"is_success" @@ -1959,6 +1994,7 @@ message GetVisualizationJobParam{ message CreateVisualizationJobReq{ string project_id = 1; // @gotags: copier:"project_id" CreateVisualizationJobParam param = 2; // @gotags: copier:"param" + string modelArtsType =3; // @gotags: copier:"modelArtsType" } message CreateVisualizationJobResp{ string error_message = 1; // @gotags: copier:"error_message"