fix:add GetFile for find algoName
This commit is contained in:
parent
125901e330
commit
d70bdd71c9
|
@ -2,6 +2,7 @@ Name: pcm.modelarts.rpc
|
|||
ListenOn: 0.0.0.0:2002
|
||||
AdapterId: 1777144940459986944
|
||||
CoreUrl: "http://127.0.0.1:8999"
|
||||
FileUrl: "https://pcm1-bucket1.obs.cn-south-222.ai.pcl.cn/"
|
||||
|
||||
Timeout: 500000
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"github.com/go-resty/resty/v2"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GetRestyRequest(timeoutSeconds int64) *resty.Request {
|
||||
client := resty.New().SetTimeout(time.Duration(timeoutSeconds) * time.Second)
|
||||
request := client.R()
|
||||
return request
|
||||
}
|
|
@ -12,4 +12,5 @@ type Config struct {
|
|||
ModelArtsConf ModelArtsConf
|
||||
AdapterId int64
|
||||
CoreUrl string
|
||||
FileUrl string
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package modelartsservicelogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/common"
|
||||
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetFileLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetFileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFileLogic {
|
||||
return &GetFileLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// File
|
||||
func (l *GetFileLogic) GetFile(in *modelarts.GetFileReq) (*modelarts.GetFileResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
resp := &modelarts.GetFileResp{}
|
||||
var reqUrl = l.svcCtx.Config.FileUrl + in.Path
|
||||
|
||||
req := common.GetRestyRequest(20)
|
||||
body, err := req.
|
||||
SetQueryParam("path", in.Path).
|
||||
Get(reqUrl)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp.Content = string(body.Body())
|
||||
|
||||
return resp, nil
|
||||
}
|
|
@ -4,9 +4,11 @@ import (
|
|||
"crypto/tls"
|
||||
"fmt"
|
||||
"github.com/JCCE-nudt/apigw-go-sdk/core"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/config"
|
||||
"io"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
var FileName string
|
||||
|
@ -96,3 +98,9 @@ func GetModelArtsConfWithPlatform(platform string) (*config.Conf, error) {
|
|||
}
|
||||
return &conf, nil
|
||||
}
|
||||
|
||||
func GetRestyRequest(timeoutSeconds int64) *resty.Request {
|
||||
client := resty.New().SetTimeout(time.Duration(timeoutSeconds) * time.Second)
|
||||
request := client.R()
|
||||
return request
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -71,6 +71,7 @@ const (
|
|||
ModelArtsService_ImageReasoning_FullMethodName = "/modelarts.ModelArtsService/ImageReasoning"
|
||||
ModelArtsService_ImageReasoningUrl_FullMethodName = "/modelarts.ModelArtsService/ImageReasoningUrl"
|
||||
ModelArtsService_ChatglmReasoning_FullMethodName = "/modelarts.ModelArtsService/ChatglmReasoning"
|
||||
ModelArtsService_GetFile_FullMethodName = "/modelarts.ModelArtsService/GetFile"
|
||||
)
|
||||
|
||||
// ModelArtsServiceClient is the client API for ModelArtsService service.
|
||||
|
@ -158,6 +159,8 @@ type ModelArtsServiceClient interface {
|
|||
ImageReasoning(ctx context.Context, in *ImageReasoningReq, opts ...grpc.CallOption) (*ImageReasoningResp, error)
|
||||
ImageReasoningUrl(ctx context.Context, in *ImageReasoningUrlReq, opts ...grpc.CallOption) (*ImageReasoningUrlResp, error)
|
||||
ChatglmReasoning(ctx context.Context, in *ChatglmReasoningReq, opts ...grpc.CallOption) (*ChatglmReasoningResp, error)
|
||||
// File
|
||||
GetFile(ctx context.Context, in *GetFileReq, opts ...grpc.CallOption) (*GetFileResp, error)
|
||||
}
|
||||
|
||||
type modelArtsServiceClient struct {
|
||||
|
@ -636,6 +639,15 @@ func (c *modelArtsServiceClient) ChatglmReasoning(ctx context.Context, in *Chatg
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *modelArtsServiceClient) GetFile(ctx context.Context, in *GetFileReq, opts ...grpc.CallOption) (*GetFileResp, error) {
|
||||
out := new(GetFileResp)
|
||||
err := c.cc.Invoke(ctx, ModelArtsService_GetFile_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// ModelArtsServiceServer is the server API for ModelArtsService service.
|
||||
// All implementations must embed UnimplementedModelArtsServiceServer
|
||||
// for forward compatibility
|
||||
|
@ -721,6 +733,8 @@ type ModelArtsServiceServer interface {
|
|||
ImageReasoning(context.Context, *ImageReasoningReq) (*ImageReasoningResp, error)
|
||||
ImageReasoningUrl(context.Context, *ImageReasoningUrlReq) (*ImageReasoningUrlResp, error)
|
||||
ChatglmReasoning(context.Context, *ChatglmReasoningReq) (*ChatglmReasoningResp, error)
|
||||
// File
|
||||
GetFile(context.Context, *GetFileReq) (*GetFileResp, error)
|
||||
mustEmbedUnimplementedModelArtsServiceServer()
|
||||
}
|
||||
|
||||
|
@ -884,6 +898,9 @@ func (UnimplementedModelArtsServiceServer) ImageReasoningUrl(context.Context, *I
|
|||
func (UnimplementedModelArtsServiceServer) ChatglmReasoning(context.Context, *ChatglmReasoningReq) (*ChatglmReasoningResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ChatglmReasoning not implemented")
|
||||
}
|
||||
func (UnimplementedModelArtsServiceServer) GetFile(context.Context, *GetFileReq) (*GetFileResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetFile not implemented")
|
||||
}
|
||||
func (UnimplementedModelArtsServiceServer) mustEmbedUnimplementedModelArtsServiceServer() {}
|
||||
|
||||
// UnsafeModelArtsServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
|
@ -1833,6 +1850,24 @@ func _ModelArtsService_ChatglmReasoning_Handler(srv interface{}, ctx context.Con
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _ModelArtsService_GetFile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetFileReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ModelArtsServiceServer).GetFile(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: ModelArtsService_GetFile_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ModelArtsServiceServer).GetFile(ctx, req.(*GetFileReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// ModelArtsService_ServiceDesc is the grpc.ServiceDesc for ModelArtsService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
|
@ -2048,6 +2083,10 @@ var ModelArtsService_ServiceDesc = grpc.ServiceDesc{
|
|||
MethodName: "ChatglmReasoning",
|
||||
Handler: _ModelArtsService_ChatglmReasoning_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetFile",
|
||||
Handler: _ModelArtsService_GetFile_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "pcm-modelarts.proto",
|
||||
|
|
|
@ -2526,6 +2526,17 @@ message GetTrainingJobLogsPreviewResp {
|
|||
int32 full_size = 3; //完整的日志大小(单位:字节)。
|
||||
}
|
||||
|
||||
/******************File first*************************/
|
||||
message GetFileReq{
|
||||
string path = 1;
|
||||
}
|
||||
|
||||
message GetFileResp{
|
||||
string content = 1;
|
||||
}
|
||||
|
||||
/******************File first*************************/
|
||||
|
||||
// Slurm Services for Shuguang Branch
|
||||
service ModelArtsService {
|
||||
|
||||
|
@ -2621,6 +2632,9 @@ service ModelArtsService {
|
|||
rpc ImageReasoning(ImageReasoningReq) returns (ImageReasoningResp);
|
||||
rpc ImageReasoningUrl(ImageReasoningUrlReq) returns (ImageReasoningUrlResp);
|
||||
rpc ChatglmReasoning(ChatglmReasoningReq) returns (ChatglmReasoningResp);
|
||||
|
||||
//File
|
||||
rpc GetFile (GetFileReq) returns (GetFileResp);
|
||||
}
|
||||
|
||||
message Errors {
|
||||
|
|
Loading…
Reference in New Issue