# Conflicts:
# adaptor/PCM-CORE/api/desc/core/pcm-core.api
# adaptor/PCM-CORE/rpc/pcmcore.go
# common/config/nacos.go
Former-commit-id: f7d1f70f11
pull/9/head
| @@ -1,15 +1,21 @@ | |||
| pcm-core: | |||
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o pcm-core adaptor/PCM-CORE/api/pcm.go | |||
| pcm-core-api: | |||
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o pcm-core-api adaptor/PCM-CORE/api/pcm.go | |||
| pcm-ac: | |||
| pcm-core-rpc: | |||
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o pcm-core-rpc adaptor/PCM-CORE/rpc/pcmcore.go | |||
| pcm-ac-rpc: | |||
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o pcm-ac adaptor/PCM-HPC/PCM-AC/rpc/hpcac.go | |||
| pcm-kubeNative: | |||
| pcm-kubenative-rpc: | |||
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o pcm-kubenative adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/pcmkubenative.go | |||
| pcm-modelarts: | |||
| pcm-modelarts-rpc: | |||
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o pcm-modelarts adaptor/PCM-AI/PCM-MODELARTS/rpc/pcmmodelarts.go | |||
| all-build: pcm-core pcm-ac pcm-kubeNative pcm-modelarts | |||
| pcm-ceph-rpc: | |||
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o pcm-ceph adaptor/PCM-STORAGE/PCM-CEPH/rpc/pcmceph.go | |||
| all-build: pcm-core-rpc pcm-core-api pcm-ac-rpc pcm-kubenative-rpc pcm-modelarts-rpc pcm-ceph-rpc | |||
| .PHONY: pcm-core pcm-ac pcm-kubeNative pcm-modelarts | |||
| .PHONY: pcm-core-rpc pcm-core-api pcm-ac-rpc pcm-kubenative-rpc pcm-modelarts-rpc pcm-ceph-rpc | |||
| @@ -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 | |||
| @@ -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 | |||
| } | |||
| @@ -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", | |||
| } | |||
| @@ -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...) | |||
| } | |||
| @@ -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) | |||
| } | |||
| @@ -4,7 +4,7 @@ NacosConfig: | |||
| ServerConfigs: | |||
| # - IpAddr: 127.0.0.1 | |||
| # Port: 8848 | |||
| - IpAddr: 10.101.15.7 | |||
| - IpAddr: nacos.jcce.dev | |||
| Port: 8848 | |||
| ClientConfig: | |||
| NamespaceId: test | |||
| @@ -64,3 +64,8 @@ type Auth struct { | |||
| } `json:"scope"` | |||
| } `json:"auth"` | |||
| } | |||
| type Error struct { | |||
| ErrorCode string `json:"error_code"` | |||
| ErrorMsg string `json:"error_msg"` | |||
| } | |||
| @@ -9,4 +9,5 @@ type Config struct { | |||
| zrpc.RpcServerConf | |||
| LogConf logx.LogConf | |||
| PcmCoreRpcConf zrpc.RpcClientConf | |||
| ModelArtsConfig | |||
| } | |||
| @@ -0,0 +1,15 @@ | |||
| package config | |||
| type ModelArtsConfig struct { | |||
| ModelArtsUrl string `json:"ModelArtsUrl"` | |||
| IAMUser string `json:"IAMUser"` | |||
| NanjingModelArtsUrl string `json:"NanjingModelArtsUrl"` | |||
| AK string `json:"AK"` | |||
| SK string `json:"SK"` | |||
| XProjectId string `json:"X-Project-Id"` | |||
| XDomainId string `json:"X-Domain-Id"` | |||
| HaweiModelArtsType string `json:"HaweiModelArtsType"` | |||
| NanjingModelArtsType string `json:"NanjingModelArtsType"` | |||
| HuaweiProjectId string `json:"Huawei-Project-Id"` | |||
| NanjingProjectId string `json:"Nanjing-Project-Id"` | |||
| } | |||
| @@ -5,9 +5,14 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| "PCM/common/tool" | |||
| "bytes" | |||
| "context" | |||
| "encoding/json" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| "io/ioutil" | |||
| "net/http" | |||
| "strings" | |||
| ) | |||
| @@ -28,25 +33,63 @@ func NewCreateAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *C | |||
| // CreateAlgorithm 创建算法 | |||
| func (l *CreateAlgorithmLogic) CreateAlgorithm(in *modelarts.CreateAlgorithmReq) (*modelarts.CreateAlgorithmResp, error) { | |||
| var resp modelarts.CreateAlgorithmResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/" + in.ProjectId + "/algorithms" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| 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 == 201 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 200 | |||
| resp.Msg = "Success" | |||
| } else if statusCode == 400 { | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/algorithms" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| 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 == 201 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 200 | |||
| resp.Msg = "Success" | |||
| } else if statusCode == 400 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| 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, | |||
| } | |||
| reqByte, err := json.Marshal(in) | |||
| r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/algorithms", | |||
| bytes.NewBuffer(reqByte)) | |||
| 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 = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| return &resp, nil | |||
| } | |||
| @@ -2,14 +2,18 @@ package logic | |||
| import ( | |||
| "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/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strings" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| @@ -31,20 +35,56 @@ func NewCreateDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cre | |||
| func (l *CreateDataSetLogic) CreateDataSet(in *modelarts.CreateDataSetReq) (*modelarts.CreateDataSetResq, error) { | |||
| // todo: add your logic here and delete this line | |||
| var resp modelarts.CreateDataSetResq | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/" + in.ProjectId + "/datasets" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.POST, url, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| if &resp == nil { | |||
| return nil, err | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/datasets" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.POST, url, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| if &resp == nil { | |||
| return nil, err | |||
| } | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| reqByte, err := json.Marshal(in) | |||
| r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/datasets", | |||
| bytes.NewBuffer(reqByte)) | |||
| 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-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) | |||
| } | |||
| return &resp, nil | |||
| } | |||
| @@ -7,15 +7,18 @@ package logic | |||
| import ( | |||
| "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/JCCE-nudt/apigw-go-sdk/core" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strings" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type CreateModelLogic struct { | |||
| @@ -36,17 +39,53 @@ func NewCreateModelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Creat | |||
| func (l *CreateModelLogic) CreateModel(in *modelarts.CreateModelReq) (*modelarts.CreateModelResp, error) { | |||
| // todo: add your logic here and delete this line | |||
| var resp modelarts.CreateModelResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/models" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/models" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.POST, url, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| reqByte, err := json.Marshal(in) | |||
| r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/models", | |||
| bytes.NewBuffer(reqByte)) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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) | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.POST, url, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| return &resp, nil | |||
| } | |||
| @@ -2,15 +2,17 @@ package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "encoding/json" | |||
| "strings" | |||
| "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/JCCE-nudt/apigw-go-sdk/core" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| ) | |||
| type CreateNotebookLogic struct { | |||
| @@ -28,19 +30,76 @@ func NewCreateNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cr | |||
| } | |||
| func (l *CreateNotebookLogic) CreateNotebook(in *modelarts.CreateNotebookReq) (*modelarts.CreateNotebookResp, error) { | |||
| var resp modelarts.CreateNotebookResp | |||
| createUrl := "https://modelarts.cn-east-3.myhuaweicloud.com/v1/{project_id}/notebooks" | |||
| createUrl = strings.Replace(createUrl, "{project_id}", in.ProjectId, -1) | |||
| reqByte, err := json.Marshal(in.Param) | |||
| if err != nil { | |||
| panic(err.Error()) | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.POST, createUrl, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| resp := &modelarts.CreateNotebookResp{} | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| createUrl := modelArtsUrl + "v1/{project_id}/notebooks" | |||
| token := common.GetToken() | |||
| var createResp modelarts.NotebookResp | |||
| req := tool.GetACHttpRequest() | |||
| res, err := req. | |||
| SetHeader("x-auth-token", token). | |||
| SetPathParam("project_id", in.ProjectId). | |||
| SetBody(in.Param). | |||
| SetResult(&createResp). | |||
| Post(createUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| if res.StatusCode() == 200 || res.StatusCode() == 201 { | |||
| resp.NotebookResp = &createResp | |||
| resp.Code = int32(res.StatusCode()) | |||
| resp.Msg = "Success" | |||
| } else { | |||
| resp.Code = int32(res.StatusCode()) | |||
| resp.Msg = "Failure" | |||
| var errMsg common.Error | |||
| err := json.Unmarshal(res.Body(), &errMsg) | |||
| if err != nil { | |||
| errMsg.ErrorMsg = "" | |||
| } | |||
| resp.ErrorMsg = errMsg.ErrorMsg | |||
| } | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| reqByte, err := json.Marshal(in) | |||
| r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/notebooks", | |||
| bytes.NewBuffer(reqByte)) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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) | |||
| } | |||
| json.Unmarshal(body, &resp.NotebookResp) | |||
| return &resp, nil | |||
| return resp, nil | |||
| } | |||
| @@ -8,8 +8,13 @@ package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "bytes" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strings" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| @@ -36,17 +41,52 @@ func NewCreateProcessorTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext | |||
| func (l *CreateProcessorTaskLogic) CreateProcessorTask(in *modelarts.CreateProcessorTaskReq) (*modelarts.CreateProcessorTaskResp, error) { | |||
| // todo: add your logic here and delete this line | |||
| var resp modelarts.CreateProcessorTaskResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/" + in.ProjectId + "/processor-tasks/" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/processor-tasks/" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.POST, url, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| reqByte, err := json.Marshal(in) | |||
| r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/processor-tasks/", | |||
| bytes.NewBuffer(reqByte)) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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) | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.POST, url, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| return &resp, nil | |||
| } | |||
| @@ -10,8 +10,13 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| "PCM/common/tool" | |||
| "bytes" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strings" | |||
| ) | |||
| @@ -37,25 +42,61 @@ func NewCreateServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cre | |||
| func (l *CreateServiceLogic) CreateService(in *modelarts.CreateServiceReq) (*modelarts.CreateServiceResp, error) { | |||
| // todo: add your logic here and delete this line | |||
| var resp modelarts.CreateServiceResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/services" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| 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 { | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/services" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| 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" | |||
| } else if statusCode != 200 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| reqByte, err := json.Marshal(in) | |||
| r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/services", | |||
| bytes.NewBuffer(reqByte)) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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 | |||
| } | |||
| @@ -3,8 +3,13 @@ package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "bytes" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strings" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| @@ -30,25 +35,61 @@ func NewCreateTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Create | |||
| // creat task 创建导入任务 | |||
| func (l *CreateTaskLogic) CreateTask(in *modelarts.ImportTaskDataReq) (*modelarts.ImportTaskDataResp, error) { | |||
| var resp modelarts.ImportTaskDataResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/" + in.ProjectId + "/datasets/" + in.DatasetId + "/import-tasks" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| 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 { | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/datasets/" + in.DatasetId + "/import-tasks" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| 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" | |||
| } else if statusCode != 200 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| reqByte, err := json.Marshal(in) | |||
| r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/datasets"+in.DatasetId+"/import-tasks", | |||
| bytes.NewBuffer(reqByte)) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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 | |||
| } | |||
| @@ -3,8 +3,13 @@ package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "bytes" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strings" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| @@ -30,20 +35,55 @@ func NewCreateTrainingJobConfigLogic(ctx context.Context, svcCtx *svc.ServiceCon | |||
| // CreateTrainingJobConfig 创建训练作业参数 | |||
| func (l *CreateTrainingJobConfigLogic) CreateTrainingJobConfig(in *modelarts.CreateTrainingJobConfigReq) (*modelarts.CreateTrainingJobConfigResp, error) { | |||
| var resp modelarts.CreateTrainingJobConfigResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/training-job-configs" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.POST, url, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| if &resp == nil { | |||
| return nil, err | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/training-job-configs" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.POST, url, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| if &resp == nil { | |||
| return nil, err | |||
| } | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| reqByte, err := json.Marshal(in) | |||
| r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/training-job-configs", | |||
| bytes.NewBuffer(reqByte)) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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) | |||
| } | |||
| return &resp, nil | |||
| } | |||
| @@ -2,14 +2,18 @@ package logic | |||
| import ( | |||
| "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/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strings" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| @@ -30,25 +34,64 @@ func NewCreateTrainingJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) | |||
| // CreateTrainingJob 创建训练作业 | |||
| func (l *CreateTrainingJobLogic) CreateTrainingJob(in *modelarts.CreateTrainingJobReq) (*modelarts.CreateTrainingJobResp, error) { | |||
| var resp modelarts.CreateTrainingJobResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/" + in.ProjectId + "/training-jobs" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| 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 == 201 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 200 | |||
| resp.Msg = "Success" | |||
| } else if statusCode != 201 { | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/training-jobs" | |||
| //url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/0a62ffb0d48026c12fbfc011b8d23f0b/training-jobs" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| 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 == 201 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 200 | |||
| resp.Msg = "Success" | |||
| } else if statusCode != 201 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| 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, | |||
| } | |||
| reqByte, err := json.Marshal(in) | |||
| r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/training-jobs", | |||
| bytes.NewBuffer(reqByte)) | |||
| 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 = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| return &resp, nil | |||
| } | |||
| @@ -3,8 +3,13 @@ package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "bytes" | |||
| "context" | |||
| "encoding/json" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "net/http" | |||
| "strings" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| @@ -29,19 +34,55 @@ func NewCreateVisualizationJobLogic(ctx context.Context, svcCtx *svc.ServiceCont | |||
| func (l *CreateVisualizationJobLogic) CreateVisualizationJob(in *modelarts.CreateVisualizationJobReq) (*modelarts.CreateVisualizationJobResp, error) { | |||
| var resp modelarts.CreateVisualizationJobResp | |||
| createVisualJobUrl := "https://modelarts.cn-east-3.myhuaweicloud.com/v1/{project_id}/visualization-jobs" | |||
| createVisualJobUrl = strings.Replace(createVisualJobUrl, "{project_id}", in.ProjectId, -1) | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| createVisualJobUrl := modelArtsUrl + "/v1/{project_id}/visualization-jobs" | |||
| createVisualJobUrl = strings.Replace(createVisualJobUrl, "{project_id}", in.ProjectId, -1) | |||
| reqByte, err := json.Marshal(in.Param) | |||
| if err != nil { | |||
| panic(err.Error()) | |||
| reqByte, err := json.Marshal(in.Param) | |||
| if err != nil { | |||
| panic(err.Error()) | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.POST, createVisualJobUrl, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| reqByte, err := json.Marshal(in) | |||
| r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/visualization-jobs", | |||
| bytes.NewBuffer(reqByte)) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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) | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.POST, createVisualJobUrl, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| return &resp, nil | |||
| } | |||
| @@ -27,9 +27,10 @@ func InitCron(svc *svc.ServiceContext) { | |||
| submitJob(infoList, submitJobLogic) | |||
| // 查询运行中的任务列表同步信息 | |||
| listReq := modelarts.ListTrainingJobsreq{ | |||
| ProjectId: "0a62ffb0d48026c12fbfc011b8d23f0b", | |||
| Limit: 10, | |||
| OffSet: 0, | |||
| ProjectId: "0a62ffb0d48026c12fbfc011b8d23f0b", | |||
| Limit: 10, | |||
| OffSet: 0, | |||
| ModelArtsType: "cn-north-4.myhuawei", | |||
| } | |||
| listJob, err := listLogic.GetListTrainingJobs(&listReq) | |||
| if err != nil { | |||
| @@ -48,27 +49,7 @@ func InitCron(svc *svc.ServiceContext) { | |||
| infoList.AiInfoList[index].StartTime = time.Time.String(startTime) | |||
| } | |||
| infoList.AiInfoList[index].RunningTime = int64(job.Status.Duration) / 1000 | |||
| if job.Status.Phase == "Running" { | |||
| infoList.AiInfoList[index].Status = "Running" | |||
| } | |||
| if job.Status.Phase == "Completed" { | |||
| infoList.AiInfoList[index].Status = "Completed" | |||
| } | |||
| if job.Status.Phase == "Creating" { | |||
| infoList.AiInfoList[index].Status = "Creating" | |||
| } | |||
| if job.Status.Phase == "Pending" { | |||
| infoList.AiInfoList[index].Status = "Pending" | |||
| } | |||
| if job.Status.Phase == "Terminated" { | |||
| infoList.AiInfoList[index].Status = "Terminated" | |||
| } | |||
| if job.Status.Phase == "Terminating" { | |||
| infoList.AiInfoList[index].Status = "Terminating" | |||
| } | |||
| if job.Status.Phase == "Abnormal" { | |||
| infoList.AiInfoList[index].Status = "Abnormal" | |||
| } | |||
| infoList.AiInfoList[index].Status = job.Status.Phase | |||
| } | |||
| } | |||
| @@ -85,23 +66,129 @@ func submitJob(infoList *pcmcoreclient.InfoListResp, submitJobLogic *CreateTrain | |||
| for index, _ := range infoList.AiInfoList { | |||
| if infoList.AiInfoList[index].Status == "Saved" { | |||
| submitReq := modelarts.CreateTrainingJobReq{ | |||
| Kind: "job", | |||
| ProjectId: "0a62ffb0d48026c12fbfc011b8d23f0b", | |||
| ModelArtsType: "cn-north-4.myhuawei", | |||
| Kind: "job", | |||
| ProjectId: "0a62ffb0d48026c12fbfc011b8d23f0b", | |||
| Metadata: &modelarts.MetadataS{ | |||
| Name: infoList.AiInfoList[index].Name, | |||
| WorkspaceId: "0", | |||
| Description: "This is a ModelArts Demo Job", | |||
| }, | |||
| Algorithm: &modelarts.Algorithms{ | |||
| Command: "echo hello;sleep 100;echo hello;sleep 100;echo hello", | |||
| Engine: &modelarts.EngineCreateTraining{ | |||
| ImageUrl: "jcce/nginx:v1", | |||
| //SubscriptionId: infoList.AiInfoList[index].SubscriptionId, | |||
| //ItemVersionId: infoList.AiInfoList[index].ItemVersionId, | |||
| SubscriptionId: "26a0d9a9-808a-43f4-9a06-c9ea6bdc53d2", | |||
| ItemVersionId: "2.0.0", | |||
| //Command: infoList.AiInfoList[index].Command, | |||
| //Engine: &modelarts.EngineCreateTraining{ | |||
| // ImageUrl: infoList.AiInfoList[index].ImageUrl, | |||
| //}, | |||
| Parameters: []*modelarts.ParametersTrainJob{ | |||
| { | |||
| Name: "do_train", | |||
| Value: "True", | |||
| }, | |||
| { | |||
| Name: "do_eval_along_train", | |||
| Value: "True", | |||
| }, | |||
| { | |||
| Name: "lr", | |||
| Value: "0.01", | |||
| }, | |||
| { | |||
| Name: "epochs", | |||
| Value: "60", | |||
| }, | |||
| { | |||
| Name: "batch_size", | |||
| Value: "64", | |||
| }, | |||
| { | |||
| Name: "eval_batch_size", | |||
| Value: "64", | |||
| }, | |||
| { | |||
| Name: "lr_scheduler", | |||
| Value: "cos", | |||
| }, | |||
| { | |||
| Name: "lr_step", | |||
| Value: "20", | |||
| }, | |||
| { | |||
| Name: "mixup", | |||
| Value: "0.2", | |||
| }, | |||
| { | |||
| Name: "label_smoothing", | |||
| Value: "0.1", | |||
| }, | |||
| { | |||
| Name: "warmup_epochs", | |||
| Value: "5", | |||
| }, | |||
| { | |||
| Name: "rand_aug", | |||
| Value: "True", | |||
| }, | |||
| { | |||
| Name: "num_workers", | |||
| Value: "8", | |||
| }, | |||
| { | |||
| Name: "model_name", | |||
| Value: "resnest50", | |||
| }, | |||
| { | |||
| Name: "use_dali", | |||
| Value: "False", | |||
| }, | |||
| { | |||
| Name: "accumulation_steps", | |||
| Value: "1", | |||
| }, | |||
| { | |||
| Name: "do_data_cleaning", | |||
| Value: "True", | |||
| }, | |||
| { | |||
| Name: "max_to_keep", | |||
| Value: "10", | |||
| }, | |||
| }, | |||
| Inputs: []*modelarts.InputTraining{ | |||
| { | |||
| Name: "data_url", | |||
| AccessMethod: "parameter", | |||
| Remote: &modelarts.RemoteTra{ | |||
| Dataset: &modelarts.DatasetTra{ | |||
| Id: "L0cTaBjZF61k27w8T74", | |||
| Name: "dataset-flower", | |||
| VersionName: "V001", | |||
| VersionId: "xBx4lPDk4rtf6mEex4W", | |||
| }, | |||
| }, | |||
| }, | |||
| }, | |||
| Outputs: []*modelarts.OutputTraining{ | |||
| { | |||
| Name: "train_url", | |||
| AccessMethod: "parameter", | |||
| Remote: &modelarts.RemoteOut{ | |||
| Obs: &modelarts.ObsTra{ | |||
| ObsUrl: "/jointcloud-out1/flower/", | |||
| }, | |||
| }, | |||
| }, | |||
| }, | |||
| }, | |||
| Spec: &modelarts.SpecsC{ | |||
| Resource: &modelarts.ResourceCreateTraining{ | |||
| FlavorId: "modelarts.p3.large.public.free", | |||
| NodeCount: 1, | |||
| FlavorId: infoList.AiInfoList[index].FlavorId, | |||
| NodeCount: 1, | |||
| Policy: "regular", | |||
| FlavorLabel: "[限时免费] GPU: 1*NVIDIA-V100(32GB) | CPU: 8 核 64GB 780GB", | |||
| }, | |||
| }, | |||
| } | |||
| @@ -4,7 +4,11 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strings" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| @@ -30,22 +34,66 @@ func NewDeleteAlgorithmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) * | |||
| // DeleteAlgorithms 删除算法 | |||
| func (l *DeleteAlgorithmsLogic) DeleteAlgorithms(in *modelarts.DeleteAlgorithmsReq) (*modelarts.DeleteAlgorithmsResp, error) { | |||
| var resp modelarts.DeleteAlgorithmsResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/" + in.ProjectId + "/algorithms/" + in.AlgorithmId | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, url, payload, token) | |||
| if statusCode == 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 200 | |||
| resp.Msg = "Success" | |||
| } else if statusCode != 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 400 | |||
| resp.Msg = "Failure" | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/algorithms/" + in.AlgorithmId | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, url, payload, token) | |||
| if statusCode == 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 200 | |||
| resp.Msg = "Success" | |||
| } else if statusCode != 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| 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("DELETE", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/algorithms/"+in.AlgorithmId, | |||
| 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) | |||
| statusCode := res.StatusCode | |||
| if statusCode == 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 200 | |||
| resp.Msg = "Success" | |||
| } else if statusCode != 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| } | |||
| return &resp, nil | |||
| } | |||
| @@ -4,7 +4,11 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strings" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| @@ -31,17 +35,69 @@ func NewDeleteDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Del | |||
| func (l *DeleteDataSetLogic) DeleteDataSet(in *modelarts.DeleteDataSetReq) (*modelarts.DeleteDataSetResq, error) { | |||
| // todo: add your logic here and delete this line | |||
| var resp modelarts.DeleteDataSetResq | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/datasets/" + in.DatasetId | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/datasets/" + in.DatasetId | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, url, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| if statusCode == 204 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 200 | |||
| resp.Msg = "Success" | |||
| } else if statusCode != 204 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| r, err := http.NewRequest("DELETE", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/datasets/"+in.DatasetId, | |||
| nil) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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) | |||
| statusCode := res.StatusCode | |||
| if statusCode == 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 200 | |||
| resp.Msg = "Success" | |||
| } else if statusCode != 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.DELETE, url, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| return &resp, nil | |||
| } | |||
| @@ -9,7 +9,11 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strings" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| @@ -35,17 +39,66 @@ func NewDeleteModelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Delet | |||
| func (l *DeleteModelLogic) DeleteModel(in *modelarts.DeleteModelReq) (*modelarts.DeleteModelResp, error) { | |||
| // todo: add your logic here and delete this line | |||
| var resp modelarts.DeleteModelResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/models/" + in.ModelId | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.DELETE, url, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/models/" + in.ModelId | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, url, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| if statusCode == 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 200 | |||
| resp.Msg = "Success" | |||
| } else if statusCode != 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| r, err := http.NewRequest("DELETE", NanjingModelArtsUrl+in.ProjectId+"/models/"+in.ModelId, | |||
| nil) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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) | |||
| statusCode := res.StatusCode | |||
| if statusCode == 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 200 | |||
| resp.Msg = "Success" | |||
| } else if statusCode != 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| return &resp, nil | |||
| } | |||
| @@ -11,7 +11,11 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| @@ -32,20 +36,62 @@ func NewDeleteServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Del | |||
| func (l *DeleteServiceLogic) DeleteService(in *modelarts.DeleteServiceReq) (*modelarts.DeleteServiceResp, error) { | |||
| var resp modelarts.DeleteServiceResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/services/" + in.ServiceId | |||
| token := common.GetToken() | |||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, 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" | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/services/" + in.ServiceId | |||
| token := common.GetToken() | |||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, 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 == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| r, err := http.NewRequest("DELETE", NanjingModelArtsUrl+in.ProjectId+"/services/"+in.ServiceId, | |||
| 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-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) | |||
| statusCode := res.StatusCode | |||
| if statusCode == 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 200 | |||
| resp.Msg = "Success" | |||
| } else if statusCode != 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| } | |||
| return &resp, nil | |||
| } | |||
| @@ -6,7 +6,11 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strings" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| @@ -29,15 +33,61 @@ func NewDeleteTrainingJobConfigLogic(ctx context.Context, svcCtx *svc.ServiceCon | |||
| // DeleteTrainingJobConfig 删除训练作业参数 | |||
| func (l *DeleteTrainingJobConfigLogic) DeleteTrainingJobConfig(in *modelarts.DeleteTrainingJobConfigReq) (*modelarts.DeleteTrainingJobConfigResp, error) { | |||
| var resp modelarts.DeleteTrainingJobConfigResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/training-job-configs/" + in.ConfigName | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.DELETE, url, strings.NewReader(``), token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| if &resp == nil { | |||
| return nil, err | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/training-job-configs/" + in.ConfigName | |||
| token := common.GetToken() | |||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, url, 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 == l.svcCtx.Config.HaweiModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| r, err := http.NewRequest("DELETE", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/training-job-configs/"+in.ConfigName, | |||
| nil) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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) | |||
| statusCode := res.StatusCode | |||
| if statusCode == 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 200 | |||
| resp.Msg = "Success" | |||
| } else if statusCode != 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| } | |||
| return &resp, nil | |||
| } | |||
| @@ -6,8 +6,12 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strings" | |||
| ) | |||
| @@ -28,25 +32,69 @@ func NewDeleteTrainingJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) | |||
| // DeleteTrainingJobConfig 删除训练作业 | |||
| func (l *DeleteTrainingJobLogic) DeleteTrainingJob(in *modelarts.DeleteTrainingJobReq) (*modelarts.DeleteTrainingJobResp, error) { | |||
| var resp modelarts.DeleteTrainingJobResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/" + in.ProjectId + "/training-jobs/" + in.TrainingJobId | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, url, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| if statusCode == 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 200 | |||
| resp.Msg = "Success" | |||
| } else if statusCode != 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 400 | |||
| resp.Msg = "Failure" | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/training-jobs/" + in.TrainingJobId | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, url, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| if statusCode == 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 200 | |||
| resp.Msg = "Success" | |||
| } else if statusCode != 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| 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("DELETE", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/training-jobs/"+in.TrainingJobId, | |||
| 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) | |||
| statusCode := res.StatusCode | |||
| if statusCode == 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 200 | |||
| resp.Msg = "Success" | |||
| } else if statusCode != 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| } | |||
| return &resp, nil | |||
| } | |||
| @@ -11,7 +11,11 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| @@ -33,12 +37,46 @@ func NewDescribeProcessorTaskLogic(ctx context.Context, svcCtx *svc.ServiceConte | |||
| func (l *DescribeProcessorTaskLogic) DescribeProcessorTask(in *modelarts.DescribeProcessorTaskReq) (*modelarts.DescribeProcessorTaskResp, error) { | |||
| // todo: add your logic here and delete this line | |||
| var resp modelarts.DescribeProcessorTaskResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/" + in.ProjectId + "/processor-tasks/" + in.TaskId | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.GET, url, nil, token) | |||
| if err != nil { | |||
| return nil, err | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/processor-tasks/" + in.TaskId | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.GET, url, nil, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/processor-tasks/"+in.TaskId, | |||
| nil) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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) | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| return &resp, nil | |||
| } | |||
| @@ -10,8 +10,13 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| _ "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| "PCM/common/tool" | |||
| "bytes" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strings" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| @@ -35,25 +40,60 @@ func NewExportTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Export | |||
| // ExportTask for modelarts | |||
| func (l *ExportTaskLogic) ExportTask(in *modelarts.ExportTaskReq) (*modelarts.ExportTaskDataResp, error) { | |||
| var resp modelarts.ExportTaskDataResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/" + in.ProjectId + "/datasets/" + in.DatasetId + "/export-tasks" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| 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" | |||
| } else if statusCode != 200 { | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == "huawei" { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/datasets/" + in.DatasetId + "/export-tasks" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| 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" | |||
| } 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 | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| reqByte, err := json.Marshal(in) | |||
| r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/datasets/"+in.DatasetId+"/export-tasks", | |||
| bytes.NewBuffer(reqByte)) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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 = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| return &resp, nil | |||
| } | |||
| @@ -0,0 +1,89 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type GetAiEnginesListLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewGetAiEnginesListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAiEnginesListLogic { | |||
| return &GetAiEnginesListLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| // GET ai-engines 查询作业引擎规格 | |||
| func (l *GetAiEnginesListLogic) GetAiEnginesList(in *modelarts.ListAiEnginesReq) (*modelarts.ListAiEnginesResp, error) { | |||
| // todo: add your logic here and delete this line | |||
| var resp modelarts.ListAiEnginesResp | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/training-job-engines" | |||
| 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 == l.svcCtx.Config.NanjingModelArtsType { | |||
| 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+"v2/"+in.ProjectId+"/training-job-engines", | |||
| nil) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| 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) | |||
| } | |||
| return &resp, nil | |||
| } | |||
| @@ -6,8 +6,12 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strconv" | |||
| "strings" | |||
| ) | |||
| @@ -32,20 +36,61 @@ 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 == l.svcCtx.Config.HaweiModelArtsType { | |||
| 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 == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/datasets?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-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 | |||
| } | |||
| @@ -10,7 +10,11 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strconv" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| @@ -38,23 +42,65 @@ func NewGetExportTasksOfDatasetLogic(ctx context.Context, svcCtx *svc.ServiceCon | |||
| func (l *GetExportTasksOfDatasetLogic) GetExportTasksOfDataset(in *modelarts.GetExportTasksOfDatasetReq) (*modelarts.GetExportTasksOfDatasetResp, error) { | |||
| var resp modelarts.GetExportTasksOfDatasetResp | |||
| limit := strconv.Itoa(int(in.Limit)) | |||
| offset := strconv.Itoa(int(in.Offset)) | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/" + in.ProjectId + "/datasets/" + in.DatasetId + "/export-tasks?limit=" + limit + "&offset=" + offset | |||
| token := common.GetToken() | |||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, url, nil, token) | |||
| if err != nil { | |||
| return nil, err | |||
| judgeLimit := strconv.Itoa(int(in.Limit)) | |||
| var limit string | |||
| if judgeLimit != "0" { | |||
| limit = strconv.Itoa(int(in.Limit)) | |||
| } else { | |||
| limit = "10" | |||
| } | |||
| if statusCode == 200 { | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/datasets/" + in.DatasetId + "/export-tasks?limit=" + limit + "&offset=" + offset | |||
| 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 != 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/datasets/"+in.DatasetId+"/export-tasks?limit="+limit+"&offset="+offset, | |||
| 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-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 != 202 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| return &resp, nil | |||
| } | |||
| @@ -9,7 +9,11 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| @@ -33,22 +37,58 @@ func NewGetExportTaskStatusOfDatasetLogic(ctx context.Context, svcCtx *svc.Servi | |||
| func (l *GetExportTaskStatusOfDatasetLogic) GetExportTaskStatusOfDataset(in *modelarts.GetExportTaskStatusOfDatasetReq) (*modelarts.GetExportTaskStatusOfDatasetResp, error) { | |||
| var resp modelarts.GetExportTaskStatusOfDatasetResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/" + in.ProjectId + "/datasets/" + in.ResourceId + "/export-tasks/" + in.TaskId | |||
| token := common.GetToken() | |||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, url, nil, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| if statusCode == 200 { | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/datasets/" + in.ResourceId + "/export-tasks/" + in.TaskId | |||
| token := common.GetToken() | |||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, url, nil, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 200 | |||
| resp.Msg = "Success" | |||
| } else if statusCode != 200 { | |||
| 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 == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/datasets/"+in.ResourceId+"/export-tasks/"+in.TaskId, | |||
| 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-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 = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| return &resp, nil | |||
| } | |||
| @@ -4,8 +4,12 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "log" | |||
| "net/http" | |||
| "strconv" | |||
| "strings" | |||
| @@ -32,22 +36,64 @@ func NewGetImportTaskListLogic(ctx context.Context, svcCtx *svc.ServiceContext) | |||
| // find taskList 查询数据集导入任务列表 | |||
| func (l *GetImportTaskListLogic) GetImportTaskList(in *modelarts.ListImportTasksReq) (*modelarts.ListImportTasksResp, error) { | |||
| var resp modelarts.ListImportTasksResp | |||
| limit := strconv.Itoa(int(in.Limit)) | |||
| judgeLimit := strconv.Itoa(int(in.Limit)) | |||
| offset := strconv.Itoa(int(in.Offset)) | |||
| token := common.GetToken() | |||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, "https://modelarts.cn-north-4.myhuaweicloud.com/v2/"+in.ProjectId+"/datasets/"+in.DatasetId+"/import-tasks?limit="+limit+"&offset="+offset, strings.NewReader(``), token) | |||
| if err != nil { | |||
| log.Fatal(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" | |||
| } else if statusCode != 200 { | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, modelArtsUrl+"v2/"+in.ProjectId+"/datasets/"+in.DatasetId+"/import-tasks?limit="+limit+"&offset="+offset, strings.NewReader(``), token) | |||
| if err != nil { | |||
| log.Fatal(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 == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/datasets/"+in.DatasetId+"/import-tasks?limit="+limit+"&offset="+offset, | |||
| 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-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 = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| return &resp, nil | |||
| } | |||
| @@ -6,7 +6,11 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "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 == l.svcCtx.Config.HaweiModelArtsType { | |||
| 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 == l.svcCtx.Config.NanjingModelArtsType { | |||
| 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 | |||
| } | |||
| @@ -5,6 +5,10 @@ import ( | |||
| "PCM/common/tool" | |||
| "context" | |||
| "encoding/json" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "net/http" | |||
| "strings" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| @@ -29,19 +33,50 @@ func NewGetNotebookStorageLogic(ctx context.Context, svcCtx *svc.ServiceContext) | |||
| func (l *GetNotebookStorageLogic) GetNotebookStorage(in *modelarts.GetNotebookStorageReq) (*modelarts.GetNotebookStorageResp, error) { | |||
| var resp modelarts.GetNotebookStorageResp | |||
| getObsUrl := "https://modelarts.cn-east-3.myhuaweicloud.com/v1/{project_id}/notebooks/{instance_id}/storage" | |||
| getObsUrl = strings.Replace(getObsUrl, "{project_id}", in.ProjectId, -1) | |||
| getObsUrl = strings.Replace(getObsUrl, "{instance_id}", in.InstanceId, -1) | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| getObsUrl := modelArtsUrl + "v1/{project_id}/notebooks/{instance_id}/storage" | |||
| getObsUrl = strings.Replace(getObsUrl, "{project_id}", in.ProjectId, -1) | |||
| getObsUrl = strings.Replace(getObsUrl, "{instance_id}", in.InstanceId, -1) | |||
| token := common.GetToken() | |||
| var e struct{} | |||
| token := common.GetToken() | |||
| //empty struct | |||
| var e struct{} | |||
| body, err := tool.HttpClientWithQueries(tool.GET, getObsUrl, nil, token, e) | |||
| if err != nil { | |||
| return nil, err | |||
| body, err := tool.HttpClientWithQueries(tool.GET, getObsUrl, nil, token, e) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/notebooks"+in.InstanceId+"/storage", | |||
| nil) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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) | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| return &resp, nil | |||
| } | |||
| @@ -0,0 +1,88 @@ | |||
| package logic | |||
| import ( | |||
| "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" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type GetTrainingJobFlavorsLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewGetTrainingJobFlavorsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTrainingJobFlavorsLogic { | |||
| return &GetTrainingJobFlavorsLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| // training-job-flavors 获取训练作业支持的公共规格 | |||
| func (l *GetTrainingJobFlavorsLogic) GetTrainingJobFlavors(in *modelarts.TrainingJobFlavorsReq) (*modelarts.TrainingJobFlavorsResp, error) { | |||
| // todo: add your logic here and delete this line | |||
| var resp modelarts.TrainingJobFlavorsResp | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/training-job-flavors?flavor_type=" + in.FlavorType | |||
| 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 == l.svcCtx.Config.NanjingModelArtsType { | |||
| 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+"v2/"+in.ProjectId+"/training-job-flavors?flavor_type="+in.FlavorType, | |||
| nil) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| 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) | |||
| } | |||
| return &resp, nil | |||
| } | |||
| @@ -5,6 +5,10 @@ import ( | |||
| "PCM/common/tool" | |||
| "context" | |||
| "encoding/json" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "net/http" | |||
| "strings" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| @@ -30,15 +34,50 @@ func NewGetVisualizationJobLogic(ctx context.Context, svcCtx *svc.ServiceContext | |||
| // visualization-jobs | |||
| func (l *GetVisualizationJobLogic) GetVisualizationJob(in *modelarts.GetVisualizationJobReq) (*modelarts.GetVisualizationJobResp, error) { | |||
| var resp modelarts.GetVisualizationJobResp | |||
| getVisualJobUrl := "https://modelarts.cn-east-3.myhuaweicloud.com/v1/{project_id}/visualization-jobs" | |||
| getVisualJobUrl = strings.Replace(getVisualJobUrl, "{project_id}", in.ProjectId, -1) | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| getVisualJobUrl := modelArtsUrl + "v1/{project_id}/visualization-jobs" | |||
| getVisualJobUrl = strings.Replace(getVisualJobUrl, "{project_id}", in.ProjectId, -1) | |||
| token := common.GetToken() | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClientWithQueries(tool.GET, getVisualJobUrl, nil, token, in.Param) | |||
| if err != nil { | |||
| return nil, err | |||
| body, err := tool.HttpClientWithQueries(tool.GET, getVisualJobUrl, nil, token, in.Param) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/visualization-jobs", | |||
| 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-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) | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| return &resp, nil | |||
| } | |||
| @@ -5,9 +5,14 @@ import ( | |||
| "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/JCCE-nudt/apigw-go-sdk/core" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strconv" | |||
| ) | |||
| @@ -36,20 +41,56 @@ 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 { | |||
| json.Unmarshal(body, &resp) | |||
| resp.Code = 200 | |||
| resp.Msg = "Success" | |||
| } else if statusCode != 200 { | |||
| modelArtsType := in.ModelArtsType | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "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 { | |||
| 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 == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v2/"+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-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 = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| return &resp, nil | |||
| } | |||
| @@ -9,7 +9,12 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strconv" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| @@ -34,17 +39,60 @@ func NewListClustersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *List | |||
| func (l *ListClustersLogic) ListClusters(in *modelarts.ListClustersReq) (*modelarts.ListClustersResp, error) { | |||
| // todo: add your logic here and delete this line | |||
| var resp modelarts.ListClustersResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/clusters" | |||
| token := common.GetToken() | |||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, url, nil, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| if statusCode == 200 { | |||
| json.Unmarshal(body, &resp.Resp200) | |||
| judgeLimit := strconv.Itoa(int(in.Limit)) | |||
| offset := strconv.Itoa(int(in.Offset)) | |||
| var limit string | |||
| if judgeLimit != "0" { | |||
| limit = strconv.Itoa(int(in.Limit)) | |||
| } else { | |||
| json.Unmarshal(body, &resp.Resp400) | |||
| limit = "10" | |||
| } | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/clusters?limit=" + limit + "&offset=" + offset | |||
| token := common.GetToken() | |||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, url, nil, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| if statusCode == 200 { | |||
| json.Unmarshal(body, &resp.Resp200) | |||
| } else { | |||
| json.Unmarshal(body, &resp.Resp400) | |||
| } | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/clusters?offset="+offset+"&"+"limit="+limit, | |||
| nil) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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) | |||
| } | |||
| return &resp, nil | |||
| } | |||
| @@ -8,8 +8,13 @@ package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "bytes" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| @@ -34,12 +39,50 @@ func NewListModelsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListMo | |||
| func (l *ListModelsLogic) ListModels(in *modelarts.ListModelReq) (*modelarts.ListModelResp, error) { | |||
| // todo: add your logic here and delete this line | |||
| var resp modelarts.ListModelResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/models" | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.GET, url, nil, token) | |||
| if err != nil { | |||
| return nil, err | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/models" | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.GET, url, nil, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| 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+"v1/"+in.ProjectId+"/models", | |||
| 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) | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| return &resp, nil | |||
| } | |||
| @@ -2,15 +2,16 @@ package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "encoding/json" | |||
| "strings" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| ) | |||
| type ListNotebookLogic struct { | |||
| @@ -29,16 +30,72 @@ func NewListNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *List | |||
| // notebook task | |||
| func (l *ListNotebookLogic) ListNotebook(in *modelarts.ListNotebookReq) (*modelarts.ListNotebookResp, error) { | |||
| var resp modelarts.ListNotebookResp | |||
| getUrl := "https://modelarts.cn-east-3.myhuaweicloud.com/v1/{project_id}/notebooks" | |||
| getUrl = strings.Replace(getUrl, "{project_id}", in.ProjectId, -1) | |||
| resp := &modelarts.ListNotebookResp{} | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| getUrl := modelArtsUrl + "v1/{project_id}/notebooks" | |||
| token := common.GetToken() | |||
| queryMap := tool.ConvertStructToMap(in.Param) | |||
| req := tool.GetACHttpRequest() | |||
| res, err := req. | |||
| SetHeader("x-auth-token", token). | |||
| SetPathParam("project_id", in.ProjectId). | |||
| SetQueryParams(queryMap). | |||
| SetResult(resp). | |||
| Get(getUrl) | |||
| token := common.GetToken() | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| body, err := tool.HttpClientWithQueries(tool.GET, getUrl, nil, token, in.Param) | |||
| if err != nil { | |||
| return nil, err | |||
| if res.StatusCode() != 200 { | |||
| resp.Code = int32(res.StatusCode()) | |||
| resp.Msg = "Failure" | |||
| var errMsg common.Error | |||
| err := json.Unmarshal(res.Body(), &errMsg) | |||
| if err != nil { | |||
| errMsg.ErrorMsg = "" | |||
| } | |||
| resp.ErrorMsg = errMsg.ErrorMsg | |||
| } else { | |||
| resp.Code = int32(res.StatusCode()) | |||
| resp.Msg = "Success" | |||
| } | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/notebooks", | |||
| nil) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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) | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| return &resp, nil | |||
| return resp, nil | |||
| } | |||
| @@ -10,9 +10,14 @@ import ( | |||
| "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/JCCE-nudt/apigw-go-sdk/core" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strconv" | |||
| ) | |||
| @@ -32,22 +37,63 @@ func NewListServicesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *List | |||
| func (l *ListServicesLogic) ListServices(in *modelarts.ListServicesReq) (*modelarts.ListServicesResp, error) { | |||
| var resp modelarts.ListServicesResp | |||
| 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/v1/" + in.ProjectId + "/services?limit=" + limit + "&offset=" + offset | |||
| token := common.GetToken() | |||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, url, nil, 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 == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/services?limit=" + limit + "&offset=" + offset | |||
| 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 == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/services?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-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 | |||
| } | |||
| @@ -5,10 +5,15 @@ import ( | |||
| "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/JCCE-nudt/apigw-go-sdk/core" | |||
| "github.com/bitly/go-simplejson" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strconv" | |||
| ) | |||
| @@ -31,14 +36,50 @@ func (l *ListTrainingJobConfigLogic) ListTrainingJobConfig(in *modelarts.ListTra | |||
| var resp modelarts.ListTrainingJobConfigResp | |||
| perPage := strconv.Itoa(int(in.PerPage)) | |||
| page := strconv.Itoa(int(in.Page)) | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/training-job-configs?" + perPage + "&" + page | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.GET, url, nil, token) | |||
| if err != nil { | |||
| return nil, err | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/training-job-configs?" + perPage + "&" + page | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.GET, url, nil, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| jsonResult, err := simplejson.NewJson(body) | |||
| println(&jsonResult) | |||
| json.Unmarshal(body, &resp) | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/training-job-configs?"+perPage+"&"+page, | |||
| 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-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) | |||
| } | |||
| jsonResult, err := simplejson.NewJson(body) | |||
| println(&jsonResult) | |||
| json.Unmarshal(body, &resp) | |||
| return &resp, nil | |||
| } | |||
| @@ -3,8 +3,13 @@ package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "bytes" | |||
| "context" | |||
| "encoding/json" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "net/http" | |||
| "strings" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| @@ -29,20 +34,54 @@ func NewMountNotebookStorageLogic(ctx context.Context, svcCtx *svc.ServiceContex | |||
| func (l *MountNotebookStorageLogic) MountNotebookStorage(in *modelarts.MountNotebookStorageReq) (*modelarts.MountNotebookStorageResp, error) { | |||
| var resp modelarts.MountNotebookStorageResp | |||
| mountUrl := "https://modelarts.cn-east-3.myhuaweicloud.com/v1/{project_id}/notebooks/{instance_id}/storage" | |||
| mountUrl = strings.Replace(mountUrl, "{project_id}", in.ProjectId, -1) | |||
| mountUrl = strings.Replace(mountUrl, "{instance_id}", in.InstanceId, -1) | |||
| reqByte, err := json.Marshal(in.Param) | |||
| if err != nil { | |||
| panic(err.Error()) | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.POST, mountUrl, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| mountUrl := modelArtsUrl + "v1/{project_id}/notebooks/{instance_id}/storage" | |||
| mountUrl = strings.Replace(mountUrl, "{project_id}", in.ProjectId, -1) | |||
| mountUrl = strings.Replace(mountUrl, "{instance_id}", in.InstanceId, -1) | |||
| reqByte, err := json.Marshal(in.Param) | |||
| if err != nil { | |||
| panic(err.Error()) | |||
| } | |||
| payload := strings.NewReader(string(reqByte)) | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.POST, mountUrl, payload, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| reqByte, err := json.Marshal(in) | |||
| r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/notebooks"+in.InstanceId+"/storage", | |||
| bytes.NewBuffer(reqByte)) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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) | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| return &resp, nil | |||
| } | |||
| @@ -3,8 +3,13 @@ package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "bytes" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| @@ -29,20 +34,58 @@ func NewShowAlgorithmByUuidLogic(ctx context.Context, svcCtx *svc.ServiceContext | |||
| // ShowAlgorithmByUuid 展示算法详情 | |||
| func (l *ShowAlgorithmByUuidLogic) ShowAlgorithmByUuid(in *modelarts.ShowAlgorithmByUuidReq) (*modelarts.ShowAlgorithmByUuidResp, error) { | |||
| var resp modelarts.ShowAlgorithmByUuidResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/" + in.ProjectId + "/algorithms/" + in.AlgorithmId | |||
| 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 { | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/algorithms/" + in.AlgorithmId | |||
| 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 == l.svcCtx.Config.NanjingModelArtsType { | |||
| 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+"v2/"+in.ProjectId+"/algorithms/"+in.AlgorithmId, | |||
| 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 = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| return &resp, nil | |||
| } | |||
| @@ -11,7 +11,11 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| @@ -33,12 +37,47 @@ func NewShowModelsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowMo | |||
| func (l *ShowModelsLogic) ShowModels(in *modelarts.ShowModelReq) (*modelarts.ShowModelResp, error) { | |||
| // todo: add your logic here and delete this line | |||
| var resp modelarts.ShowModelResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/models/" + in.ModelId | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.GET, url, nil, token) | |||
| if err != nil { | |||
| return nil, err | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/models/" + in.ModelId | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClient(tool.GET, url, nil, token) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/models/"+in.ModelId, | |||
| nil) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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) | |||
| } | |||
| json.Unmarshal(body, &resp) | |||
| return &resp, nil | |||
| } | |||
| @@ -11,7 +11,11 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| @@ -33,20 +37,55 @@ func NewShowServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowS | |||
| func (l *ShowServiceLogic) ShowService(in *modelarts.ShowServiceReq) (*modelarts.ShowServiceResp, error) { | |||
| // todo: add your logic here and delete this line | |||
| var resp modelarts.ShowServiceResp | |||
| url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/services/" + in.ServiceId | |||
| 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 { | |||
| //根据智算类型判断走华为智算还是南京智算 | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/services/" + in.ServiceId | |||
| 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 == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/services/"+in.ServiceId, | |||
| nil) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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 = 400 | |||
| resp.Msg = "Failure" | |||
| } | |||
| return &resp, nil | |||
| } | |||
| @@ -3,8 +3,13 @@ package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "bytes" | |||
| "context" | |||
| "encoding/json" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "net/http" | |||
| "strings" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| @@ -29,15 +34,49 @@ func NewStartNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Sta | |||
| func (l *StartNotebookLogic) StartNotebook(in *modelarts.StartNotebookReq) (*modelarts.StartNotebookResp, error) { | |||
| var resp modelarts.StartNotebookResp | |||
| startUrl := "https://modelarts.cn-east-3.myhuaweicloud.com/v1/{project_id}/notebooks/{id}/start" | |||
| startUrl = strings.Replace(startUrl, "{project_id}", in.ProjectId, -1) | |||
| startUrl = strings.Replace(startUrl, "{id}", in.Id, -1) | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClientWithQueries(tool.POST, startUrl, nil, token, in.Param) | |||
| if err != nil { | |||
| return nil, err | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| startUrl := modelArtsUrl + "v1/{project_id}/notebooks/{id}/start" | |||
| startUrl = strings.Replace(startUrl, "{project_id}", in.ProjectId, -1) | |||
| startUrl = strings.Replace(startUrl, "{id}", in.Id, -1) | |||
| token := common.GetToken() | |||
| body, err := tool.HttpClientWithQueries(tool.POST, startUrl, nil, token, in.Param) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp.NotebookResp) | |||
| } else if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| reqByte, err := json.Marshal(in) | |||
| r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/notebooks"+in.Id+"/start", | |||
| bytes.NewBuffer(reqByte)) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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) | |||
| } | |||
| json.Unmarshal(body, &resp.NotebookResp) | |||
| return &resp, nil | |||
| } | |||
| @@ -3,8 +3,13 @@ package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "bytes" | |||
| "context" | |||
| "encoding/json" | |||
| "fmt" | |||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||
| "io/ioutil" | |||
| "net/http" | |||
| "strings" | |||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||
| @@ -29,18 +34,50 @@ func NewStopNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Stop | |||
| func (l *StopNotebookLogic) StopNotebook(in *modelarts.StopNotebookReq) (*modelarts.StopNotebookResp, error) { | |||
| var resp modelarts.StopNotebookResp | |||
| stopUrl := "https://modelarts.cn-east-3.myhuaweicloud.com/v1/{project_id}/notebooks/{id}/stop" | |||
| stopUrl = strings.Replace(stopUrl, "{project_id}", in.ProjectId, -1) | |||
| stopUrl = strings.Replace(stopUrl, "{id}", in.Id, -1) | |||
| token := common.GetToken() | |||
| //empty struct | |||
| var e struct{} | |||
| body, err := tool.HttpClientWithQueries(tool.POST, stopUrl, nil, token, e) | |||
| if err != nil { | |||
| return nil, err | |||
| modelArtsType := in.ModelArtsType | |||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||
| stopUrl := modelArtsUrl + "v1/{project_id}/notebooks/{id}/stop" | |||
| stopUrl = strings.Replace(stopUrl, "{project_id}", in.ProjectId, -1) | |||
| stopUrl = strings.Replace(stopUrl, "{id}", in.Id, -1) | |||
| token := common.GetToken() | |||
| //empty struct | |||
| var e struct{} | |||
| body, err := tool.HttpClientWithQueries(tool.POST, stopUrl, nil, token, e) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Unmarshal(body, &resp.NotebookResp) | |||
| } else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||
| AK := l.svcCtx.Config.AK | |||
| SK := l.svcCtx.Config.SK | |||
| NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl | |||
| XProjectId := l.svcCtx.Config.XProjectId | |||
| s := core.Signer{ | |||
| Key: AK, | |||
| Secret: SK, | |||
| } | |||
| reqByte, err := json.Marshal(in) | |||
| r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/notebooks"+in.Id+"/stop", | |||
| bytes.NewBuffer(reqByte)) | |||
| if err != nil { | |||
| fmt.Println(err) | |||
| } | |||
| r.Header.Add("content-type", "application/json;charset=UTF-8") | |||
| r.Header.Add("X-Project-Id", XProjectId) | |||
| 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) | |||
| } | |||
| json.Unmarshal(body, &resp.NotebookResp) | |||
| return &resp, nil | |||
| } | |||
| @@ -118,6 +118,18 @@ func (s *ModelArtsServer) ShowAlgorithmByUuid(ctx context.Context, in *modelarts | |||
| return l.ShowAlgorithmByUuid(in) | |||
| } | |||
| // training-job-flavors 获取训练作业支持的公共规格 | |||
| func (s *ModelArtsServer) GetTrainingJobFlavors(ctx context.Context, in *modelarts.TrainingJobFlavorsReq) (*modelarts.TrainingJobFlavorsResp, error) { | |||
| l := logic.NewGetTrainingJobFlavorsLogic(ctx, s.svcCtx) | |||
| return l.GetTrainingJobFlavors(in) | |||
| } | |||
| // GET ai-engines 查询作业引擎规格 | |||
| func (s *ModelArtsServer) GetAiEnginesList(ctx context.Context, in *modelarts.ListAiEnginesReq) (*modelarts.ListAiEnginesResp, error) { | |||
| l := logic.NewGetAiEnginesListLogic(ctx, s.svcCtx) | |||
| return l.GetAiEnginesList(in) | |||
| } | |||
| // export task | |||
| func (s *ModelArtsServer) ExportTask(ctx context.Context, in *modelarts.ExportTaskReq) (*modelarts.ExportTaskDataResp, error) { | |||
| l := logic.NewExportTaskLogic(ctx, s.svcCtx) | |||
| @@ -35,6 +35,8 @@ const ( | |||
| ModelArts_ListAlgorithms_FullMethodName = "/modelarts.ModelArts/ListAlgorithms" | |||
| ModelArts_DeleteAlgorithms_FullMethodName = "/modelarts.ModelArts/DeleteAlgorithms" | |||
| ModelArts_ShowAlgorithmByUuid_FullMethodName = "/modelarts.ModelArts/ShowAlgorithmByUuid" | |||
| ModelArts_GetTrainingJobFlavors_FullMethodName = "/modelarts.ModelArts/GetTrainingJobFlavors" | |||
| ModelArts_GetAiEnginesList_FullMethodName = "/modelarts.ModelArts/GetAiEnginesList" | |||
| ModelArts_ExportTask_FullMethodName = "/modelarts.ModelArts/ExportTask" | |||
| ModelArts_GetExportTasksOfDataset_FullMethodName = "/modelarts.ModelArts/GetExportTasksOfDataset" | |||
| ModelArts_GetExportTaskStatusOfDataset_FullMethodName = "/modelarts.ModelArts/GetExportTaskStatusOfDataset" | |||
| @@ -95,6 +97,10 @@ type ModelArtsClient interface { | |||
| DeleteAlgorithms(ctx context.Context, in *DeleteAlgorithmsReq, opts ...grpc.CallOption) (*DeleteAlgorithmsResp, error) | |||
| // ShowAlgorithmByUuid 展示算法详情 | |||
| ShowAlgorithmByUuid(ctx context.Context, in *ShowAlgorithmByUuidReq, opts ...grpc.CallOption) (*ShowAlgorithmByUuidResp, error) | |||
| // training-job-flavors 获取训练作业支持的公共规格 | |||
| GetTrainingJobFlavors(ctx context.Context, in *TrainingJobFlavorsReq, opts ...grpc.CallOption) (*TrainingJobFlavorsResp, error) | |||
| // GET ai-engines 查询作业引擎规格 | |||
| GetAiEnginesList(ctx context.Context, in *ListAiEnginesReq, opts ...grpc.CallOption) (*ListAiEnginesResp, error) | |||
| //export task | |||
| ExportTask(ctx context.Context, in *ExportTaskReq, opts ...grpc.CallOption) (*ExportTaskDataResp, error) | |||
| GetExportTasksOfDataset(ctx context.Context, in *GetExportTasksOfDatasetReq, opts ...grpc.CallOption) (*GetExportTasksOfDatasetResp, error) | |||
| @@ -277,6 +283,24 @@ func (c *modelArtsClient) ShowAlgorithmByUuid(ctx context.Context, in *ShowAlgor | |||
| return out, nil | |||
| } | |||
| func (c *modelArtsClient) GetTrainingJobFlavors(ctx context.Context, in *TrainingJobFlavorsReq, opts ...grpc.CallOption) (*TrainingJobFlavorsResp, error) { | |||
| out := new(TrainingJobFlavorsResp) | |||
| err := c.cc.Invoke(ctx, ModelArts_GetTrainingJobFlavors_FullMethodName, in, out, opts...) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return out, nil | |||
| } | |||
| func (c *modelArtsClient) GetAiEnginesList(ctx context.Context, in *ListAiEnginesReq, opts ...grpc.CallOption) (*ListAiEnginesResp, error) { | |||
| out := new(ListAiEnginesResp) | |||
| err := c.cc.Invoke(ctx, ModelArts_GetAiEnginesList_FullMethodName, in, out, opts...) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return out, nil | |||
| } | |||
| func (c *modelArtsClient) ExportTask(ctx context.Context, in *ExportTaskReq, opts ...grpc.CallOption) (*ExportTaskDataResp, error) { | |||
| out := new(ExportTaskDataResp) | |||
| err := c.cc.Invoke(ctx, ModelArts_ExportTask_FullMethodName, in, out, opts...) | |||
| @@ -511,6 +535,10 @@ type ModelArtsServer interface { | |||
| DeleteAlgorithms(context.Context, *DeleteAlgorithmsReq) (*DeleteAlgorithmsResp, error) | |||
| // ShowAlgorithmByUuid 展示算法详情 | |||
| ShowAlgorithmByUuid(context.Context, *ShowAlgorithmByUuidReq) (*ShowAlgorithmByUuidResp, error) | |||
| // training-job-flavors 获取训练作业支持的公共规格 | |||
| GetTrainingJobFlavors(context.Context, *TrainingJobFlavorsReq) (*TrainingJobFlavorsResp, error) | |||
| // GET ai-engines 查询作业引擎规格 | |||
| GetAiEnginesList(context.Context, *ListAiEnginesReq) (*ListAiEnginesResp, error) | |||
| //export task | |||
| ExportTask(context.Context, *ExportTaskReq) (*ExportTaskDataResp, error) | |||
| GetExportTasksOfDataset(context.Context, *GetExportTasksOfDatasetReq) (*GetExportTasksOfDatasetResp, error) | |||
| @@ -594,6 +622,12 @@ func (UnimplementedModelArtsServer) DeleteAlgorithms(context.Context, *DeleteAlg | |||
| func (UnimplementedModelArtsServer) ShowAlgorithmByUuid(context.Context, *ShowAlgorithmByUuidReq) (*ShowAlgorithmByUuidResp, error) { | |||
| return nil, status.Errorf(codes.Unimplemented, "method ShowAlgorithmByUuid not implemented") | |||
| } | |||
| func (UnimplementedModelArtsServer) GetTrainingJobFlavors(context.Context, *TrainingJobFlavorsReq) (*TrainingJobFlavorsResp, error) { | |||
| return nil, status.Errorf(codes.Unimplemented, "method GetTrainingJobFlavors not implemented") | |||
| } | |||
| func (UnimplementedModelArtsServer) GetAiEnginesList(context.Context, *ListAiEnginesReq) (*ListAiEnginesResp, error) { | |||
| return nil, status.Errorf(codes.Unimplemented, "method GetAiEnginesList not implemented") | |||
| } | |||
| func (UnimplementedModelArtsServer) ExportTask(context.Context, *ExportTaskReq) (*ExportTaskDataResp, error) { | |||
| return nil, status.Errorf(codes.Unimplemented, "method ExportTask not implemented") | |||
| } | |||
| @@ -961,6 +995,42 @@ func _ModelArts_ShowAlgorithmByUuid_Handler(srv interface{}, ctx context.Context | |||
| return interceptor(ctx, in, info, handler) | |||
| } | |||
| func _ModelArts_GetTrainingJobFlavors_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | |||
| in := new(TrainingJobFlavorsReq) | |||
| if err := dec(in); err != nil { | |||
| return nil, err | |||
| } | |||
| if interceptor == nil { | |||
| return srv.(ModelArtsServer).GetTrainingJobFlavors(ctx, in) | |||
| } | |||
| info := &grpc.UnaryServerInfo{ | |||
| Server: srv, | |||
| FullMethod: ModelArts_GetTrainingJobFlavors_FullMethodName, | |||
| } | |||
| handler := func(ctx context.Context, req interface{}) (interface{}, error) { | |||
| return srv.(ModelArtsServer).GetTrainingJobFlavors(ctx, req.(*TrainingJobFlavorsReq)) | |||
| } | |||
| return interceptor(ctx, in, info, handler) | |||
| } | |||
| func _ModelArts_GetAiEnginesList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | |||
| in := new(ListAiEnginesReq) | |||
| if err := dec(in); err != nil { | |||
| return nil, err | |||
| } | |||
| if interceptor == nil { | |||
| return srv.(ModelArtsServer).GetAiEnginesList(ctx, in) | |||
| } | |||
| info := &grpc.UnaryServerInfo{ | |||
| Server: srv, | |||
| FullMethod: ModelArts_GetAiEnginesList_FullMethodName, | |||
| } | |||
| handler := func(ctx context.Context, req interface{}) (interface{}, error) { | |||
| return srv.(ModelArtsServer).GetAiEnginesList(ctx, req.(*ListAiEnginesReq)) | |||
| } | |||
| return interceptor(ctx, in, info, handler) | |||
| } | |||
| func _ModelArts_ExportTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | |||
| in := new(ExportTaskReq) | |||
| if err := dec(in); err != nil { | |||
| @@ -1428,6 +1498,14 @@ var ModelArts_ServiceDesc = grpc.ServiceDesc{ | |||
| MethodName: "ShowAlgorithmByUuid", | |||
| Handler: _ModelArts_ShowAlgorithmByUuid_Handler, | |||
| }, | |||
| { | |||
| MethodName: "GetTrainingJobFlavors", | |||
| Handler: _ModelArts_GetTrainingJobFlavors_Handler, | |||
| }, | |||
| { | |||
| MethodName: "GetAiEnginesList", | |||
| Handler: _ModelArts_GetAiEnginesList_Handler, | |||
| }, | |||
| { | |||
| MethodName: "ExportTask", | |||
| Handler: _ModelArts_ExportTask_Handler, | |||
| @@ -13,6 +13,7 @@ import ( | |||
| ) | |||
| type ( | |||
| ActionProgress = modelarts.ActionProgress | |||
| AdvancedConfigAl = modelarts.AdvancedConfigAl | |||
| AlgoConfigs = modelarts.AlgoConfigs | |||
| Algorithm = modelarts.Algorithm | |||
| @@ -35,6 +36,7 @@ type ( | |||
| ConstraintAlRq = modelarts.ConstraintAlRq | |||
| ConstraintCreateTraining = modelarts.ConstraintCreateTraining | |||
| ContainerHooks = modelarts.ContainerHooks | |||
| ContainerHooksResp = modelarts.ContainerHooksResp | |||
| Cpu = modelarts.Cpu | |||
| CreateAlgorithmReq = modelarts.CreateAlgorithmReq | |||
| CreateAlgorithmResp = modelarts.CreateAlgorithmResp | |||
| @@ -69,6 +71,7 @@ type ( | |||
| DataSources = modelarts.DataSources | |||
| DataVolumesRes = modelarts.DataVolumesRes | |||
| Dataset = modelarts.Dataset | |||
| DatasetTra = modelarts.DatasetTra | |||
| DeleteAlgorithmsReq = modelarts.DeleteAlgorithmsReq | |||
| DeleteAlgorithmsResp = modelarts.DeleteAlgorithmsResp | |||
| DeleteDataSetReq = modelarts.DeleteDataSetReq | |||
| @@ -113,6 +116,7 @@ type ( | |||
| GetVisualizationJobResp = modelarts.GetVisualizationJobResp | |||
| Gpu = modelarts.Gpu | |||
| GuideDoc = modelarts.GuideDoc | |||
| Hooks = modelarts.Hooks | |||
| I18NDescription = modelarts.I18NDescription | |||
| Identity = modelarts.Identity | |||
| Image = modelarts.Image | |||
| @@ -122,9 +126,11 @@ type ( | |||
| ImportTasks = modelarts.ImportTasks | |||
| Input = modelarts.Input | |||
| InputDataInfo = modelarts.InputDataInfo | |||
| InputTraining = modelarts.InputTraining | |||
| Inputs = modelarts.Inputs | |||
| InputsAlRp = modelarts.InputsAlRp | |||
| InputsAlRq = modelarts.InputsAlRq | |||
| Items = modelarts.Items | |||
| JobAlgorithmResponse = modelarts.JobAlgorithmResponse | |||
| JobConfigAl = modelarts.JobConfigAl | |||
| JobConfigAlRq = modelarts.JobConfigAlRq | |||
| @@ -134,6 +140,8 @@ type ( | |||
| Jobs = modelarts.Jobs | |||
| Lease = modelarts.Lease | |||
| LeaseReq = modelarts.LeaseReq | |||
| ListAiEnginesReq = modelarts.ListAiEnginesReq | |||
| ListAiEnginesResp = modelarts.ListAiEnginesResp | |||
| ListAlgorithmsReq = modelarts.ListAlgorithmsReq | |||
| ListAlgorithmsResp = modelarts.ListAlgorithmsResp | |||
| ListClustersReq = modelarts.ListClustersReq | |||
| @@ -176,8 +184,10 @@ type ( | |||
| Npu = modelarts.Npu | |||
| Obs = modelarts.Obs | |||
| Obs1 = modelarts.Obs1 | |||
| ObsTra = modelarts.ObsTra | |||
| OperatorParam = modelarts.OperatorParam | |||
| Output = modelarts.Output | |||
| OutputTraining = modelarts.OutputTraining | |||
| Outputs = modelarts.Outputs | |||
| OutputsAl = modelarts.OutputsAl | |||
| OutputsAlRp = modelarts.OutputsAlRp | |||
| @@ -191,12 +201,16 @@ type ( | |||
| Policies = modelarts.Policies | |||
| PoliciesCreateTraining = modelarts.PoliciesCreateTraining | |||
| Pool = modelarts.Pool | |||
| PostStart = modelarts.PostStart | |||
| PreStart = modelarts.PreStart | |||
| ProcessorDataSource = modelarts.ProcessorDataSource | |||
| Project = modelarts.Project | |||
| QueryServiceConfig = modelarts.QueryServiceConfig | |||
| Remote = modelarts.Remote | |||
| RemoteConstraint = modelarts.RemoteConstraint | |||
| RemoteConstraints = modelarts.RemoteConstraints | |||
| RemoteOut = modelarts.RemoteOut | |||
| RemoteTra = modelarts.RemoteTra | |||
| Resource = modelarts.Resource | |||
| ResourceCreateTraining = modelarts.ResourceCreateTraining | |||
| ResourceRequirements = modelarts.ResourceRequirements | |||
| @@ -229,6 +243,7 @@ type ( | |||
| Status = modelarts.Status | |||
| StopNotebookReq = modelarts.StopNotebookReq | |||
| StopNotebookResp = modelarts.StopNotebookResp | |||
| Tags = modelarts.Tags | |||
| TagsAlRp = modelarts.TagsAlRp | |||
| TaskResponse = modelarts.TaskResponse | |||
| TaskStatuses = modelarts.TaskStatuses | |||
| @@ -236,7 +251,11 @@ type ( | |||
| TemplateParam = modelarts.TemplateParam | |||
| TokenReq = modelarts.TokenReq | |||
| TokenResp = modelarts.TokenResp | |||
| TrainingJobFlavorsReq = modelarts.TrainingJobFlavorsReq | |||
| TrainingJobFlavorsResp = modelarts.TrainingJobFlavorsResp | |||
| User = modelarts.User | |||
| UserNotebookDomain = modelarts.UserNotebookDomain | |||
| UserNotebookResp = modelarts.UserNotebookResp | |||
| VolumeReq = modelarts.VolumeReq | |||
| VolumeRes = modelarts.VolumeRes | |||
| Volumes = modelarts.Volumes | |||
| @@ -276,6 +295,10 @@ type ( | |||
| DeleteAlgorithms(ctx context.Context, in *DeleteAlgorithmsReq, opts ...grpc.CallOption) (*DeleteAlgorithmsResp, error) | |||
| // ShowAlgorithmByUuid 展示算法详情 | |||
| ShowAlgorithmByUuid(ctx context.Context, in *ShowAlgorithmByUuidReq, opts ...grpc.CallOption) (*ShowAlgorithmByUuidResp, error) | |||
| // training-job-flavors 获取训练作业支持的公共规格 | |||
| GetTrainingJobFlavors(ctx context.Context, in *TrainingJobFlavorsReq, opts ...grpc.CallOption) (*TrainingJobFlavorsResp, error) | |||
| // GET ai-engines 查询作业引擎规格 | |||
| GetAiEnginesList(ctx context.Context, in *ListAiEnginesReq, opts ...grpc.CallOption) (*ListAiEnginesResp, error) | |||
| // export task | |||
| ExportTask(ctx context.Context, in *ExportTaskReq, opts ...grpc.CallOption) (*ExportTaskDataResp, error) | |||
| GetExportTasksOfDataset(ctx context.Context, in *GetExportTasksOfDatasetReq, opts ...grpc.CallOption) (*GetExportTasksOfDatasetResp, error) | |||
| @@ -413,6 +436,18 @@ func (m *defaultModelArts) ShowAlgorithmByUuid(ctx context.Context, in *ShowAlgo | |||
| return client.ShowAlgorithmByUuid(ctx, in, opts...) | |||
| } | |||
| // training-job-flavors 获取训练作业支持的公共规格 | |||
| func (m *defaultModelArts) GetTrainingJobFlavors(ctx context.Context, in *TrainingJobFlavorsReq, opts ...grpc.CallOption) (*TrainingJobFlavorsResp, error) { | |||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||
| return client.GetTrainingJobFlavors(ctx, in, opts...) | |||
| } | |||
| // GET ai-engines 查询作业引擎规格 | |||
| func (m *defaultModelArts) GetAiEnginesList(ctx context.Context, in *ListAiEnginesReq, opts ...grpc.CallOption) (*ListAiEnginesResp, error) { | |||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||
| return client.GetAiEnginesList(ctx, in, opts...) | |||
| } | |||
| // export task | |||
| func (m *defaultModelArts) ExportTask(ctx context.Context, in *ExportTaskReq, opts ...grpc.CallOption) (*ExportTaskDataResp, error) { | |||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||
| @@ -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{ | |||
| @@ -260,7 +264,6 @@ message JobAlgorithmResponse{ | |||
| repeated Environments environments=17;//@gotags: copier:"Environments" | |||
| } | |||
| message Environments{ | |||
| map<string,string> environments =1; | |||
| } | |||
| message TaskResponse{ | |||
| string role =1; | |||
| @@ -293,7 +296,7 @@ message cpu{ | |||
| int32 core_num =2; | |||
| } | |||
| message npu{ | |||
| string unit_num =1; | |||
| int32 unit_num =1; | |||
| string product_name =2; | |||
| string memory =3; | |||
| } | |||
| @@ -480,6 +483,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{ | |||
| @@ -506,10 +510,10 @@ message MetadataS { | |||
| } | |||
| message EngineCreateTraining { | |||
| string engine_id = 1; | |||
| string engine_name = 2; | |||
| string engine_version = 3; | |||
| string image_url =4; | |||
| string engine_id = 1; // @gotags: copier:"EngineId" | |||
| string engine_name = 2; // @gotags: copier:"EngineName" | |||
| string engine_version = 3; // @gotags: copier:"EngineVersion" | |||
| string image_url =4; // @gotags: copier:"ImageUrl" | |||
| } | |||
| message ConstraintCreateTraining { | |||
| @@ -522,9 +526,9 @@ message ConstraintCreateTraining { | |||
| message ParametersTrainJob { | |||
| string name = 1; // @gotags: copier:"Name" | |||
| string description = 2; // @gotags: copier:"Description" | |||
| string value = 3; // @gotags: copier:"Value" | |||
| ConstraintCreateTraining constraint = 4; // @gotags: copier:"ConstraintCreateTraining" | |||
| // string description = 2; // @gotags: copier:"Description" | |||
| string value = 2; // @gotags: copier:"Value" | |||
| // ConstraintCreateTraining constraint = 4; // @gotags: copier:"ConstraintCreateTraining" | |||
| } | |||
| message PoliciesCreateTraining { | |||
| @@ -539,11 +543,45 @@ message Algorithms { | |||
| repeated ParametersTrainJob parameters = 6;// @gotags: copier:"ParametersTrainJob" | |||
| PoliciesCreateTraining policies = 7;// @gotags: copier:"PoliciesCreateTraining" | |||
| string command =8; // @gotags: copier:"Command" | |||
| string subscription_id =9; // @gotags: copier:"SubscriptionId" | |||
| string item_version_id =10; // @gotags: copier:"ItemVersionId" | |||
| repeated InputTraining inputs =11; // @gotags: copier:"InputTra" | |||
| repeated OutputTraining outputs =12; // @gotags: copier:"OutputTra" | |||
| Environments environments =13; // @gotags: copier:"Environments" | |||
| } | |||
| message InputTraining{ | |||
| string name = 1; // @gotags: copier:"Name" | |||
| string access_method = 2; // @gotags: copier:"AccessMethod" | |||
| RemoteTra remote = 3; // @gotags: copier:"RemoteIn" | |||
| } | |||
| message OutputTraining{ | |||
| string name = 1; // @gotags: copier:"Name" | |||
| string access_method = 2; // @gotags: copier:"AccessMethod" | |||
| bool prefetch_to_local =3; // @gotags: copier:"PrefetchToLocal" | |||
| RemoteOut remote = 4; // @gotags: copier:"RemoteOut" | |||
| } | |||
| message RemoteTra{ | |||
| DatasetTra dataset =1; // @gotags: copier:"DatasetIn" | |||
| } | |||
| message RemoteOut{ | |||
| ObsTra obs =1; // @gotags: copier:"Obs" | |||
| } | |||
| message ObsTra{ | |||
| string obs_url =1; // @gotags: copier:"ObsUrl" | |||
| } | |||
| message DatasetTra{ | |||
| string id = 1; // @gotags: copier:"Id" | |||
| string name = 2; // @gotags: copier:"Name" | |||
| string version_name = 3; // @gotags: copier:"VersionName" | |||
| string version_id = 4; // @gotags: copier:"VersionId" | |||
| } | |||
| message ResourceCreateTraining { | |||
| string flavor_id = 1; // @gotags: copier:"FlavorId" | |||
| int32 node_count = 2; // @gotags: copier:"NodeCount" | |||
| string policy = 3; // @gotags: copier:"Policy" | |||
| string flavor_label = 4; // @gotags: copier:"FlavorLabel" | |||
| } | |||
| message LogExportPathCreateTraining { | |||
| @@ -572,6 +610,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 +630,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,11 +644,14 @@ message DeleteTrainingJobResp{ | |||
| message DeleteTrainingJobConfigReq{ | |||
| string project_id =1; | |||
| string config_name=2; | |||
| string modelArtsType =3; // @gotags: copier:"ModelArtsType" | |||
| } | |||
| message DeleteTrainingJobConfigResp{ | |||
| bool is_success =1; | |||
| string error_message =2; | |||
| string error_code =3; | |||
| int32 code =4; //@gotags: copier:"Code" | |||
| string msg =5; //@gotags: copier:"Msg" | |||
| } | |||
| /******************DeleteTrainingJobConfig end*************************/ | |||
| @@ -623,6 +666,7 @@ message ListTrainingJobConfigReq{ | |||
| string order =5; | |||
| string search_content =6; | |||
| string config_type =7; | |||
| string modelArtsType =8; // @gotags: copier:"ModelArtsType" | |||
| } | |||
| message ListTrainingJobConfigResp{ | |||
| @@ -654,6 +698,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 +888,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 +930,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 +944,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{ | |||
| @@ -911,6 +959,53 @@ message ShowAlgorithmByUuidResp{ | |||
| /******************Show Algorithm By Uuid end*************************/ | |||
| /******************TrainingJobFlavors start*************************/ | |||
| message TrainingJobFlavorsReq{ | |||
| string project_id =1; // @gotags: copier:"ProjectId" | |||
| string flavor_type =2; // @gotags: copier:"FlavorType" | |||
| string modelArtsType =3; // @gotags: copier:"ModelArtsType" | |||
| } | |||
| message TrainingJobFlavorsResp{ | |||
| int32 total_count = 1; // @gotags: copier:"TotalCount" | |||
| repeated FlavorResponse flavors = 2; // @gotags: copier:"FlavorResponse" | |||
| string msg =3;// @gotags: copier:"Msg" | |||
| int32 code =4;// @gotags: copier:"Code" | |||
| } | |||
| /******************TrainingJobFlavors end*************************/ | |||
| /******************ListAiEngines start*************************/ | |||
| message ListAiEnginesReq{ | |||
| string project_id =1; // @gotags: copier:"ProjectId" | |||
| string modelArtsType =2; // @gotags: copier:"ModelArtsType" | |||
| } | |||
| message ListAiEnginesResp{ | |||
| int32 total = 1; // @gotags: copier:"total" | |||
| repeated Items items =2; // @gotags: copier:"items" | |||
| string msg =3;// @gotags: copier:"Msg" | |||
| int32 code =4;// @gotags: copier:"Code" | |||
| } | |||
| message Items{ | |||
| string engine_id =1; // @gotags: copier:"EngineId" | |||
| string engine_name =2; // @gotags: copier:"EngineName" | |||
| string engine_version =3; // @gotags: copier:"EngineVersion" | |||
| bool v1_compatible =4; // @gotags: copier:"V1Compatible" | |||
| string run_user =5; // @gotags: copier:"RunUser" | |||
| ImageInfo image_info =6; // @gotags: copier:"ImageInfo" | |||
| bool image_source =7; // @gotags: copier:"imageSource" | |||
| repeated Tags tags =8; // @gotags: copier:"Tags" | |||
| } | |||
| message Tags{ | |||
| string key = 1; | |||
| string value = 2; | |||
| } | |||
| /******************ListAiEngines end*************************/ | |||
| /******************Task(export) Start*************************/ | |||
| message ExportTaskReq{ | |||
| string annotation_format = 1; // @gotags: copier:"AnnotationFormat" | |||
| @@ -927,7 +1022,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 +1107,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 +1157,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 +1196,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 +1242,7 @@ message OperatorParam { | |||
| message DescribeProcessorTaskReq{ | |||
| string project_id = 1; | |||
| string task_id = 2; | |||
| string modelArtsType =4; // @gotags: copier:"ModelArtsType" | |||
| } | |||
| message DescribeProcessorTaskResp{ | |||
| @@ -1196,7 +1294,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,12 +1360,14 @@ message DeleteModelReq{ | |||
| string project_id = 1; | |||
| string model_id = 2; | |||
| bool cascade = 3; | |||
| string modelArtsType =4; // @gotags: copier:"ModelArtsType" | |||
| } | |||
| message DeleteModelResp{ | |||
| int32 code = 1; // @gotags: copier:"Code" | |||
| repeated string delete_success_list = 2; | |||
| repeated DeleteModelResponseFailedList delete_failed_list = 3; | |||
| string msg =4; // @gotags: copier:"Msg" | |||
| } | |||
| message DeleteModelResponseFailedList{ | |||
| @@ -1290,6 +1390,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 +1437,7 @@ message ModelSpecification{ | |||
| message ShowModelReq{ | |||
| string project_id = 1; | |||
| string model_id = 2; | |||
| string modelArtsType =3; // @gotags: copier:"ModelArtsType" | |||
| } | |||
| message ShowModelResp{ | |||
| @@ -1411,7 +1513,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 +1561,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 +1577,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 +1650,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 +1698,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 +1746,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,214 +1758,285 @@ 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{ | |||
| int32 code =1; //@gotags: copier:"Code" | |||
| string msg =2; //@gotags: copier:"Msg" | |||
| string error_msg =3;// @gotags: copier:"ErrorMsg" | |||
| } | |||
| /******************create dataset end*************************/ | |||
| /******************Notebook Start*************************/ | |||
| message ListNotebookReq{ | |||
| string project_id = 1; // @gotags: copier:"project_id" | |||
| ListNotebookParam param = 2; // @gotags: copier:"param" | |||
| 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" | |||
| repeated NotebookResp data = 2; // @gotags: copier:"data" | |||
| int32 pages = 3; // @gotags: copier:"pages" | |||
| int32 size = 4; // @gotags: copier:"size" | |||
| int64 total = 5; // @gotags: copier:"total" | |||
| int32 current = 1; // @gotags: copier:"Current" | |||
| repeated NotebookResp data = 2; // @gotags: copier:"Data" | |||
| int32 pages = 3; // @gotags: copier:"Pages" | |||
| int32 size = 4; // @gotags: copier:"Size" | |||
| int64 total = 5; // @gotags: copier:"Total" | |||
| int32 code = 6; // @gotags: copier:"Code" | |||
| string msg = 7; // @gotags: copier:"Msg" | |||
| string error_msg =8;// @gotags: copier:"ErrorMsg" | |||
| } | |||
| message ListNotebookParam{ | |||
| string feature = 1; // @gotags: copier:"feature" | |||
| int32 limit = 2; // @gotags: copier:"limit" | |||
| string name = 3; // @gotags: copier:"name" | |||
| string pool_id = 4; // @gotags: copier:"pool_id" | |||
| int32 offset = 5; // @gotags: copier:"offset" | |||
| string owner = 6; // @gotags: copier:"owner" | |||
| string sort_dir = 7; // @gotags: copier:"sort_dir" | |||
| string sort_key = 8; // @gotags: copier:"sort_key" | |||
| string status = 9; // @gotags: copier:"status" | |||
| string workspaceId = 10; // @gotags: copier:"workspaceId" | |||
| string feature = 1; // @gotags: copier:"Feature" | |||
| int32 limit = 2; // @gotags: copier:"Limit" | |||
| string name = 3; // @gotags: copier:"Name" | |||
| string pool_id = 4; // @gotags: copier:"PoolId" | |||
| int32 offset = 5; // @gotags: copier:"Offset" | |||
| string owner = 6; // @gotags: copier:"Owner" | |||
| string sort_dir = 7; // @gotags: copier:"SortDir" | |||
| string sort_key = 8; // @gotags: copier:"SortKey" | |||
| string status = 9; // @gotags: copier:"Status" | |||
| string workspaceId = 10; // @gotags: copier:"WorkspaceId" | |||
| } | |||
| message CreateNotebookReq{ | |||
| string project_id = 1; // @gotags: copier:"project_id" | |||
| CreateNotebookParam param = 2; // @gotags: copier:"param" | |||
| 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" | |||
| NotebookResp notebookResp = 1; // @gotags: copier:"NotebookResp" | |||
| int32 code = 2; // @gotags: copier:"Code" | |||
| string msg = 3; // @gotags: copier:"Msg" | |||
| string error_msg =4;// @gotags: copier:"ErrorMsg" | |||
| } | |||
| message CreateNotebookParam{ | |||
| string description = 1; // @gotags: copier:"description" | |||
| int64 duration = 2; // @gotags: copier:"duration" | |||
| repeated EndpointsReq endpoints = 3; // @gotags: copier:"endpoints" | |||
| string feature = 4; // @gotags: copier:"feature" | |||
| string flavor = 5; // @gotags: copier:"flavor" | |||
| string image_id = 6; // @gotags: copier:"image_id" | |||
| string name = 7; // @gotags: copier:"name" | |||
| string pool_id = 8; // @gotags: copier:"pool_id" | |||
| VolumeReq volume = 9; // @gotags: copier:"volume" | |||
| string workspace_id = 10; // @gotags: copier:"workspace_id" | |||
| CustomHooks hooks = 11; // @gotags: copier:"hooks" | |||
| LeaseReq lease = 12; // @gotags: copier:"lease" | |||
| string description = 1; // @gotags: copier:"Description" | |||
| int64 duration = 2; // @gotags: copier:"Duration" | |||
| repeated EndpointsReq endpoints = 3; // @gotags: copier:"Endpoints" | |||
| string feature = 4; // @gotags: copier:"Feature" | |||
| string flavor = 5; // @gotags: copier:"Flavor" | |||
| string image_id = 6; // @gotags: copier:"ImageId" | |||
| string name = 7; // @gotags: copier:"Name" | |||
| string pool_id = 8; // @gotags: copier:"PoolId" | |||
| VolumeReq volume = 9; // @gotags: copier:"Volume" | |||
| string workspace_id = 10; // @gotags: copier:"WorkspaceId" | |||
| CustomHooks hooks = 11; // @gotags: copier:"Hooks" | |||
| LeaseReq lease = 12; // @gotags: copier:"Lease" | |||
| } | |||
| message StartNotebookReq{ | |||
| string id = 1; // @gotags: copier:"id" | |||
| string project_id = 2; // @gotags: copier:"project_id" | |||
| StartNotebookParam param = 3; // @gotags: copier:"param" | |||
| 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{ | |||
| NotebookResp notebookResp = 1; // @gotags: copier:"notebookResp" | |||
| NotebookResp notebookResp = 1; // @gotags: copier:"NotebookResp" | |||
| int32 code = 2; // @gotags: copier:"Code" | |||
| string msg = 3; // @gotags: copier:"Msg" | |||
| string error_msg =4;// @gotags: copier:"ErrorMsg" | |||
| } | |||
| message StartNotebookParam{ | |||
| int64 duration = 1; // @gotags: copier:"duration" | |||
| string type = 2; // @gotags: copier:"type_start_notebook" | |||
| int64 duration = 1; // @gotags: copier:"Duration" | |||
| string type = 2; // @gotags: copier:"TypeStartNotebook" | |||
| } | |||
| message StopNotebookReq{ | |||
| string id = 1; // @gotags: copier:"id" | |||
| string project_id = 2; // @gotags: copier:"project_id" | |||
| 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" | |||
| NotebookResp notebookResp = 1; // @gotags: copier:"NotebookResp" | |||
| int32 code = 2; // @gotags: copier:"Code" | |||
| string msg = 3; // @gotags: copier:"Msg" | |||
| string error_msg =4;// @gotags: copier:"ErrorMsg" | |||
| } | |||
| message GetNotebookStorageReq{ | |||
| string instance_id = 1; // @gotags: copier:"instance_id" | |||
| string project_id = 2; // @gotags: copier:"project_id" | |||
| 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" | |||
| repeated DataVolumesRes data = 2; // @gotags: copier:"data" | |||
| int32 pages = 3; // @gotags: copier:"pages" | |||
| int32 size = 4; // @gotags: copier:"size" | |||
| int64 total = 5; // @gotags: copier:"total" | |||
| int32 current = 1; // @gotags: copier:"Current" | |||
| repeated DataVolumesRes data = 2; // @gotags: copier:"Data" | |||
| int32 pages = 3; // @gotags: copier:"Pages" | |||
| int32 size = 4; // @gotags: copier:"Size" | |||
| int64 total = 5; // @gotags: copier:"Total" | |||
| } | |||
| message MountNotebookStorageReq{ | |||
| string instance_id = 1; // @gotags: copier:"instance_id" | |||
| string project_id = 2; // @gotags: copier:"project_id" | |||
| MountNotebookStorageParam param = 3; // @gotags: copier:"param" | |||
| 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" | |||
| string id = 2; // @gotags: copier:"id" | |||
| string mount_path = 3; // @gotags: copier:"mount_path" | |||
| string status = 4; // @gotags: copier:"status" | |||
| string uri = 5; // @gotags: copier:"uri" | |||
| string category = 1; // @gotags: copier:"Category" | |||
| string id = 2; // @gotags: copier:"Id" | |||
| string mount_path = 3; // @gotags: copier:"MountPath" | |||
| string status = 4; // @gotags: copier:"Status" | |||
| string uri = 5; // @gotags: copier:"Uri" | |||
| } | |||
| message MountNotebookStorageParam{ | |||
| string category = 1; // @gotags: copier:"category" | |||
| string mount_path = 2; // @gotags: copier:"mount_path" | |||
| string uri = 3; // @gotags: copier:"uri" | |||
| string category = 1; // @gotags: copier:"Category" | |||
| string mount_path = 2; // @gotags: copier:"MountPath" | |||
| string uri = 3; // @gotags: copier:"Uri" | |||
| } | |||
| message DataVolumesRes{ | |||
| string category = 1; // @gotags: copier:"category" | |||
| string id = 2; // @gotags: copier:"id" | |||
| string mount_path = 3; // @gotags: copier:"mount_path" | |||
| string status = 4; // @gotags: copier:"status" | |||
| string uri = 5; // @gotags: copier:"uri" | |||
| string category = 1; // @gotags: copier:"Category" | |||
| string id = 2; // @gotags: copier:"Id" | |||
| string mount_path = 3; // @gotags: copier:"MountPath" | |||
| string status = 4; // @gotags: copier:"Status" | |||
| string uri = 5; // @gotags: copier:"Uri" | |||
| } | |||
| message NotebookResp{ | |||
| repeated JobProgress action_progress = 1; // @gotags: copier:"action_progress" | |||
| string description = 2; // @gotags: copier:"description" | |||
| repeated EndpointsRes endpoints = 3; // @gotags: copier:"endpoints" | |||
| string fail_reason = 4; // @gotags: copier:"fail_reason" | |||
| string flavor = 5; // @gotags: copier:"flavor" | |||
| string id = 6; // @gotags: copier:"id" | |||
| Image image = 7; // @gotags: copier:"image" | |||
| Lease lease = 8; // @gotags: copier:"lease" | |||
| string name = 9; // @gotags: copier:"name" | |||
| Pool pool = 10; // @gotags: copier:"pool" | |||
| string status = 11; // @gotags: copier:"status" | |||
| string token = 12; // @gotags: copier:"token" | |||
| string url = 13; // @gotags: copier:"url" | |||
| VolumeRes volume = 14; // @gotags: copier:"volume" | |||
| string workspace_id = 15; // @gotags: copier:"workspace_id" | |||
| string feature = 16; // @gotags: copier:"feature" | |||
| repeated ActionProgress action_progress = 1; // @gotags: copier:"ActionProgress" | |||
| string description = 2; // @gotags: copier:"Description" | |||
| repeated EndpointsRes endpoints = 3; // @gotags: copier:"Endpoints" | |||
| string fail_reason = 4; // @gotags: copier:"FailReason" | |||
| string flavor = 5; // @gotags: copier:"Flavor" | |||
| string id = 6; // @gotags: copier:"Id" | |||
| Image image = 7; // @gotags: copier:"Image" | |||
| Lease lease = 8; // @gotags: copier:"Lease" | |||
| string name = 9; // @gotags: copier:"Name" | |||
| Pool pool = 10; // @gotags: copier:"Pool" | |||
| string status = 11; // @gotags: copier:"Status" | |||
| string token = 12; // @gotags: copier:"Token" | |||
| string url = 13; // @gotags: copier:"Url" | |||
| VolumeRes volume = 14; // @gotags: copier:"Volume" | |||
| string workspace_id = 15; // @gotags: copier:"WorkspaceId" | |||
| string feature = 16; // @gotags: copier:"Feature" | |||
| int64 create_at = 17; // @gotags: copier:"CreateAt" * | |||
| Hooks hooks = 18; // @gotags: copier:"Hooks" * | |||
| repeated string tags = 19; // @gotags: copier:"Tags" * | |||
| int64 update_at = 20; // @gotags: copier:"UpdateAt" * | |||
| UserNotebookResp user = 21; // @gotags: copier:"UserNotebookResp" * | |||
| string user_id = 22; // @gotags: copier:"UserId" * | |||
| repeated string billing_items = 23; // @gotags: copier:"BillingItems" * | |||
| } | |||
| message UserNotebookResp{ | |||
| UserNotebookDomain domain = 1; // @gotags: copier:"UserNotebookDomain" * | |||
| string id = 2; // @gotags: copier:"Id" * | |||
| string name = 3; // @gotags: copier:"Name" * | |||
| } | |||
| message UserNotebookDomain{ | |||
| string id = 1; // @gotags: copier:"Id" * | |||
| string name = 2; // @gotags: copier:"Name" * | |||
| } | |||
| message Hooks { | |||
| ContainerHooksResp containerHooks =1; // @gotags: copier:"ContainerHooksResp" * | |||
| } | |||
| message ContainerHooksResp{ | |||
| PostStart postStart=1; // @gotags: copier:"PostStart" * | |||
| PreStart preStart=2; // @gotags: copier:"PreStart" * | |||
| } | |||
| message PostStart{ | |||
| string mode=1; // @gotags: copier:"Mode" * | |||
| string script=2; // @gotags: copier:"Script" * | |||
| string type=3; // @gotags: copier:"Type" * | |||
| } | |||
| message PreStart{ | |||
| string mode=1; // @gotags: copier:"Mode" * | |||
| string script=2; // @gotags: copier:"Script" * | |||
| string type=3; // @gotags: copier:"Type" * | |||
| } | |||
| message ActionProgress{ | |||
| int32 step = 1; // @gotags: copier:"Step" * | |||
| string status = 2; // @gotags: copier:"Status" * | |||
| string description = 3; // @gotags: copier:"Description" * | |||
| } | |||
| message JobProgress{ | |||
| string notebook_id = 1; // @gotags: copier:"notebook_id" | |||
| string status = 2; // @gotags: copier:"status" | |||
| int32 step = 3; // @gotags: copier:"step" | |||
| string step_description = 4; // @gotags: copier:"step_description" | |||
| string notebook_id = 1; // @gotags: copier:"NotebookId" | |||
| string status = 2; // @gotags: copier:"Status" | |||
| int32 step = 3; // @gotags: copier:"Step" | |||
| string step_description = 4; // @gotags: copier:"StepDescription" | |||
| } | |||
| message EndpointsRes{ | |||
| repeated string allowed_access_ips = 1; // @gotags: copier:"allowed_access_ips" | |||
| string dev_service = 2; // @gotags: copier:"dev_service" | |||
| repeated string ssh_keys = 3; // @gotags: copier:"ssh_keys" | |||
| repeated string allowed_access_ips = 1; // @gotags: copier:"AllowedAccessIps" | |||
| string dev_service = 2; // @gotags: copier:"DevService" | |||
| repeated string ssh_keys = 3; // @gotags: copier:"SshKeys" | |||
| } | |||
| message Image{ | |||
| string arch = 1; // @gotags: copier:"arch" | |||
| int64 create_at = 2; // @gotags: copier:"create_at" | |||
| string description = 3; // @gotags: copier:"description" | |||
| repeated string dev_services = 4; // @gotags: copier:"dev_services" | |||
| string id = 5; // @gotags: copier:"id" | |||
| string name = 6; // @gotags: copier:"name" | |||
| string namespace = 7; // @gotags: copier:"namespace" | |||
| string origin = 8; // @gotags: copier:"origin" | |||
| repeated string resource_categories = 9; // @gotags: copier:"resource_categories" | |||
| string service_type = 10; // @gotags: copier:"service_type" | |||
| int64 size = 11; // @gotags: copier:"size" | |||
| string status = 12; // @gotags: copier:"status" | |||
| string status_message = 13; // @gotags: copier:"status_message" | |||
| repeated string support_res_categories = 14; // @gotags: copier:"support_res_categories" | |||
| string swr_path = 15; // @gotags: copier:"swr_path" | |||
| string tag = 16; // @gotags: copier:"tag" | |||
| string type = 17; // @gotags: copier:"type_image" | |||
| int64 update_at = 18; // @gotags: copier:"update_at" | |||
| string visibility = 19; // @gotags: copier:"visibility" | |||
| string workspace_id = 20; // @gotags: copier:"workspace_id" | |||
| string arch = 1; // @gotags: copier:"Arch" | |||
| int64 create_at = 2; // @gotags: copier:"CreateAt" | |||
| string description = 3; // @gotags: copier:"Description" | |||
| repeated string dev_services = 4; // @gotags: copier:"DevServices" | |||
| string id = 5; // @gotags: copier:"Id" | |||
| string name = 6; // @gotags: copier:"Name" | |||
| string namespace = 7; // @gotags: copier:"Namespace" | |||
| string origin = 8; // @gotags: copier:"Origin" | |||
| repeated string resource_categories = 9; // @gotags: copier:"ResourceCategories" | |||
| string service_type = 10; // @gotags: copier:"ServiceType" | |||
| int64 size = 11; // @gotags: copier:"Size" | |||
| string status = 12; // @gotags: copier:"Status" | |||
| string status_message = 13; // @gotags: copier:"StatusMessage" | |||
| repeated string support_res_categories = 14; // @gotags: copier:"SupportResCategories" | |||
| string swr_path = 15; // @gotags: copier:"SwrPath" | |||
| string tag = 16; // @gotags: copier:"Tag" | |||
| string type = 17; // @gotags: copier:"TypeImage" | |||
| int64 update_at = 18; // @gotags: copier:"UpdateAt" | |||
| string visibility = 19; // @gotags: copier:"Visibility" | |||
| string workspace_id = 20; // @gotags: copier:"WorkspaceId" | |||
| } | |||
| message Lease{ | |||
| int64 create_at = 1; // @gotags: copier:"create_at" | |||
| int64 duration = 2; // @gotags: copier:"duration" | |||
| bool enable = 3; // @gotags: copier:"enable" | |||
| string type = 4; // @gotags: copier:"type_lease" | |||
| int64 update_at = 5; // @gotags: copier:"update_at" | |||
| int64 create_at = 1; // @gotags: copier:"CreateAt" | |||
| int64 duration = 2; // @gotags: copier:"Duration" | |||
| bool enable = 3; // @gotags: copier:"Enable" | |||
| string type = 4; // @gotags: copier:"TypeLease" | |||
| int64 update_at = 5; // @gotags: copier:"UpdateAt" | |||
| } | |||
| message Pool{ | |||
| string id = 1; // @gotags: copier:"id" | |||
| string name = 2; // @gotags: copier:"name" | |||
| string id = 1; // @gotags: copier:"Id" | |||
| string name = 2; // @gotags: copier:"Name" | |||
| } | |||
| message VolumeRes{ | |||
| int64 capacity = 1; // @gotags: copier:"capacity" | |||
| string category = 2; // @gotags: copier:"category" | |||
| string mount_path = 3; // @gotags: copier:"mount_path" | |||
| string ownership = 4; // @gotags: copier:"ownership" | |||
| string status = 5; // @gotags: copier:"status" | |||
| int64 capacity = 1; // @gotags: copier:"Capacity" | |||
| string category = 2; // @gotags: copier:"Category" | |||
| string mount_path = 3; // @gotags: copier:"MountPath" | |||
| string ownership = 4; // @gotags: copier:"Ownership" | |||
| string status = 5; // @gotags: copier:"Status" | |||
| } | |||
| message EndpointsReq{ | |||
| repeated string allowed_access_ips = 1; // @gotags: copier:"allowed_access_ips" | |||
| string dev_service = 2; // @gotags: copier:"dev_service" | |||
| repeated string ssh_keys = 3; // @gotags: copier:"ssh_keys" | |||
| repeated string allowed_access_ips = 1; // @gotags: copier:"AllowedAccessIps" | |||
| string dev_service = 2; // @gotags: copier:"DevService" | |||
| repeated string ssh_keys = 3; // @gotags: copier:"SshKeys" | |||
| } | |||
| message VolumeReq{ | |||
| int64 capacity = 1; // @gotags: copier:"capacity" | |||
| string category = 2; // @gotags: copier:"category" | |||
| string ownership = 3; // @gotags: copier:"ownership" | |||
| string uri = 4; // @gotags: copier:"uri" | |||
| int64 capacity = 1; // @gotags: copier:"Capacity" | |||
| string category = 2; // @gotags: copier:"Category" | |||
| string ownership = 3; // @gotags: copier:"Ownership" | |||
| string uri = 4; // @gotags: copier:"Uri" | |||
| } | |||
| message CustomHooks{ | |||
| ContainerHooks container_hooks = 1; // @gotags: copier:"container_hooks" | |||
| ContainerHooks container_hooks = 1; // @gotags: copier:"ContainerHooks" | |||
| } | |||
| message ContainerHooks{ | |||
| Config post_start = 1; // @gotags: copier:"post_start" | |||
| Config pre_start = 2; // @gotags: copier:"pre_start" | |||
| Config post_start = 1; // @gotags: copier:"PostStart" | |||
| Config pre_start = 2; // @gotags: copier:"PreStart" | |||
| } | |||
| message Config{ | |||
| string script = 1; // @gotags: copier:"script" | |||
| string type = 2; // @gotags: copier:"type_config" | |||
| string script = 1; // @gotags: copier:"Script" | |||
| string type = 2; // @gotags: copier:"TypeConfig" | |||
| } | |||
| message LeaseReq{ | |||
| int64 duration = 1; // @gotags: copier:"duration" | |||
| string type = 2; // @gotags: copier:"type_lease_req" | |||
| int64 duration = 1; // @gotags: copier:"Duration" | |||
| string type = 2; // @gotags: copier:"TypeLeaseReq" | |||
| } | |||
| /******************Notebook End*************************/ | |||
| @@ -1867,6 +2045,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" | |||
| @@ -1900,6 +2079,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" | |||
| @@ -1965,7 +2145,10 @@ service ModelArts { | |||
| rpc DeleteAlgorithms(DeleteAlgorithmsReq) returns (DeleteAlgorithmsResp); | |||
| // ShowAlgorithmByUuid 展示算法详情 | |||
| rpc ShowAlgorithmByUuid(ShowAlgorithmByUuidReq) returns (ShowAlgorithmByUuidResp); | |||
| // training-job-flavors 获取训练作业支持的公共规格 | |||
| rpc GetTrainingJobFlavors(TrainingJobFlavorsReq) returns (TrainingJobFlavorsResp); | |||
| // GET ai-engines 查询作业引擎规格 | |||
| rpc GetAiEnginesList(ListAiEnginesReq) returns (ListAiEnginesResp); | |||
| //export task | |||
| rpc ExportTask(ExportTaskReq) returns (ExportTaskDataResp); | |||
| @@ -1999,4 +2182,6 @@ service ModelArts { | |||
| //visualization-jobs | |||
| rpc GetVisualizationJob(GetVisualizationJobReq) returns (GetVisualizationJobResp); | |||
| rpc CreateVisualizationJob(CreateVisualizationJobReq) returns (CreateVisualizationJobResp); | |||
| } | |||
| @@ -0,0 +1,53 @@ | |||
| // Code generated by goctl. DO NOT EDIT. | |||
| // Source: pcm-ms.proto | |||
| package agentservice | |||
| import ( | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/ms" | |||
| "github.com/zeromicro/go-zero/zrpc" | |||
| "google.golang.org/grpc" | |||
| ) | |||
| type ( | |||
| ClusterReRegisterMessageProto = ms.ClusterReRegisterMessageProto | |||
| ClusterRegisterAckMessageProto = ms.ClusterRegisterAckMessageProto | |||
| ClusterStateChangeMessageProto = ms.ClusterStateChangeMessageProto | |||
| MessageProducerProto = ms.MessageProducerProto | |||
| MessageResponseProto = ms.MessageResponseProto | |||
| StringStringMapProto = ms.StringStringMapProto | |||
| AgentService interface { | |||
| RequireReRegister(ctx context.Context, in *ClusterReRegisterMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) | |||
| RegisterAck(ctx context.Context, in *ClusterRegisterAckMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) | |||
| ChangeClusterState(ctx context.Context, in *ClusterStateChangeMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) | |||
| } | |||
| defaultAgentService struct { | |||
| cli zrpc.Client | |||
| } | |||
| ) | |||
| func NewAgentService(cli zrpc.Client) AgentService { | |||
| return &defaultAgentService{ | |||
| cli: cli, | |||
| } | |||
| } | |||
| func (m *defaultAgentService) RequireReRegister(ctx context.Context, in *ClusterReRegisterMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) { | |||
| client := ms.NewAgentServiceClient(m.cli.Conn()) | |||
| return client.RequireReRegister(ctx, in, opts...) | |||
| } | |||
| func (m *defaultAgentService) RegisterAck(ctx context.Context, in *ClusterRegisterAckMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) { | |||
| client := ms.NewAgentServiceClient(m.cli.Conn()) | |||
| return client.RegisterAck(ctx, in, opts...) | |||
| } | |||
| func (m *defaultAgentService) ChangeClusterState(ctx context.Context, in *ClusterStateChangeMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) { | |||
| client := ms.NewAgentServiceClient(m.cli.Conn()) | |||
| return client.ChangeClusterState(ctx, in, opts...) | |||
| } | |||
| @@ -0,0 +1,6 @@ | |||
| Name: pcmms.rpc | |||
| ListenOn: 0.0.0.0:8080 | |||
| Etcd: | |||
| Hosts: | |||
| - 127.0.0.1:2379 | |||
| Key: pcmms.rpc | |||
| @@ -0,0 +1,30 @@ | |||
| package logic | |||
| import ( | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/ms" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type ChangeClusterStateLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewChangeClusterStateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ChangeClusterStateLogic { | |||
| return &ChangeClusterStateLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *ChangeClusterStateLogic) ChangeClusterState(in *ms.ClusterStateChangeMessageProto) (*ms.MessageResponseProto, error) { | |||
| // todo: add your logic here and delete this line | |||
| return &ms.MessageResponseProto{}, nil | |||
| } | |||
| @@ -0,0 +1,30 @@ | |||
| package logic | |||
| import ( | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/ms" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type RegisterAckLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewRegisterAckLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisterAckLogic { | |||
| return &RegisterAckLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *RegisterAckLogic) RegisterAck(in *ms.ClusterRegisterAckMessageProto) (*ms.MessageResponseProto, error) { | |||
| // todo: add your logic here and delete this line | |||
| return &ms.MessageResponseProto{}, nil | |||
| } | |||
| @@ -0,0 +1,30 @@ | |||
| package logic | |||
| import ( | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/ms" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type RequireReRegisterLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewRequireReRegisterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RequireReRegisterLogic { | |||
| return &RequireReRegisterLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *RequireReRegisterLogic) RequireReRegister(in *ms.ClusterReRegisterMessageProto) (*ms.MessageResponseProto, error) { | |||
| // todo: add your logic here and delete this line | |||
| return &ms.MessageResponseProto{}, nil | |||
| } | |||
| @@ -0,0 +1,38 @@ | |||
| // Code generated by goctl. DO NOT EDIT. | |||
| // Source: pcm-ms.proto | |||
| package server | |||
| import ( | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/internal/logic" | |||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/ms" | |||
| ) | |||
| type AgentServiceServer struct { | |||
| svcCtx *svc.ServiceContext | |||
| ms.UnimplementedAgentServiceServer | |||
| } | |||
| func NewAgentServiceServer(svcCtx *svc.ServiceContext) *AgentServiceServer { | |||
| return &AgentServiceServer{ | |||
| svcCtx: svcCtx, | |||
| } | |||
| } | |||
| func (s *AgentServiceServer) RequireReRegister(ctx context.Context, in *ms.ClusterReRegisterMessageProto) (*ms.MessageResponseProto, error) { | |||
| l := logic.NewRequireReRegisterLogic(ctx, s.svcCtx) | |||
| return l.RequireReRegister(in) | |||
| } | |||
| func (s *AgentServiceServer) RegisterAck(ctx context.Context, in *ms.ClusterRegisterAckMessageProto) (*ms.MessageResponseProto, error) { | |||
| l := logic.NewRegisterAckLogic(ctx, s.svcCtx) | |||
| return l.RegisterAck(in) | |||
| } | |||
| func (s *AgentServiceServer) ChangeClusterState(ctx context.Context, in *ms.ClusterStateChangeMessageProto) (*ms.MessageResponseProto, error) { | |||
| l := logic.NewChangeClusterStateLogic(ctx, s.svcCtx) | |||
| return l.ChangeClusterState(in) | |||
| } | |||
| @@ -1,6 +1,6 @@ | |||
| package svc | |||
| import "PCM/adaptor/PCM-AI/PCM-HANWUJI/rpc/internal/config" | |||
| import "PCM/adaptor/PCM-AI/PCM-MS/rpc/internal/config" | |||
| type ServiceContext struct { | |||
| Config config.Config | |||
| @@ -0,0 +1,613 @@ | |||
| // Code generated by protoc-gen-go. DO NOT EDIT. | |||
| // versions: | |||
| // protoc-gen-go v1.28.1 | |||
| // protoc v3.19.4 | |||
| // source: pcm-ms.proto | |||
| package ms | |||
| 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 MessageStatus int32 | |||
| const ( | |||
| MessageStatus_FAIL MessageStatus = 0 | |||
| MessageStatus_SUCCESS MessageStatus = 1 | |||
| MessageStatus_UNKNOWN MessageStatus = 2 | |||
| ) | |||
| // Enum value maps for MessageStatus. | |||
| var ( | |||
| MessageStatus_name = map[int32]string{ | |||
| 0: "FAIL", | |||
| 1: "SUCCESS", | |||
| 2: "UNKNOWN", | |||
| } | |||
| MessageStatus_value = map[string]int32{ | |||
| "FAIL": 0, | |||
| "SUCCESS": 1, | |||
| "UNKNOWN": 2, | |||
| } | |||
| ) | |||
| func (x MessageStatus) Enum() *MessageStatus { | |||
| p := new(MessageStatus) | |||
| *p = x | |||
| return p | |||
| } | |||
| func (x MessageStatus) String() string { | |||
| return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) | |||
| } | |||
| func (MessageStatus) Descriptor() protoreflect.EnumDescriptor { | |||
| return file_pcm_ms_proto_enumTypes[0].Descriptor() | |||
| } | |||
| func (MessageStatus) Type() protoreflect.EnumType { | |||
| return &file_pcm_ms_proto_enumTypes[0] | |||
| } | |||
| func (x MessageStatus) Number() protoreflect.EnumNumber { | |||
| return protoreflect.EnumNumber(x) | |||
| } | |||
| // Deprecated: Use MessageStatus.Descriptor instead. | |||
| func (MessageStatus) EnumDescriptor() ([]byte, []int) { | |||
| return file_pcm_ms_proto_rawDescGZIP(), []int{0} | |||
| } | |||
| type ClusterReRegisterMessageProto struct { | |||
| state protoimpl.MessageState | |||
| sizeCache protoimpl.SizeCache | |||
| unknownFields protoimpl.UnknownFields | |||
| MsgProducer *MessageProducerProto `protobuf:"bytes,1,opt,name=msg_producer,json=msgProducer,proto3" json:"msg_producer,omitempty"` | |||
| } | |||
| func (x *ClusterReRegisterMessageProto) Reset() { | |||
| *x = ClusterReRegisterMessageProto{} | |||
| if protoimpl.UnsafeEnabled { | |||
| mi := &file_pcm_ms_proto_msgTypes[0] | |||
| ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |||
| ms.StoreMessageInfo(mi) | |||
| } | |||
| } | |||
| func (x *ClusterReRegisterMessageProto) String() string { | |||
| return protoimpl.X.MessageStringOf(x) | |||
| } | |||
| func (*ClusterReRegisterMessageProto) ProtoMessage() {} | |||
| func (x *ClusterReRegisterMessageProto) ProtoReflect() protoreflect.Message { | |||
| mi := &file_pcm_ms_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 ClusterReRegisterMessageProto.ProtoReflect.Descriptor instead. | |||
| func (*ClusterReRegisterMessageProto) Descriptor() ([]byte, []int) { | |||
| return file_pcm_ms_proto_rawDescGZIP(), []int{0} | |||
| } | |||
| func (x *ClusterReRegisterMessageProto) GetMsgProducer() *MessageProducerProto { | |||
| if x != nil { | |||
| return x.MsgProducer | |||
| } | |||
| return nil | |||
| } | |||
| type MessageProducerProto struct { | |||
| state protoimpl.MessageState | |||
| sizeCache protoimpl.SizeCache | |||
| unknownFields protoimpl.UnknownFields | |||
| MsNetId string `protobuf:"bytes,1,opt,name=ms_net_id,json=msNetId,proto3" json:"ms_net_id,omitempty"` | |||
| ClusterId string `protobuf:"bytes,2,opt,name=cluster_id,json=clusterId,proto3" json:"cluster_id,omitempty"` | |||
| AgentServiceHost string `protobuf:"bytes,3,opt,name=agent_service_host,json=agentServiceHost,proto3" json:"agent_service_host,omitempty"` | |||
| AgentServicePort int32 `protobuf:"varint,4,opt,name=agent_service_port,json=agentServicePort,proto3" json:"agent_service_port,omitempty"` | |||
| } | |||
| func (x *MessageProducerProto) Reset() { | |||
| *x = MessageProducerProto{} | |||
| if protoimpl.UnsafeEnabled { | |||
| mi := &file_pcm_ms_proto_msgTypes[1] | |||
| ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |||
| ms.StoreMessageInfo(mi) | |||
| } | |||
| } | |||
| func (x *MessageProducerProto) String() string { | |||
| return protoimpl.X.MessageStringOf(x) | |||
| } | |||
| func (*MessageProducerProto) ProtoMessage() {} | |||
| func (x *MessageProducerProto) ProtoReflect() protoreflect.Message { | |||
| mi := &file_pcm_ms_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 MessageProducerProto.ProtoReflect.Descriptor instead. | |||
| func (*MessageProducerProto) Descriptor() ([]byte, []int) { | |||
| return file_pcm_ms_proto_rawDescGZIP(), []int{1} | |||
| } | |||
| func (x *MessageProducerProto) GetMsNetId() string { | |||
| if x != nil { | |||
| return x.MsNetId | |||
| } | |||
| return "" | |||
| } | |||
| func (x *MessageProducerProto) GetClusterId() string { | |||
| if x != nil { | |||
| return x.ClusterId | |||
| } | |||
| return "" | |||
| } | |||
| func (x *MessageProducerProto) GetAgentServiceHost() string { | |||
| if x != nil { | |||
| return x.AgentServiceHost | |||
| } | |||
| return "" | |||
| } | |||
| func (x *MessageProducerProto) GetAgentServicePort() int32 { | |||
| if x != nil { | |||
| return x.AgentServicePort | |||
| } | |||
| return 0 | |||
| } | |||
| type ClusterRegisterAckMessageProto struct { | |||
| state protoimpl.MessageState | |||
| sizeCache protoimpl.SizeCache | |||
| unknownFields protoimpl.UnknownFields | |||
| MsgProducer *MessageProducerProto `protobuf:"bytes,1,opt,name=msg_producer,json=msgProducer,proto3" json:"msg_producer,omitempty"` | |||
| Configs []*StringStringMapProto `protobuf:"bytes,3,rep,name=configs,proto3" json:"configs,omitempty"` | |||
| } | |||
| func (x *ClusterRegisterAckMessageProto) Reset() { | |||
| *x = ClusterRegisterAckMessageProto{} | |||
| if protoimpl.UnsafeEnabled { | |||
| mi := &file_pcm_ms_proto_msgTypes[2] | |||
| ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |||
| ms.StoreMessageInfo(mi) | |||
| } | |||
| } | |||
| func (x *ClusterRegisterAckMessageProto) String() string { | |||
| return protoimpl.X.MessageStringOf(x) | |||
| } | |||
| func (*ClusterRegisterAckMessageProto) ProtoMessage() {} | |||
| func (x *ClusterRegisterAckMessageProto) ProtoReflect() protoreflect.Message { | |||
| mi := &file_pcm_ms_proto_msgTypes[2] | |||
| 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 ClusterRegisterAckMessageProto.ProtoReflect.Descriptor instead. | |||
| func (*ClusterRegisterAckMessageProto) Descriptor() ([]byte, []int) { | |||
| return file_pcm_ms_proto_rawDescGZIP(), []int{2} | |||
| } | |||
| func (x *ClusterRegisterAckMessageProto) GetMsgProducer() *MessageProducerProto { | |||
| if x != nil { | |||
| return x.MsgProducer | |||
| } | |||
| return nil | |||
| } | |||
| func (x *ClusterRegisterAckMessageProto) GetConfigs() []*StringStringMapProto { | |||
| if x != nil { | |||
| return x.Configs | |||
| } | |||
| return nil | |||
| } | |||
| type StringStringMapProto struct { | |||
| state protoimpl.MessageState | |||
| sizeCache protoimpl.SizeCache | |||
| unknownFields protoimpl.UnknownFields | |||
| Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` | |||
| Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` | |||
| } | |||
| func (x *StringStringMapProto) Reset() { | |||
| *x = StringStringMapProto{} | |||
| if protoimpl.UnsafeEnabled { | |||
| mi := &file_pcm_ms_proto_msgTypes[3] | |||
| ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |||
| ms.StoreMessageInfo(mi) | |||
| } | |||
| } | |||
| func (x *StringStringMapProto) String() string { | |||
| return protoimpl.X.MessageStringOf(x) | |||
| } | |||
| func (*StringStringMapProto) ProtoMessage() {} | |||
| func (x *StringStringMapProto) ProtoReflect() protoreflect.Message { | |||
| mi := &file_pcm_ms_proto_msgTypes[3] | |||
| 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 StringStringMapProto.ProtoReflect.Descriptor instead. | |||
| func (*StringStringMapProto) Descriptor() ([]byte, []int) { | |||
| return file_pcm_ms_proto_rawDescGZIP(), []int{3} | |||
| } | |||
| func (x *StringStringMapProto) GetKey() string { | |||
| if x != nil { | |||
| return x.Key | |||
| } | |||
| return "" | |||
| } | |||
| func (x *StringStringMapProto) GetValue() string { | |||
| if x != nil { | |||
| return x.Value | |||
| } | |||
| return "" | |||
| } | |||
| type ClusterStateChangeMessageProto struct { | |||
| state protoimpl.MessageState | |||
| sizeCache protoimpl.SizeCache | |||
| unknownFields protoimpl.UnknownFields | |||
| MsgProducer *MessageProducerProto `protobuf:"bytes,1,opt,name=msg_producer,json=msgProducer,proto3" json:"msg_producer,omitempty"` | |||
| ClusterState int32 `protobuf:"varint,2,opt,name=cluster_state,json=clusterState,proto3" json:"cluster_state,omitempty"` | |||
| } | |||
| func (x *ClusterStateChangeMessageProto) Reset() { | |||
| *x = ClusterStateChangeMessageProto{} | |||
| if protoimpl.UnsafeEnabled { | |||
| mi := &file_pcm_ms_proto_msgTypes[4] | |||
| ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |||
| ms.StoreMessageInfo(mi) | |||
| } | |||
| } | |||
| func (x *ClusterStateChangeMessageProto) String() string { | |||
| return protoimpl.X.MessageStringOf(x) | |||
| } | |||
| func (*ClusterStateChangeMessageProto) ProtoMessage() {} | |||
| func (x *ClusterStateChangeMessageProto) ProtoReflect() protoreflect.Message { | |||
| mi := &file_pcm_ms_proto_msgTypes[4] | |||
| 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 ClusterStateChangeMessageProto.ProtoReflect.Descriptor instead. | |||
| func (*ClusterStateChangeMessageProto) Descriptor() ([]byte, []int) { | |||
| return file_pcm_ms_proto_rawDescGZIP(), []int{4} | |||
| } | |||
| func (x *ClusterStateChangeMessageProto) GetMsgProducer() *MessageProducerProto { | |||
| if x != nil { | |||
| return x.MsgProducer | |||
| } | |||
| return nil | |||
| } | |||
| func (x *ClusterStateChangeMessageProto) GetClusterState() int32 { | |||
| if x != nil { | |||
| return x.ClusterState | |||
| } | |||
| return 0 | |||
| } | |||
| type MessageResponseProto struct { | |||
| state protoimpl.MessageState | |||
| sizeCache protoimpl.SizeCache | |||
| unknownFields protoimpl.UnknownFields | |||
| MessageStatus MessageStatus `protobuf:"varint,1,opt,name=message_status,json=messageStatus,proto3,enum=ms.MessageStatus" json:"message_status,omitempty"` | |||
| } | |||
| func (x *MessageResponseProto) Reset() { | |||
| *x = MessageResponseProto{} | |||
| if protoimpl.UnsafeEnabled { | |||
| mi := &file_pcm_ms_proto_msgTypes[5] | |||
| ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |||
| ms.StoreMessageInfo(mi) | |||
| } | |||
| } | |||
| func (x *MessageResponseProto) String() string { | |||
| return protoimpl.X.MessageStringOf(x) | |||
| } | |||
| func (*MessageResponseProto) ProtoMessage() {} | |||
| func (x *MessageResponseProto) ProtoReflect() protoreflect.Message { | |||
| mi := &file_pcm_ms_proto_msgTypes[5] | |||
| 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 MessageResponseProto.ProtoReflect.Descriptor instead. | |||
| func (*MessageResponseProto) Descriptor() ([]byte, []int) { | |||
| return file_pcm_ms_proto_rawDescGZIP(), []int{5} | |||
| } | |||
| func (x *MessageResponseProto) GetMessageStatus() MessageStatus { | |||
| if x != nil { | |||
| return x.MessageStatus | |||
| } | |||
| return MessageStatus_FAIL | |||
| } | |||
| var File_pcm_ms_proto protoreflect.FileDescriptor | |||
| var file_pcm_ms_proto_rawDesc = []byte{ | |||
| 0x0a, 0x0c, 0x70, 0x63, 0x6d, 0x2d, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, | |||
| 0x6d, 0x73, 0x22, 0x5c, 0x0a, 0x1d, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x52, | |||
| 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x72, | |||
| 0x6f, 0x74, 0x6f, 0x12, 0x3b, 0x0a, 0x0c, 0x6d, 0x73, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x64, 0x75, | |||
| 0x63, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6d, 0x73, 0x2e, 0x4d, | |||
| 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x72, 0x50, 0x72, | |||
| 0x6f, 0x74, 0x6f, 0x52, 0x0b, 0x6d, 0x73, 0x67, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x72, | |||
| 0x22, 0xad, 0x01, 0x0a, 0x14, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x64, | |||
| 0x75, 0x63, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1a, 0x0a, 0x09, 0x6d, 0x73, 0x5f, | |||
| 0x6e, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x73, | |||
| 0x4e, 0x65, 0x74, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, | |||
| 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, | |||
| 0x65, 0x72, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x65, | |||
| 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, | |||
| 0x52, 0x10, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x48, 0x6f, | |||
| 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x65, 0x72, 0x76, | |||
| 0x69, 0x63, 0x65, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, | |||
| 0x61, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, | |||
| 0x22, 0x91, 0x01, 0x0a, 0x1e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, | |||
| 0x73, 0x74, 0x65, 0x72, 0x41, 0x63, 0x6b, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x72, | |||
| 0x6f, 0x74, 0x6f, 0x12, 0x3b, 0x0a, 0x0c, 0x6d, 0x73, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x64, 0x75, | |||
| 0x63, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6d, 0x73, 0x2e, 0x4d, | |||
| 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x72, 0x50, 0x72, | |||
| 0x6f, 0x74, 0x6f, 0x52, 0x0b, 0x6d, 0x73, 0x67, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x72, | |||
| 0x12, 0x32, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, | |||
| 0x0b, 0x32, 0x18, 0x2e, 0x6d, 0x73, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, | |||
| 0x69, 0x6e, 0x67, 0x4d, 0x61, 0x70, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x52, 0x07, 0x63, 0x6f, 0x6e, | |||
| 0x66, 0x69, 0x67, 0x73, 0x22, 0x3e, 0x0a, 0x14, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x53, 0x74, | |||
| 0x72, 0x69, 0x6e, 0x67, 0x4d, 0x61, 0x70, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x0a, 0x03, | |||
| 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, | |||
| 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, | |||
| 0x61, 0x6c, 0x75, 0x65, 0x22, 0x82, 0x01, 0x0a, 0x1e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, | |||
| 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, | |||
| 0x67, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x3b, 0x0a, 0x0c, 0x6d, 0x73, 0x67, 0x5f, 0x70, | |||
| 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, | |||
| 0x6d, 0x73, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, | |||
| 0x65, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x52, 0x0b, 0x6d, 0x73, 0x67, 0x50, 0x72, 0x6f, 0x64, | |||
| 0x75, 0x63, 0x65, 0x72, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x5f, | |||
| 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x63, 0x6c, 0x75, | |||
| 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x22, 0x50, 0x0a, 0x14, 0x4d, 0x65, 0x73, | |||
| 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x74, | |||
| 0x6f, 0x12, 0x38, 0x0a, 0x0e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x74, 0x61, | |||
| 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x6d, 0x73, 0x2e, 0x4d, | |||
| 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0d, 0x6d, 0x65, | |||
| 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, 0x33, 0x0a, 0x0d, 0x4d, | |||
| 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x08, 0x0a, 0x04, | |||
| 0x46, 0x41, 0x49, 0x4c, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, | |||
| 0x53, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x02, | |||
| 0x32, 0x87, 0x02, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, | |||
| 0x65, 0x12, 0x52, 0x0a, 0x11, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x52, 0x65, 0x52, 0x65, | |||
| 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x21, 0x2e, 0x6d, 0x73, 0x2e, 0x43, 0x6c, 0x75, 0x73, | |||
| 0x74, 0x65, 0x72, 0x52, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x65, 0x73, | |||
| 0x73, 0x61, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x2e, 0x6d, 0x73, 0x2e, 0x4d, | |||
| 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x50, 0x72, | |||
| 0x6f, 0x74, 0x6f, 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x0b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, | |||
| 0x72, 0x41, 0x63, 0x6b, 0x12, 0x22, 0x2e, 0x6d, 0x73, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, | |||
| 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x41, 0x63, 0x6b, 0x4d, 0x65, 0x73, 0x73, | |||
| 0x61, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x2e, 0x6d, 0x73, 0x2e, 0x4d, 0x65, | |||
| 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x50, 0x72, 0x6f, | |||
| 0x74, 0x6f, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x12, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6c, | |||
| 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x22, 0x2e, 0x6d, 0x73, 0x2e, | |||
| 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, | |||
| 0x67, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, | |||
| 0x2e, 0x6d, 0x73, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, | |||
| 0x6e, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x00, 0x42, 0x05, 0x5a, 0x03, 0x2f, 0x6d, | |||
| 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, | |||
| } | |||
| var ( | |||
| file_pcm_ms_proto_rawDescOnce sync.Once | |||
| file_pcm_ms_proto_rawDescData = file_pcm_ms_proto_rawDesc | |||
| ) | |||
| func file_pcm_ms_proto_rawDescGZIP() []byte { | |||
| file_pcm_ms_proto_rawDescOnce.Do(func() { | |||
| file_pcm_ms_proto_rawDescData = protoimpl.X.CompressGZIP(file_pcm_ms_proto_rawDescData) | |||
| }) | |||
| return file_pcm_ms_proto_rawDescData | |||
| } | |||
| var file_pcm_ms_proto_enumTypes = make([]protoimpl.EnumInfo, 1) | |||
| var file_pcm_ms_proto_msgTypes = make([]protoimpl.MessageInfo, 6) | |||
| var file_pcm_ms_proto_goTypes = []interface{}{ | |||
| (MessageStatus)(0), // 0: ms.MessageStatus | |||
| (*ClusterReRegisterMessageProto)(nil), // 1: ms.ClusterReRegisterMessageProto | |||
| (*MessageProducerProto)(nil), // 2: ms.MessageProducerProto | |||
| (*ClusterRegisterAckMessageProto)(nil), // 3: ms.ClusterRegisterAckMessageProto | |||
| (*StringStringMapProto)(nil), // 4: ms.StringStringMapProto | |||
| (*ClusterStateChangeMessageProto)(nil), // 5: ms.ClusterStateChangeMessageProto | |||
| (*MessageResponseProto)(nil), // 6: ms.MessageResponseProto | |||
| } | |||
| var file_pcm_ms_proto_depIdxs = []int32{ | |||
| 2, // 0: ms.ClusterReRegisterMessageProto.msg_producer:type_name -> ms.MessageProducerProto | |||
| 2, // 1: ms.ClusterRegisterAckMessageProto.msg_producer:type_name -> ms.MessageProducerProto | |||
| 4, // 2: ms.ClusterRegisterAckMessageProto.configs:type_name -> ms.StringStringMapProto | |||
| 2, // 3: ms.ClusterStateChangeMessageProto.msg_producer:type_name -> ms.MessageProducerProto | |||
| 0, // 4: ms.MessageResponseProto.message_status:type_name -> ms.MessageStatus | |||
| 1, // 5: ms.AgentService.requireReRegister:input_type -> ms.ClusterReRegisterMessageProto | |||
| 3, // 6: ms.AgentService.registerAck:input_type -> ms.ClusterRegisterAckMessageProto | |||
| 5, // 7: ms.AgentService.changeClusterState:input_type -> ms.ClusterStateChangeMessageProto | |||
| 6, // 8: ms.AgentService.requireReRegister:output_type -> ms.MessageResponseProto | |||
| 6, // 9: ms.AgentService.registerAck:output_type -> ms.MessageResponseProto | |||
| 6, // 10: ms.AgentService.changeClusterState:output_type -> ms.MessageResponseProto | |||
| 8, // [8:11] is the sub-list for method output_type | |||
| 5, // [5:8] is the sub-list for method input_type | |||
| 5, // [5:5] is the sub-list for extension type_name | |||
| 5, // [5:5] is the sub-list for extension extendee | |||
| 0, // [0:5] is the sub-list for field type_name | |||
| } | |||
| func init() { file_pcm_ms_proto_init() } | |||
| func file_pcm_ms_proto_init() { | |||
| if File_pcm_ms_proto != nil { | |||
| return | |||
| } | |||
| if !protoimpl.UnsafeEnabled { | |||
| file_pcm_ms_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { | |||
| switch v := v.(*ClusterReRegisterMessageProto); i { | |||
| case 0: | |||
| return &v.state | |||
| case 1: | |||
| return &v.sizeCache | |||
| case 2: | |||
| return &v.unknownFields | |||
| default: | |||
| return nil | |||
| } | |||
| } | |||
| file_pcm_ms_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { | |||
| switch v := v.(*MessageProducerProto); i { | |||
| case 0: | |||
| return &v.state | |||
| case 1: | |||
| return &v.sizeCache | |||
| case 2: | |||
| return &v.unknownFields | |||
| default: | |||
| return nil | |||
| } | |||
| } | |||
| file_pcm_ms_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { | |||
| switch v := v.(*ClusterRegisterAckMessageProto); i { | |||
| case 0: | |||
| return &v.state | |||
| case 1: | |||
| return &v.sizeCache | |||
| case 2: | |||
| return &v.unknownFields | |||
| default: | |||
| return nil | |||
| } | |||
| } | |||
| file_pcm_ms_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { | |||
| switch v := v.(*StringStringMapProto); i { | |||
| case 0: | |||
| return &v.state | |||
| case 1: | |||
| return &v.sizeCache | |||
| case 2: | |||
| return &v.unknownFields | |||
| default: | |||
| return nil | |||
| } | |||
| } | |||
| file_pcm_ms_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { | |||
| switch v := v.(*ClusterStateChangeMessageProto); i { | |||
| case 0: | |||
| return &v.state | |||
| case 1: | |||
| return &v.sizeCache | |||
| case 2: | |||
| return &v.unknownFields | |||
| default: | |||
| return nil | |||
| } | |||
| } | |||
| file_pcm_ms_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { | |||
| switch v := v.(*MessageResponseProto); 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_ms_proto_rawDesc, | |||
| NumEnums: 1, | |||
| NumMessages: 6, | |||
| NumExtensions: 0, | |||
| NumServices: 1, | |||
| }, | |||
| GoTypes: file_pcm_ms_proto_goTypes, | |||
| DependencyIndexes: file_pcm_ms_proto_depIdxs, | |||
| EnumInfos: file_pcm_ms_proto_enumTypes, | |||
| MessageInfos: file_pcm_ms_proto_msgTypes, | |||
| }.Build() | |||
| File_pcm_ms_proto = out.File | |||
| file_pcm_ms_proto_rawDesc = nil | |||
| file_pcm_ms_proto_goTypes = nil | |||
| file_pcm_ms_proto_depIdxs = nil | |||
| } | |||
| @@ -0,0 +1,177 @@ | |||
| // Code generated by protoc-gen-go-grpc. DO NOT EDIT. | |||
| // versions: | |||
| // - protoc-gen-go-grpc v1.2.0 | |||
| // - protoc v3.19.4 | |||
| // source: pcm-ms.proto | |||
| package ms | |||
| 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 | |||
| // AgentServiceClient is the client API for AgentService 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 AgentServiceClient interface { | |||
| RequireReRegister(ctx context.Context, in *ClusterReRegisterMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) | |||
| RegisterAck(ctx context.Context, in *ClusterRegisterAckMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) | |||
| ChangeClusterState(ctx context.Context, in *ClusterStateChangeMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) | |||
| } | |||
| type agentServiceClient struct { | |||
| cc grpc.ClientConnInterface | |||
| } | |||
| func NewAgentServiceClient(cc grpc.ClientConnInterface) AgentServiceClient { | |||
| return &agentServiceClient{cc} | |||
| } | |||
| func (c *agentServiceClient) RequireReRegister(ctx context.Context, in *ClusterReRegisterMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) { | |||
| out := new(MessageResponseProto) | |||
| err := c.cc.Invoke(ctx, "/ms.AgentService/requireReRegister", in, out, opts...) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return out, nil | |||
| } | |||
| func (c *agentServiceClient) RegisterAck(ctx context.Context, in *ClusterRegisterAckMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) { | |||
| out := new(MessageResponseProto) | |||
| err := c.cc.Invoke(ctx, "/ms.AgentService/registerAck", in, out, opts...) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return out, nil | |||
| } | |||
| func (c *agentServiceClient) ChangeClusterState(ctx context.Context, in *ClusterStateChangeMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) { | |||
| out := new(MessageResponseProto) | |||
| err := c.cc.Invoke(ctx, "/ms.AgentService/changeClusterState", in, out, opts...) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return out, nil | |||
| } | |||
| // AgentServiceServer is the server API for AgentService service. | |||
| // All implementations must embed UnimplementedAgentServiceServer | |||
| // for forward compatibility | |||
| type AgentServiceServer interface { | |||
| RequireReRegister(context.Context, *ClusterReRegisterMessageProto) (*MessageResponseProto, error) | |||
| RegisterAck(context.Context, *ClusterRegisterAckMessageProto) (*MessageResponseProto, error) | |||
| ChangeClusterState(context.Context, *ClusterStateChangeMessageProto) (*MessageResponseProto, error) | |||
| mustEmbedUnimplementedAgentServiceServer() | |||
| } | |||
| // UnimplementedAgentServiceServer must be embedded to have forward compatible implementations. | |||
| type UnimplementedAgentServiceServer struct { | |||
| } | |||
| func (UnimplementedAgentServiceServer) RequireReRegister(context.Context, *ClusterReRegisterMessageProto) (*MessageResponseProto, error) { | |||
| return nil, status.Errorf(codes.Unimplemented, "method RequireReRegister not implemented") | |||
| } | |||
| func (UnimplementedAgentServiceServer) RegisterAck(context.Context, *ClusterRegisterAckMessageProto) (*MessageResponseProto, error) { | |||
| return nil, status.Errorf(codes.Unimplemented, "method RegisterAck not implemented") | |||
| } | |||
| func (UnimplementedAgentServiceServer) ChangeClusterState(context.Context, *ClusterStateChangeMessageProto) (*MessageResponseProto, error) { | |||
| return nil, status.Errorf(codes.Unimplemented, "method ChangeClusterState not implemented") | |||
| } | |||
| func (UnimplementedAgentServiceServer) mustEmbedUnimplementedAgentServiceServer() {} | |||
| // UnsafeAgentServiceServer may be embedded to opt out of forward compatibility for this service. | |||
| // Use of this interface is not recommended, as added methods to AgentServiceServer will | |||
| // result in compilation errors. | |||
| type UnsafeAgentServiceServer interface { | |||
| mustEmbedUnimplementedAgentServiceServer() | |||
| } | |||
| func RegisterAgentServiceServer(s grpc.ServiceRegistrar, srv AgentServiceServer) { | |||
| s.RegisterService(&AgentService_ServiceDesc, srv) | |||
| } | |||
| func _AgentService_RequireReRegister_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | |||
| in := new(ClusterReRegisterMessageProto) | |||
| if err := dec(in); err != nil { | |||
| return nil, err | |||
| } | |||
| if interceptor == nil { | |||
| return srv.(AgentServiceServer).RequireReRegister(ctx, in) | |||
| } | |||
| info := &grpc.UnaryServerInfo{ | |||
| Server: srv, | |||
| FullMethod: "/ms.AgentService/requireReRegister", | |||
| } | |||
| handler := func(ctx context.Context, req interface{}) (interface{}, error) { | |||
| return srv.(AgentServiceServer).RequireReRegister(ctx, req.(*ClusterReRegisterMessageProto)) | |||
| } | |||
| return interceptor(ctx, in, info, handler) | |||
| } | |||
| func _AgentService_RegisterAck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | |||
| in := new(ClusterRegisterAckMessageProto) | |||
| if err := dec(in); err != nil { | |||
| return nil, err | |||
| } | |||
| if interceptor == nil { | |||
| return srv.(AgentServiceServer).RegisterAck(ctx, in) | |||
| } | |||
| info := &grpc.UnaryServerInfo{ | |||
| Server: srv, | |||
| FullMethod: "/ms.AgentService/registerAck", | |||
| } | |||
| handler := func(ctx context.Context, req interface{}) (interface{}, error) { | |||
| return srv.(AgentServiceServer).RegisterAck(ctx, req.(*ClusterRegisterAckMessageProto)) | |||
| } | |||
| return interceptor(ctx, in, info, handler) | |||
| } | |||
| func _AgentService_ChangeClusterState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | |||
| in := new(ClusterStateChangeMessageProto) | |||
| if err := dec(in); err != nil { | |||
| return nil, err | |||
| } | |||
| if interceptor == nil { | |||
| return srv.(AgentServiceServer).ChangeClusterState(ctx, in) | |||
| } | |||
| info := &grpc.UnaryServerInfo{ | |||
| Server: srv, | |||
| FullMethod: "/ms.AgentService/changeClusterState", | |||
| } | |||
| handler := func(ctx context.Context, req interface{}) (interface{}, error) { | |||
| return srv.(AgentServiceServer).ChangeClusterState(ctx, req.(*ClusterStateChangeMessageProto)) | |||
| } | |||
| return interceptor(ctx, in, info, handler) | |||
| } | |||
| // AgentService_ServiceDesc is the grpc.ServiceDesc for AgentService service. | |||
| // It's only intended for direct use with grpc.RegisterService, | |||
| // and not to be introspected or modified (even as a copy) | |||
| var AgentService_ServiceDesc = grpc.ServiceDesc{ | |||
| ServiceName: "ms.AgentService", | |||
| HandlerType: (*AgentServiceServer)(nil), | |||
| Methods: []grpc.MethodDesc{ | |||
| { | |||
| MethodName: "requireReRegister", | |||
| Handler: _AgentService_RequireReRegister_Handler, | |||
| }, | |||
| { | |||
| MethodName: "registerAck", | |||
| Handler: _AgentService_RegisterAck_Handler, | |||
| }, | |||
| { | |||
| MethodName: "changeClusterState", | |||
| Handler: _AgentService_ChangeClusterState_Handler, | |||
| }, | |||
| }, | |||
| Streams: []grpc.StreamDesc{}, | |||
| Metadata: "pcm-ms.proto", | |||
| } | |||
| @@ -0,0 +1,47 @@ | |||
| syntax = "proto3"; | |||
| package ms; | |||
| option go_package = "/ms"; | |||
| message ClusterReRegisterMessageProto { | |||
| MessageProducerProto msg_producer = 1; | |||
| } | |||
| message MessageProducerProto { | |||
| string ms_net_id = 1; | |||
| string cluster_id = 2; | |||
| string agent_service_host = 3; | |||
| int32 agent_service_port = 4; | |||
| } | |||
| message ClusterRegisterAckMessageProto { | |||
| MessageProducerProto msg_producer = 1; | |||
| repeated StringStringMapProto configs = 3; | |||
| } | |||
| message StringStringMapProto { | |||
| string key = 1; | |||
| string value = 2; | |||
| } | |||
| message ClusterStateChangeMessageProto { | |||
| MessageProducerProto msg_producer = 1; | |||
| int32 cluster_state = 2; | |||
| } | |||
| enum MessageStatus { | |||
| FAIL = 0; | |||
| SUCCESS = 1; | |||
| UNKNOWN = 2; | |||
| } | |||
| message MessageResponseProto { | |||
| MessageStatus message_status = 1; | |||
| } | |||
| service AgentService { | |||
| rpc requireReRegister (ClusterReRegisterMessageProto) returns (MessageResponseProto) {}; | |||
| rpc registerAck (ClusterRegisterAckMessageProto) returns (MessageResponseProto) {}; | |||
| rpc changeClusterState (ClusterStateChangeMessageProto) returns (MessageResponseProto) {}; | |||
| } | |||
| @@ -0,0 +1,39 @@ | |||
| package main | |||
| import ( | |||
| "flag" | |||
| "fmt" | |||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/internal/config" | |||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/internal/server" | |||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/ms" | |||
| "github.com/zeromicro/go-zero/core/conf" | |||
| "github.com/zeromicro/go-zero/core/service" | |||
| "github.com/zeromicro/go-zero/zrpc" | |||
| "google.golang.org/grpc" | |||
| "google.golang.org/grpc/reflection" | |||
| ) | |||
| var configFile = flag.String("f", "etc/pcmms.yaml", "the config file") | |||
| func main() { | |||
| flag.Parse() | |||
| var c config.Config | |||
| conf.MustLoad(*configFile, &c) | |||
| ctx := svc.NewServiceContext(c) | |||
| s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) { | |||
| ms.RegisterAgentServiceServer(grpcServer, server.NewAgentServiceServer(ctx)) | |||
| if c.Mode == service.DevMode || c.Mode == service.TestMode { | |||
| reflection.Register(grpcServer) | |||
| } | |||
| }) | |||
| defer s.Stop() | |||
| fmt.Printf("Starting rpc server at %s...\n", c.ListenOn) | |||
| s.Start() | |||
| } | |||
| @@ -2,12 +2,12 @@ NacosConfig: | |||
| DataId: pcm-octopus-rpc.yaml | |||
| Group: DEFAULT_GROUP | |||
| ServerConfigs: | |||
| - IpAddr: 10.101.15.7 | |||
| - IpAddr: nacos.jcce.dev | |||
| Port: 8848 | |||
| # - IpAddr: nacos-headless | |||
| # Port: 8848 | |||
| ClientConfig: | |||
| NamespaceId: test_octopus | |||
| NamespaceId: test | |||
| TimeoutMs: 5000 | |||
| NotLoadCacheAtStart: true | |||
| LogDir: | |||
| @@ -15,18 +15,21 @@ func OctopusHttpClient(method string, url string, payload io.Reader, token strin | |||
| } else { | |||
| request.Header.Set("Content-Type", "application/json") | |||
| } | |||
| client := http.Client{Timeout: time.Duration(3) * time.Second} | |||
| client := http.Client{Timeout: time.Duration(2) * time.Second} | |||
| res, err := client.Do(request) | |||
| if err != nil { | |||
| if os.IsTimeout(err) { | |||
| log.Fatal("接口调用超时 : ", err) | |||
| log.Println("接口调用超时 : ", err) | |||
| request.Body.Close() | |||
| return nil, err | |||
| } | |||
| log.Fatal(err) | |||
| log.Println(err) | |||
| } | |||
| defer res.Body.Close() | |||
| body, err := io.ReadAll(res.Body) | |||
| if err != nil { | |||
| log.Fatal(err) | |||
| log.Println("body转换错误: ", err) | |||
| return nil, err | |||
| } | |||
| return body, err | |||
| @@ -21,21 +21,22 @@ type TokenTimePair struct { | |||
| } | |||
| var ( | |||
| tokenMap = generateTokenMap() | |||
| tokenMap = generateTokenMap() | |||
| OctopusUrls = getOctopusUrls() | |||
| ) | |||
| func generateTokenMap() map[string]TokenTimePair { | |||
| var tokenMap = make(map[string]TokenTimePair) | |||
| octopusConfig := config.Cfg | |||
| login := Login{ | |||
| Username: octopusConfig.Username, | |||
| Password: octopusConfig.Password, | |||
| Username: octopusConfig.OctopusConfig.Username, | |||
| Password: octopusConfig.OctopusConfig.Password, | |||
| } | |||
| jsonStr, _ := json.Marshal(login) | |||
| urlMap := map[string]string{ | |||
| Hanwuji: octopusConfig.HanwujiUrl + octopusConfig.OctopusTokenUrl, | |||
| Suiyuan: octopusConfig.SuiyuanUrl + octopusConfig.OctopusTokenUrl, | |||
| Sailingsi: octopusConfig.SailingsiUrl + octopusConfig.OctopusTokenUrl, | |||
| Hanwuji: octopusConfig.OctopusConfig.HanwujiUrl + octopusConfig.OctopusConfig.OctopusTokenUrl, | |||
| Suiyuan: octopusConfig.OctopusConfig.SuiyuanUrl + octopusConfig.OctopusConfig.OctopusTokenUrl, | |||
| Sailingsi: octopusConfig.OctopusConfig.SailingsiUrl + octopusConfig.OctopusConfig.OctopusTokenUrl, | |||
| } | |||
| for k, v := range urlMap { | |||
| token, expiredAt := generateToken(jsonStr, v) | |||
| @@ -64,10 +65,29 @@ func generateToken(jsonStr []byte, tokenUrl string) (string, time.Time) { | |||
| } | |||
| func GetToken(kForToken string) string { | |||
| if tokenMap[kForToken].Token == "" { | |||
| tokenMap = generateTokenMap() | |||
| } | |||
| tokenTimePair := tokenMap[kForToken] | |||
| if tokenTimePair.Token == "" { | |||
| return "" | |||
| } | |||
| if time.Now().After(tokenTimePair.ExpiredAt) { | |||
| tokenMap = generateTokenMap() | |||
| } | |||
| return tokenTimePair.Token | |||
| } | |||
| func getOctopusUrls() map[string]string { | |||
| octopusConfig := config.Cfg | |||
| urlMap := map[string]string{ | |||
| Hanwuji: octopusConfig.OctopusConfig.HanwujiUrl, | |||
| Suiyuan: octopusConfig.OctopusConfig.SuiyuanUrl, | |||
| Sailingsi: octopusConfig.OctopusConfig.SailingsiUrl, | |||
| } | |||
| return urlMap | |||
| } | |||
| @@ -5,13 +5,17 @@ import ( | |||
| "flag" | |||
| "github.com/zeromicro/go-zero/core/conf" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| "github.com/zeromicro/go-zero/core/stores/redis" | |||
| "github.com/zeromicro/go-zero/zrpc" | |||
| ) | |||
| type Config struct { | |||
| zrpc.RpcServerConf | |||
| OctopusConfig | |||
| LogConf logx.LogConf | |||
| OctopusConfig OctopusConfig | |||
| OctopusApi OctopusApi | |||
| PcmCoreRpcConf zrpc.RpcClientConf | |||
| LogConf logx.LogConf | |||
| RedisConf redis.RedisConf | |||
| } | |||
| var configFile = flag.String("f", "adaptor/PCM-AI/PCM-OCTOPUS/rpc/etc/octopus.yaml", "the config file") | |||
| @@ -10,4 +10,58 @@ type OctopusConfig struct { | |||
| OctopusTokenUrl string | |||
| CambriconMLU290 int32 | |||
| EnflameT20 int32 | |||
| OctopusCp string | |||
| } | |||
| type OctopusApi struct { | |||
| GetUserImageList string | |||
| GetMyAlgorithmList string | |||
| GetNotebookList string | |||
| GetMydatasetList string | |||
| CreateImage string | |||
| DeleteImage string | |||
| CreateDataSet string | |||
| DeleteDataSet string | |||
| GetAlgorithmApplyList string | |||
| GetAlgorithmFrameworkList string | |||
| DeleteMyAlgorithm string | |||
| CreateMyAlgorithm string | |||
| GetAlgorithmList string | |||
| GetAlgorithm string | |||
| DownloadAlgorithm string | |||
| UploadAlgorithm string | |||
| UploadAlgorithmConfirm string | |||
| UploadImage string | |||
| UploadImageConfirm string | |||
| UploadDataSet string | |||
| UploadDataSetConfirm string | |||
| CreateDataSetVersion string | |||
| DeleteDataSetVersion string | |||
| GetDatasetVersionList string | |||
| DeleteNotebook string | |||
| StartNotebook string | |||
| StopNotebook string | |||
| CreateNotebook string | |||
| GetNotebook string | |||
| CreateTrainJob string | |||
| GetDatasetApplyList string | |||
| GetDatasetTypeList string | |||
| GetTrainJobList string | |||
| GetMyModelList string | |||
| GetModelVersionList string | |||
| DeleteMyModel string | |||
| DeleteModelVersion string | |||
| DownloadModelVersion string | |||
| GetTrainJob string | |||
| DeleteTrainJob string | |||
| StopTrainJob string | |||
| GetTrainJobEvent string | |||
| GetTrainJobMetric string | |||
| CreateModelDeploy string | |||
| GetModelDeployList string | |||
| GetModelDeploy string | |||
| GetModelDeployEvent string | |||
| StopModelDeploy string | |||
| DeleteModelDeploy string | |||
| InferModelDeploy string | |||
| } | |||
| @@ -1,8 +1,10 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| @@ -21,28 +23,23 @@ func NewCreateDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cre | |||
| } | |||
| } | |||
| func (l *CreateDataSetLogic) CreateDataSet(in *octopus.CreateDataSetReq) (*octopus.CreateDataSetResq, error) { | |||
| // todo: add your logic here and delete this line | |||
| /* { | |||
| // todo: add your logic here and delete this line | |||
| var resp octopus.CreateDataSetResq | |||
| url := "http://192.168.242.41:8001/openaiserver/v1/datasetmanage/dataset" | |||
| reqByte, err := json.Marshal(in) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| 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) | |||
| } else if statusCode == 400 { | |||
| json.Unmarshal(body, &resp) | |||
| } | |||
| }*/ | |||
| return &octopus.CreateDataSetResq{}, nil | |||
| func (l *CreateDataSetLogic) CreateDataSet(in *octopus.CreateDataSetReq) (*octopus.CreateDataSetResp, error) { | |||
| resp := &octopus.CreateDataSetResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.CreateDataSet | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetBody(in.CreateDataSet). | |||
| SetResult(resp). | |||
| Post(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,48 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type CreateDataSetVersionLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewCreateDataSetVersionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateDataSetVersionLogic { | |||
| return &CreateDataSetVersionLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *CreateDataSetVersionLogic) CreateDataSetVersion(in *octopus.CreateDataSetVersionReq) (*octopus.CreateDataSetVersionResp, error) { | |||
| resp := &octopus.CreateDataSetVersionResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.CreateDataSetVersion | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetPathParam("datasetId", in.DatasetId). | |||
| SetBody(in.Params). | |||
| SetResult(resp). | |||
| Post(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,46 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type CreateImageLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewCreateImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateImageLogic { | |||
| return &CreateImageLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *CreateImageLogic) CreateImage(in *octopus.CreateImageReq) (*octopus.CreateImageResp, error) { | |||
| resp := &octopus.CreateImageResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.CreateImage | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetBody(in.CreateImage). | |||
| SetResult(resp). | |||
| Post(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,48 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type CreateModelDeployLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewCreateModelDeployLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateModelDeployLogic { | |||
| return &CreateModelDeployLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| // ModelDeployService | |||
| func (l *CreateModelDeployLogic) CreateModelDeploy(in *octopus.CreateModelDeployReq) (*octopus.CreateModelDeployResp, error) { | |||
| resp := &octopus.CreateModelDeployResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.CreateModelDeploy | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetBody(in.Params). | |||
| SetResult(resp). | |||
| Post(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,47 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type CreateMyAlgorithmLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewCreateMyAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateMyAlgorithmLogic { | |||
| return &CreateMyAlgorithmLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *CreateMyAlgorithmLogic) CreateMyAlgorithm(in *octopus.CreateMyAlgorithmReq) (*octopus.CreateMyAlgorithmResp, error) { | |||
| resp := &octopus.CreateMyAlgorithmResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.CreateMyAlgorithm | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetBody(in.CreateMyAlgorithm). | |||
| SetResult(resp). | |||
| Post(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,47 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type CreateNotebookLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewCreateNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateNotebookLogic { | |||
| return &CreateNotebookLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *CreateNotebookLogic) CreateNotebook(in *octopus.CreateNotebookReq) (*octopus.CreateNotebookResp, error) { | |||
| resp := &octopus.CreateNotebookResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.CreateNotebook | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetBody(in.Params). | |||
| SetResult(resp). | |||
| Post(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,48 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type CreateTrainJobLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewCreateTrainJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTrainJobLogic { | |||
| return &CreateTrainJobLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| // TrainJobService | |||
| func (l *CreateTrainJobLogic) CreateTrainJob(in *octopus.CreateTrainJobReq) (*octopus.CreateTrainJobResp, error) { | |||
| resp := &octopus.CreateTrainJobResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.CreateTrainJob | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetBody(in.Params). | |||
| SetResult(resp). | |||
| Post(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,47 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type DeleteDataSetLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewDeleteDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDataSetLogic { | |||
| return &DeleteDataSetLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *DeleteDataSetLogic) DeleteDataSet(in *octopus.DeleteDataSetReq) (*octopus.DeleteDataSetResp, error) { | |||
| resp := &octopus.DeleteDataSetResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DeleteDataSet | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetPathParam("id", in.Id). | |||
| SetResult(resp). | |||
| Delete(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,48 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type DeleteDataSetVersionLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewDeleteDataSetVersionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDataSetVersionLogic { | |||
| return &DeleteDataSetVersionLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *DeleteDataSetVersionLogic) DeleteDataSetVersion(in *octopus.DeleteDataSetVersionReq) (*octopus.DeleteDataSetVersionResp, error) { | |||
| resp := &octopus.DeleteDataSetVersionResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DeleteDataSetVersion | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetPathParam("datasetId", in.DatasetId). | |||
| SetPathParam("version", in.Version). | |||
| SetResult(resp). | |||
| Delete(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,47 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type DeleteImageLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewDeleteImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteImageLogic { | |||
| return &DeleteImageLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *DeleteImageLogic) DeleteImage(in *octopus.DeleteImageReq) (*octopus.DeleteImageResp, error) { | |||
| resp := &octopus.DeleteImageResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DeleteImage | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetPathParam("imageId", in.ImageId). | |||
| SetResult(resp). | |||
| Delete(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,52 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type DeleteModelDeployLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewDeleteModelDeployLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteModelDeployLogic { | |||
| return &DeleteModelDeployLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *DeleteModelDeployLogic) DeleteModelDeploy(in *octopus.DeleteModelDeployReq) (*octopus.DeleteModelDeployResp, error) { | |||
| resp := &octopus.DeleteModelDeployResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DeleteModelDeploy | |||
| token := common.GetToken(in.Platform) | |||
| var queryStr string | |||
| for _, s := range in.GetJobIds() { | |||
| queryStr += "jobIds=" + s + "&" | |||
| } | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetQueryString(queryStr). | |||
| SetResult(resp). | |||
| Delete(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,48 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type DeleteModelVersionLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewDeleteModelVersionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteModelVersionLogic { | |||
| return &DeleteModelVersionLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *DeleteModelVersionLogic) DeleteModelVersion(in *octopus.DeleteModelVersionReq) (*octopus.DeleteModelVersionResp, error) { | |||
| resp := &octopus.DeleteModelVersionResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DeleteModelVersion | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetPathParam("modelId", in.ModelId). | |||
| SetPathParam("version", in.Version). | |||
| SetResult(resp). | |||
| Delete(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,47 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type DeleteMyAlgorithmLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewDeleteMyAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteMyAlgorithmLogic { | |||
| return &DeleteMyAlgorithmLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *DeleteMyAlgorithmLogic) DeleteMyAlgorithm(in *octopus.DeleteMyAlgorithmReq) (*octopus.DeleteMyAlgorithmResp, error) { | |||
| resp := &octopus.DeleteMyAlgorithmResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DeleteMyAlgorithm | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetPathParam("algorithmId", in.AlgorithmId). | |||
| SetResult(resp). | |||
| Delete(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,48 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type DeleteMyModelLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewDeleteMyModelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteMyModelLogic { | |||
| return &DeleteMyModelLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *DeleteMyModelLogic) DeleteMyModel(in *octopus.DeleteMyModelReq) (*octopus.DeleteMyModelResp, error) { | |||
| resp := &octopus.DeleteMyModelResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DeleteMyModel | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetPathParam("modelId", in.ModelId). | |||
| SetResult(resp). | |||
| Delete(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,47 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type DeleteNotebookLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewDeleteNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteNotebookLogic { | |||
| return &DeleteNotebookLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *DeleteNotebookLogic) DeleteNotebook(in *octopus.DeleteNotebookReq) (*octopus.DeleteNotebookResp, error) { | |||
| resp := &octopus.DeleteNotebookResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DeleteNotebook | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetPathParam("id", in.Id). | |||
| SetResult(resp). | |||
| Delete(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,52 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type DeleteTrainJobLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewDeleteTrainJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTrainJobLogic { | |||
| return &DeleteTrainJobLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *DeleteTrainJobLogic) DeleteTrainJob(in *octopus.DeleteTrainJobReq) (*octopus.DeleteTrainJobResp, error) { | |||
| resp := &octopus.DeleteTrainJobResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DeleteTrainJob | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| var queryStr string | |||
| for _, s := range in.GetJobIds() { | |||
| queryStr += "jobIds=" + s + "&" | |||
| } | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetQueryString(queryStr). | |||
| SetResult(resp). | |||
| Delete(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,48 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type DownloadAlgorithmLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewDownloadAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DownloadAlgorithmLogic { | |||
| return &DownloadAlgorithmLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *DownloadAlgorithmLogic) DownloadAlgorithm(in *octopus.DownloadAlgorithmReq) (*octopus.DownloadAlgorithmResp, error) { | |||
| resp := &octopus.DownloadAlgorithmResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DownloadAlgorithm | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetPathParam("algorithmId", in.AlgorithmId). | |||
| SetPathParam("version", in.Version). | |||
| SetResult(resp). | |||
| Get(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,48 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type DownloadModelVersionLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewDownloadModelVersionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DownloadModelVersionLogic { | |||
| return &DownloadModelVersionLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *DownloadModelVersionLogic) DownloadModelVersion(in *octopus.DownloadModelVersionReq) (*octopus.DownloadModelVersionResp, error) { | |||
| resp := &octopus.DownloadModelVersionResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DownloadModelVersion | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetPathParam("modelId", in.ModelId). | |||
| SetPathParam("version", in.Version). | |||
| SetQueryString("domain=" + in.Domain). | |||
| SetResult(resp). | |||
| Get(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,50 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "strconv" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type GetAlgorithmApplyListLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewGetAlgorithmApplyListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAlgorithmApplyListLogic { | |||
| return &GetAlgorithmApplyListLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *GetAlgorithmApplyListLogic) GetAlgorithmApplyList(in *octopus.GetAlgorithmApplyListReq) (*octopus.GetAlgorithmApplyListResp, error) { | |||
| resp := &octopus.GetAlgorithmApplyListResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.GetAlgorithmApplyList | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetQueryString("pageIndex=" + strconv.Itoa(int(in.PageIndex))). | |||
| SetQueryString("pageSize=" + strconv.Itoa(int(in.PageSize))). | |||
| SetResult(resp). | |||
| Get(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,50 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "strconv" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type GetAlgorithmFrameworkListLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewGetAlgorithmFrameworkListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAlgorithmFrameworkListLogic { | |||
| return &GetAlgorithmFrameworkListLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *GetAlgorithmFrameworkListLogic) GetAlgorithmFrameworkList(in *octopus.GetAlgorithmFrameworkListReq) (*octopus.GetAlgorithmFrameworkListResp, error) { | |||
| resp := &octopus.GetAlgorithmFrameworkListResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.GetAlgorithmFrameworkList | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetQueryString("pageIndex=" + strconv.Itoa(int(in.PageIndex))). | |||
| SetQueryString("pageSize=" + strconv.Itoa(int(in.PageSize))). | |||
| SetResult(resp). | |||
| Get(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,51 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "strconv" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type GetAlgorithmListLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewGetAlgorithmListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAlgorithmListLogic { | |||
| return &GetAlgorithmListLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *GetAlgorithmListLogic) GetAlgorithmList(in *octopus.GetAlgorithmListReq) (*octopus.GetAlgorithmListResp, error) { | |||
| resp := &octopus.GetAlgorithmListResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.GetAlgorithmList | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetQueryString("pageIndex="+strconv.Itoa(int(in.PageIndex))). | |||
| SetQueryString("pageSize="+strconv.Itoa(int(in.PageSize))). | |||
| SetPathParam("algorithmId", in.AlgorithmId). | |||
| SetResult(resp). | |||
| Get(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,48 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type GetAlgorithmLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewGetAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAlgorithmLogic { | |||
| return &GetAlgorithmLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *GetAlgorithmLogic) GetAlgorithm(in *octopus.GetAlgorithmReq) (*octopus.GetAlgorithmResp, error) { | |||
| resp := &octopus.GetAlgorithmResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.GetAlgorithm | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetPathParam("algorithmId", in.AlgorithmId). | |||
| SetPathParam("version", in.Version). | |||
| SetResult(resp). | |||
| Get(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -7,10 +7,11 @@ import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "context" | |||
| "encoding/json" | |||
| "github.com/go-redis/redis" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| "log" | |||
| "strconv" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| "time" | |||
| ) | |||
| type GetComputingPowerLogic struct { | |||
| @@ -29,12 +30,41 @@ func NewGetComputingPowerLogic(ctx context.Context, svcCtx *svc.ServiceContext) | |||
| func (l *GetComputingPowerLogic) GetComputingPower(in *octopus.ResourceReq) (*octopus.CpResp, error) { | |||
| var resp octopus.CpResp | |||
| var cp float32 | |||
| redisClient := redis.NewClient(&redis.Options{ | |||
| Addr: l.svcCtx.Config.RedisConf.Host, | |||
| Password: l.svcCtx.Config.RedisConf.Pass, | |||
| }) | |||
| defer redisClient.Close() | |||
| _, err := redisClient.Ping().Result() | |||
| if err != nil { | |||
| log.Println("redis连接失败", err) | |||
| cp = getCPFromOctopus() | |||
| redisClient.Set(l.svcCtx.Config.OctopusConfig.OctopusCp, cp, 168*time.Hour) | |||
| } else { | |||
| res, err := redisClient.Get(l.svcCtx.Config.OctopusConfig.OctopusCp).Float32() | |||
| if err == redis.Nil { | |||
| log.Println("redis key未找到或已过期,重新请求") | |||
| cp = getCPFromOctopus() | |||
| redisClient.Set(l.svcCtx.Config.OctopusConfig.OctopusCp, cp, 168*time.Hour) | |||
| } else { | |||
| cp = res | |||
| } | |||
| } | |||
| resp.POpsAtFp16 = cp | |||
| return &resp, nil | |||
| } | |||
| func getCPFromOctopus() float32 { | |||
| octopusConfig := config.Cfg | |||
| urlMap := map[string]string{ | |||
| common.Hanwuji: octopusConfig.OctopusConfig.HanwujiUrl + octopusConfig.OctopusResouceSpec, | |||
| common.Suiyuan: octopusConfig.OctopusConfig.SuiyuanUrl + octopusConfig.OctopusResouceSpec, | |||
| common.Sailingsi: octopusConfig.OctopusConfig.SailingsiUrl + octopusConfig.OctopusResouceSpec, | |||
| common.Hanwuji: octopusConfig.OctopusConfig.HanwujiUrl + octopusConfig.OctopusConfig.OctopusResouceSpec, | |||
| common.Suiyuan: octopusConfig.OctopusConfig.SuiyuanUrl + octopusConfig.OctopusConfig.OctopusResouceSpec, | |||
| common.Sailingsi: octopusConfig.OctopusConfig.SailingsiUrl + octopusConfig.OctopusConfig.OctopusResouceSpec, | |||
| } | |||
| var computingPowerInTops int32 | |||
| @@ -42,7 +72,7 @@ func (l *GetComputingPowerLogic) GetComputingPower(in *octopus.ResourceReq) (*oc | |||
| token := common.GetToken(k) | |||
| body, err := common.OctopusHttpClient("GET", v, nil, token) | |||
| if err != nil { | |||
| return nil, err | |||
| continue | |||
| } | |||
| //获取训练资源算力 | |||
| switch k { | |||
| @@ -62,8 +92,7 @@ func (l *GetComputingPowerLogic) GetComputingPower(in *octopus.ResourceReq) (*oc | |||
| if err != nil { | |||
| continue | |||
| } | |||
| computingPowerInTops += octopusConfig.CambriconMLU290 * int32(numOfCards) | |||
| computingPowerInTops += octopusConfig.OctopusConfig.CambriconMLU290 * int32(numOfCards) | |||
| } | |||
| case common.Suiyuan: | |||
| resourceSpec := common.SuiyuanResp{} | |||
| @@ -81,12 +110,16 @@ func (l *GetComputingPowerLogic) GetComputingPower(in *octopus.ResourceReq) (*oc | |||
| if err != nil { | |||
| continue | |||
| } | |||
| computingPowerInTops += octopusConfig.EnflameT20 * int32(numOfCards) | |||
| computingPowerInTops += octopusConfig.OctopusConfig.EnflameT20 * int32(numOfCards) | |||
| } | |||
| } | |||
| } | |||
| resp.POpsAtFp16 = float32(computingPowerInTops) / 1024 | |||
| return &resp, nil | |||
| if computingPowerInTops == 0 { | |||
| return 0 | |||
| } | |||
| return float32(computingPowerInTops) / 1024 | |||
| } | |||
| @@ -0,0 +1,50 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "strconv" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type GetDatasetApplyListLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewGetDatasetApplyListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDatasetApplyListLogic { | |||
| return &GetDatasetApplyListLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *GetDatasetApplyListLogic) GetDatasetApplyList(in *octopus.GetDatasetApplyListReq) (*octopus.GetDatasetApplyListResp, error) { | |||
| resp := &octopus.GetDatasetApplyListResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.GetDatasetApplyList | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetQueryString("pageIndex=" + strconv.Itoa(int(in.PageIndex))). | |||
| SetQueryString("pageSize=" + strconv.Itoa(int(in.PageSize))). | |||
| SetResult(resp). | |||
| Get(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,50 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "strconv" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type GetDatasetTypeListLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewGetDatasetTypeListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDatasetTypeListLogic { | |||
| return &GetDatasetTypeListLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *GetDatasetTypeListLogic) GetDatasetTypeList(in *octopus.GetDatasetTypeListRep) (*octopus.GetDatasetTypeListResp, error) { | |||
| resp := &octopus.GetDatasetTypeListResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.GetDatasetTypeList | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetQueryString("pageIndex=" + strconv.Itoa(int(in.PageIndex))). | |||
| SetQueryString("pageSize=" + strconv.Itoa(int(in.PageSize))). | |||
| SetResult(resp). | |||
| Get(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,51 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "strconv" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type GetDatasetVersionListLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewGetDatasetVersionListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDatasetVersionListLogic { | |||
| return &GetDatasetVersionListLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *GetDatasetVersionListLogic) GetDatasetVersionList(in *octopus.GetDatasetVersionListReq) (*octopus.GetDatasetVersionListResp, error) { | |||
| resp := &octopus.GetDatasetVersionListResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.GetDatasetVersionList | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetPathParam("datasetId", in.DatasetId). | |||
| SetQueryString("pageIndex=" + strconv.Itoa(int(in.PageIndex))). | |||
| SetQueryString("pageSize=" + strconv.Itoa(int(in.PageSize))). | |||
| SetResult(resp). | |||
| Get(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -1,7 +1,15 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/config" | |||
| "context" | |||
| "encoding/json" | |||
| "github.com/go-redis/redis" | |||
| "log" | |||
| "strconv" | |||
| "strings" | |||
| "time" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| @@ -9,6 +17,12 @@ import ( | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| const ( | |||
| GI = "Gi" | |||
| OctopusGeneralInfo = "octopusGeneralInfo" | |||
| Comma = "," | |||
| ) | |||
| type GetGeneralInfoLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| @@ -24,7 +38,116 @@ func NewGetGeneralInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge | |||
| } | |||
| func (l *GetGeneralInfoLogic) GetGeneralInfo(in *octopus.ResourceReq) (*octopus.GiResp, error) { | |||
| // todo: add your logic here and delete this line | |||
| var resp octopus.GiResp | |||
| var octopusCpuCores int32 | |||
| var octopusMemoryInGi int32 | |||
| redisClient := redis.NewClient(&redis.Options{ | |||
| Addr: l.svcCtx.Config.RedisConf.Host, | |||
| Password: l.svcCtx.Config.RedisConf.Pass, | |||
| }) | |||
| defer redisClient.Close() | |||
| _, err := redisClient.Ping().Result() | |||
| if err != nil { | |||
| log.Println("redis连接失败", err) | |||
| octopusCpuCores, octopusMemoryInGi = getGeneralInfoFromOctopus() | |||
| octopusGeneralInfo := strconv.FormatInt(int64(octopusCpuCores), 10) + Comma + strconv.FormatInt(int64(octopusMemoryInGi), 10) | |||
| redisClient.Set(OctopusGeneralInfo, octopusGeneralInfo, 168*time.Hour) | |||
| } else { | |||
| res, err := redisClient.Get(OctopusGeneralInfo).Result() | |||
| if err == redis.Nil { | |||
| log.Println("redis key未找到或已过期,重新请求") | |||
| octopusCpuCores, octopusMemoryInGi = getGeneralInfoFromOctopus() | |||
| octopusGeneralInfo := strconv.FormatInt(int64(octopusCpuCores), 10) + Comma + strconv.FormatInt(int64(octopusMemoryInGi), 10) | |||
| redisClient.Set(OctopusGeneralInfo, octopusGeneralInfo, 168*time.Hour) | |||
| } else { | |||
| strs := strings.Split(res, Comma) | |||
| cpu, _ := strconv.ParseInt(strs[0], 10, 32) | |||
| memory, _ := strconv.ParseInt(strs[1], 10, 32) | |||
| octopusCpuCores = int32(cpu) | |||
| octopusMemoryInGi = int32(memory) | |||
| } | |||
| } | |||
| resp.CpuCoreNum = octopusCpuCores | |||
| resp.MemoryInGib = octopusMemoryInGi | |||
| return &resp, nil | |||
| } | |||
| func getGeneralInfoFromOctopus() (int32, int32) { | |||
| octopusConfig := config.Cfg | |||
| urlMap := map[string]string{ | |||
| common.Hanwuji: octopusConfig.OctopusConfig.HanwujiUrl + octopusConfig.OctopusConfig.OctopusResouceSpec, | |||
| common.Suiyuan: octopusConfig.OctopusConfig.SuiyuanUrl + octopusConfig.OctopusConfig.OctopusResouceSpec, | |||
| common.Sailingsi: octopusConfig.OctopusConfig.SailingsiUrl + octopusConfig.OctopusConfig.OctopusResouceSpec, | |||
| } | |||
| var cpuCoreNum int32 | |||
| var memoryInGib int32 | |||
| for k, v := range urlMap { | |||
| token := common.GetToken(k) | |||
| body, err := common.OctopusHttpClient("GET", v, nil, token) | |||
| if err != nil { | |||
| continue | |||
| } | |||
| //获取训练资源算力 | |||
| switch k { | |||
| case common.Hanwuji: | |||
| resourceSpec := common.HanwujiResp{} | |||
| err := json.Unmarshal(body, &resourceSpec) | |||
| if err != nil { | |||
| log.Println("Hanwuji json转换失败 : ", err) | |||
| continue | |||
| } | |||
| if !resourceSpec.Success { | |||
| log.Println("Hanwuji 获取训练资源失败 : ", resourceSpec.Error) | |||
| continue | |||
| } | |||
| for _, spec := range resourceSpec.Payload.MapResourceSpecIdList.Train.ResourceSpecs { | |||
| cpuInfo, err := strconv.ParseInt(spec.ResourceQuantity.Cpu, 10, 32) | |||
| if err != nil { | |||
| continue | |||
| } | |||
| cpuCoreNum += int32(cpuInfo) | |||
| memoryStr := strings.Replace(spec.ResourceQuantity.Memory, GI, "", -1) | |||
| memoryInfo, err := strconv.ParseInt(memoryStr, 10, 32) | |||
| if err != nil { | |||
| continue | |||
| } | |||
| memoryInGib += int32(memoryInfo) | |||
| } | |||
| case common.Suiyuan: | |||
| resourceSpec := common.SuiyuanResp{} | |||
| err := json.Unmarshal(body, &resourceSpec) | |||
| if err != nil { | |||
| log.Println("Suiyuan json转换失败 : ", err) | |||
| continue | |||
| } | |||
| if !resourceSpec.Success { | |||
| log.Println("Suiyuan 获取训练资源失败 : ", resourceSpec.Error) | |||
| continue | |||
| } | |||
| for _, spec := range resourceSpec.Payload.MapResourceSpecIdList.Train.ResourceSpecs { | |||
| cpuInfo, err := strconv.ParseInt(spec.ResourceQuantity.Cpu, 10, 32) | |||
| if err != nil { | |||
| continue | |||
| } | |||
| cpuCoreNum += int32(cpuInfo) | |||
| memoryStr := strings.Replace(spec.ResourceQuantity.Memory, GI, "", -1) | |||
| memoryInfo, err := strconv.ParseInt(memoryStr, 10, 32) | |||
| if err != nil { | |||
| continue | |||
| } | |||
| memoryInGib += int32(memoryInfo) | |||
| } | |||
| } | |||
| } | |||
| return &octopus.GiResp{}, nil | |||
| return cpuCoreNum, memoryInGib | |||
| } | |||
| @@ -0,0 +1,52 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "strconv" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type GetModelDeployEventLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewGetModelDeployEventLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetModelDeployEventLogic { | |||
| return &GetModelDeployEventLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| func (l *GetModelDeployEventLogic) GetModelDeployEvent(in *octopus.GetModelDeployEventReq) (*octopus.GetModelDeployEventResp, error) { | |||
| resp := &octopus.GetModelDeployEventResp{} | |||
| var url_prefix = common.OctopusUrls[in.Platform] | |||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.GetModelDeployEvent | |||
| token := common.GetToken(in.Platform) | |||
| req := tool.GetACHttpRequest() | |||
| _, err := req. | |||
| SetHeader("Authorization", "Bearer "+token). | |||
| SetQueryString("id=" + in.Id). | |||
| SetQueryString("pageIndex=" + strconv.Itoa(int(in.PageIndex))). | |||
| SetQueryString("pageSize=" + strconv.Itoa(int(in.PageSize))). | |||
| SetQueryString("isMain=" + strconv.FormatBool(in.IsMain)). | |||
| SetResult(resp). | |||
| Get(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return resp, nil | |||
| } | |||