fix:合并modelarts代码到2.0分支

This commit is contained in:
qiwang 2023-03-15 16:07:09 +08:00
parent c8677333f3
commit ee16b5ce23
10 changed files with 3591 additions and 2716 deletions

View File

@ -44,13 +44,14 @@ func (l *CreateServiceLogic) CreateService(in *modelarts.CreateServiceReq) (*mod
}
payload := strings.NewReader(string(reqByte))
token := common.GetToken()
body, err := tool.HttpClient(tool.POST, url, payload, token)
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, url, payload, token)
if err != nil {
return nil, err
}
json.Unmarshal(body, &resp)
resp.Code = int32(200)
resp.Msg = "Success"
if statusCode == 200 {
json.Unmarshal(body, &resp.Resp200)
} else {
json.Unmarshal(body, &resp.Resp400)
}
return &resp, nil
}

View File

@ -35,12 +35,15 @@ func (l *DeleteServiceLogic) DeleteService(in *modelarts.DeleteServiceReq) (*mod
var resp modelarts.DeleteServiceResp
url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/services/" + in.ServiceId
token := common.GetToken()
body, err := tool.HttpClient(tool.DELETE, url, nil, token)
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, url, nil, token)
if err != nil {
return nil, err
}
json.Unmarshal(body, &resp)
resp.Code = int32(200)
resp.Msg = "Success"
if statusCode == 200 {
json.Unmarshal(body, &resp.Resp200)
} else {
json.Unmarshal(body, &resp.Resp400)
}
return &resp, nil
}

View File

@ -42,13 +42,14 @@ func (l *ExportTaskLogic) ExportTask(in *modelarts.ExportTaskReq) (*modelarts.Ex
}
payload := strings.NewReader(string(reqByte))
token := common.GetToken()
body, err := tool.HttpClient(tool.POST, url, payload, token)
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, url, payload, token)
if err != nil {
return nil, err
}
json.Unmarshal(body, &resp)
resp.Code = int32(200)
resp.Msg = "Success"
if statusCode == 200 {
json.Unmarshal(body, &resp.Resp200)
} else {
json.Unmarshal(body, &resp.Resp400)
}
return &resp, nil
}

View File

@ -36,13 +36,15 @@ func (l *ListClustersLogic) ListClusters(in *modelarts.ListClustersReq) (*modela
var resp modelarts.ListClustersResp
url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/clusters"
token := common.GetToken()
body, err := tool.HttpClient(tool.GET, url, nil, token)
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, url, nil, token)
if err != nil {
return nil, err
}
// var resp Pppp
json.Unmarshal(body, &resp)
resp.Code = int32(200)
resp.Msg = "Success"
if statusCode == 200 {
json.Unmarshal(body, &resp.Resp200)
} else {
json.Unmarshal(body, &resp.Resp400)
}
return &resp, nil
}

View File

@ -36,12 +36,15 @@ func (l *ListServicesLogic) ListServices(in *modelarts.ListServicesReq) (*modela
url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/services"
token := common.GetToken()
body, err := tool.HttpClient(tool.GET, url, nil, token)
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, url, nil, token)
if err != nil {
return nil, err
}
json.Unmarshal(body, &resp)
resp.Code = int32(200)
resp.Msg = "Success"
if statusCode == 200 {
json.Unmarshal(body, &resp.Resp200)
} else {
json.Unmarshal(body, &resp.Resp400)
}
return &resp, nil
}

View File

@ -35,12 +35,15 @@ func (l *ShowServiceLogic) ShowService(in *modelarts.ShowServiceReq) (*modelarts
var resp modelarts.ShowServiceResp
url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/services/" + in.ServiceId
token := common.GetToken()
body, err := tool.HttpClient(tool.GET, url, nil, token)
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, url, nil, token)
if err != nil {
return nil, err
}
json.Unmarshal(body, &resp)
resp.Code = int32(200)
resp.Msg = "Success"
if statusCode == 200 {
json.Unmarshal(body, &resp.Resp200)
} else {
json.Unmarshal(body, &resp.Resp400)
}
return &resp, nil
}

File diff suppressed because it is too large Load Diff

View File

@ -52,6 +52,8 @@ type (
CreateProcessorTaskResp = modelarts.CreateProcessorTaskResp
CreateServiceReq = modelarts.CreateServiceReq
CreateServiceResp = modelarts.CreateServiceResp
CreateServiceResp200 = modelarts.CreateServiceResp200
CreateServiceResp400 = modelarts.CreateServiceResp400
CreateTrainingJobConfigReq = modelarts.CreateTrainingJobConfigReq
CreateTrainingJobConfigResp = modelarts.CreateTrainingJobConfigResp
CreateTrainingJobReq = modelarts.CreateTrainingJobReq
@ -77,6 +79,8 @@ type (
DeleteModelResponseFailedList = modelarts.DeleteModelResponseFailedList
DeleteServiceReq = modelarts.DeleteServiceReq
DeleteServiceResp = modelarts.DeleteServiceResp
DeleteServiceResp200 = modelarts.DeleteServiceResp200
DeleteServiceResp400 = modelarts.DeleteServiceResp400
DeleteTrainingJobConfigReq = modelarts.DeleteTrainingJobConfigReq
DeleteTrainingJobConfigResp = modelarts.DeleteTrainingJobConfigResp
DeleteTrainingJobReq = modelarts.DeleteTrainingJobReq
@ -92,6 +96,8 @@ type (
EngineAlRq = modelarts.EngineAlRq
EngineCreateTraining = modelarts.EngineCreateTraining
ExportParams = modelarts.ExportParams
ExportTaskDataResp200 = modelarts.ExportTaskDataResp200
ExportTaskDataResp400 = modelarts.ExportTaskDataResp400
ExportTaskReq = modelarts.ExportTaskReq
ExportTaskResp = modelarts.ExportTaskResp
ExportTaskStatus = modelarts.ExportTaskStatus
@ -136,6 +142,8 @@ type (
ListAlgorithmsResp = modelarts.ListAlgorithmsResp
ListClustersReq = modelarts.ListClustersReq
ListClustersResp = modelarts.ListClustersResp
ListClustersResp200 = modelarts.ListClustersResp200
ListClustersResp400 = modelarts.ListClustersResp400
ListImportTasksReq = modelarts.ListImportTasksReq
ListImportTasksResp = modelarts.ListImportTasksResp
ListModelReq = modelarts.ListModelReq
@ -146,6 +154,8 @@ type (
ListServices = modelarts.ListServices
ListServicesReq = modelarts.ListServicesReq
ListServicesResp = modelarts.ListServicesResp
ListServicesResp200 = modelarts.ListServicesResp200
ListServicesResp400 = modelarts.ListServicesResp400
ListTrainingJobConfigReq = modelarts.ListTrainingJobConfigReq
ListTrainingJobConfigResp = modelarts.ListTrainingJobConfigResp
ListTrainingJobsreq = modelarts.ListTrainingJobsreq
@ -215,6 +225,8 @@ type (
ShowModelResp = modelarts.ShowModelResp
ShowServiceReq = modelarts.ShowServiceReq
ShowServiceResp = modelarts.ShowServiceResp
ShowServiceResp200 = modelarts.ShowServiceResp200
ShowServiceResp400 = modelarts.ShowServiceResp400
SourceInfo = modelarts.SourceInfo
Spec = modelarts.Spec
Specs = modelarts.Specs

View File

@ -49,28 +49,28 @@ message TokenResp{
/******************auth end*************************/
/******************find datasetList start*************************/
message datasetReq{
string project_id = 1;
message DatasetReq{
string project_id = 1; // @gotags: copier:"ProjectId"
}
message datasetResp{
string total_number = 1; // @gotags: copier:"TotalNumber"
message DatasetResp{
uint32 total_number = 1; // @gotags: copier:"TotalNumber"
repeated Datasets datasets =2; // @gotags: copier:"Datasets"
}
message Datasets{
string dataset_id =1;
string data_format =2;
DataSources data_sources =3;
int32 dataset_format =4;
string dataset_name =5;
int32 dataset_type =6;
bool import_data =7;
string dataset_id =1; // @gotags: copier:"DatasetId"
string data_format =2; // @gotags: copier:"DataFormat"
DataSources data_sources =3; // @gotags: copier:"DataSources"
int32 dataset_format =4; // @gotags: copier:"DatasetFormat"
string dataset_name =5; // @gotags: copier:"DatasetName"
int32 dataset_type =6; // @gotags: copier:"DatasetType"
bool import_data =7; // @gotags: copier:"ImportData"
}
message DataSources{
string data_path =1;
int32 data_type =2;
string data_path =1; // @gotags: copier:"DataPath"
int32 data_type =2; // @gotags: copier:"DataType"
}
/******************find datasetList end*************************/
@ -883,22 +883,27 @@ message ExportTaskReq{
}
message ExportTaskResp{
ExportTaskDataResp200 resp200 = 1; // @gotags: copier:"Resp200"
ExportTaskDataResp400 resp400 = 2; // @gotags: copier:"Resp400"
}
message ExportTaskDataResp200{
uint32 create_time = 1; // @gotags: copier:"CreateTime"
string error_code = 2; // @gotags: copier:"ErrorCode"
string error_msg = 3; // @gotags: copier:"ErrorMsg"
int64 export_format = 4; // @gotags: copier:"ExportFormat"
ExportParams export_params = 5; // @gotags: copier:"ExportParams"
int32 finished_sample_count = 6; // @gotags: copier:"FinishedSampleCount"
string path = 7; // @gotags: copier:"Path"
float progress = 8; // @gotags: copier:"Progress"
string status = 9; // @gotags: copier:"Status"
string task_id = 10; // @gotags: copier:"TaskId"
int64 total_sample_count = 11; // @gotags: copier:"TotalSampleCount"
uint32 update_time = 12; // @gotags: copier:"UpdateTime"
string version_format = 13; // @gotags: copier:"VersionFormat"
string version_id = 14; // @gotags: copier:"VersionId"
int32 code = 15; // @gotags: copier:"Code"
string msg = 16; // @gotags: copier:"Msg"
int64 export_format = 2; // @gotags: copier:"ExportFormat"
ExportParams export_params = 3; // @gotags: copier:"ExportParams"
int32 finished_sample_count = 4; // @gotags: copier:"FinishedSampleCount"
string path = 5; // @gotags: copier:"Path"
float progress = 6; // @gotags: copier:"Progress"
string status = 7; // @gotags: copier:"Status"
string task_id = 8; // @gotags: copier:"TaskId"
int64 total_sample_count = 9; // @gotags: copier:"TotalSampleCount"
uint32 update_time = 10; // @gotags: copier:"UpdateTime"
string version_format = 11; // @gotags: copier:"VersionFormat"
string version_id = 12; // @gotags: copier:"VersionId"
}
message ExportTaskDataResp400{
string error_code = 1; // @gotags: copier:"ErrorCode"
string error_msg = 2; // @gotags: copier:"ErrorMsg"
}
message ExportParams{
@ -958,87 +963,86 @@ message SearchProp {
/******************Get Export Tasks Of Dataset Start*************************/
message GetExportTasksOfDatasetReq{
string dataset_id = 1;
string project_id = 2;
int32 export_type = 3;
int32 limit = 4;
int32 offset = 5;
string dataset_id = 1; // @gotags: copier:"DatasetId"
string project_id = 2; // @gotags: copier:"ProjectId"
int32 export_type = 3; // @gotags: copier:"ExportType"
int32 limit = 4; // @gotags: copier:"Limit"
int32 offset = 5; // @gotags: copier:"Offset"
}
message GetExportTasksOfDatasetResp{
uint32 code = 1; // @gotags: copier:"Code"
uint32 create_time = 2;
string error_code = 3;
string error_msg = 4;
int32 export_format = 5;
ExportParams export_params = 6;
repeated ExportTaskStatus export_tasks = 7;
int32 export_type = 8;
int32 finished_sample_count = 9;
string path = 10;
float progress = 11;
string status = 12;
string task_id = 13;
int64 total_count = 14;
int64 total_sample = 15;
uint32 update_time = 16;
string version_format = 17;
string version_id = 18;
uint32 create_time = 2; // @gotags: copier:"CreateTime"
string error_code = 3; // @gotags: copier:"ErrorCode"
string error_msg = 4; // @gotags: copier:"ErrorMsg"
int32 export_format = 5; // @gotags: copier:"ExportFormat"
ExportParams export_params = 6; // @gotags: copier:"ExportParams"
repeated ExportTaskStatus export_tasks = 7; // @gotags: copier:"ExportTasks"
int32 export_type = 8; // @gotags: copier:"ExportType"
int32 finished_sample_count = 9; // @gotags: copier:"FinishedSampleCount"
string path = 10; // @gotags: copier:"Path"
float progress = 11; // @gotags: copier:"Progress"
string status = 12; // @gotags: copier:"Status"
string task_id = 13; // @gotags: copier:"TaskId"
int64 total_count = 14; // @gotags: copier:"TotalCount"
int64 total_sample = 15; // @gotags: copier:"TotalSample"
uint32 update_time = 16; // @gotags: copier:"UpdateTime"
string version_format = 17; // @gotags: copier:"VersionFormat"
string version_id = 18; // @gotags: copier:"VersionId"
string msg = 19; // @gotags: copier:"Msg"
}
message ExportTaskStatus {
uint32 code = 1;
uint32 create_time = 2;
string error_code = 3;
string error_msg = 4;
int32 export_format = 5;
ExportParams export_params = 6;
int32 export_type = 7;
int32 finished_sample_count = 8;
string path = 9;
float progress = 10;
string status = 11;
string task_id = 12;
int64 total_count = 13;
int64 total_sample = 14;
uint32 update_time = 15;
string version_format = 16;
string version_id = 17;
uint32 code = 1; // @gotags: copier:"Code"
uint32 create_time = 2; // @gotags: copier:"CreateTime"
string error_code = 3; // @gotags: copier:"ErrorCode"
string error_msg = 4; // @gotags: copier:"ErrorMsg"
int32 export_format = 5; // @gotags: copier:"ExportFormat"
ExportParams export_params = 6; // @gotags: copier:"ExportParams"
int32 export_type = 7; // @gotags: copier:"ExportType"
int32 finished_sample_count = 8; // @gotags: copier:"FinishedSampleCount"
string path = 9; // @gotags: copier:"Path"
float progress = 10; // @gotags: copier:"Progress"
string status = 11; // @gotags: copier:"Status"
string task_id = 12; // @gotags: copier:"TaskId"
int64 total_count = 13; // @gotags: copier:"TotalCount"
int64 total_sample = 14; // @gotags: copier:"TotalSample"
uint32 update_time = 15; // @gotags: copier:"UpdateTime"
string version_format = 16; // @gotags: copier:"VersionFormat"
string version_id = 17; // @gotags: copier:"VersionId"
}
/******************Get Export Tasks Of Dataset End*************************/
/******************Get Export Task Status Of Dataset Start*************************/
message GetExportTaskStatusOfDatasetReq{
string resource_id = 1;
string project_id = 2;
string task_id = 3;
string resource_id = 1; // @gotags: copier:"ResourceId"
string project_id = 2; // @gotags: copier:"ProjectId"
string task_id = 3; // @gotags: copier:"TaskId"
}
message GetExportTaskStatusOfDatasetResp{
uint32 code = 1; // @gotags: copier:"Code"
uint32 create_time = 2;
string error_code = 3;
string error_msg = 4;
int32 export_format = 5;
ExportParams export_params = 6;
repeated ExportTaskStatus export_tasks = 7;
int32 export_type = 8;
int32 finished_sample_count = 9;
string path = 10;
float progress = 11;
string status = 12;
string task_id = 13;
int64 total_count = 14;
int64 total_sample = 15;
uint32 update_time = 16;
string version_format = 17;
string version_id = 18;
uint32 create_time = 2; // @gotags: copier:"CreateTime"
string error_code = 3; // @gotags: copier:"ErrorCode"
string error_msg = 4; // @gotags: copier:"ErrorMsg"
int32 export_format = 5; // @gotags: copier:"ExportFormat"
ExportParams export_params = 6; // @gotags: copier:"ExportParams"
repeated ExportTaskStatus export_tasks = 7; // @gotags: copier:"ExportTasks"
int32 export_type = 8; // @gotags: copier:"ExportType"
int32 finished_sample_count = 9; // @gotags: copier:"FinishedSampleCount"
string path = 10; // @gotags: copier:"Path"
float progress = 11; // @gotags: copier:"Progress"
string status = 12; // @gotags: copier:"Status"
string task_id = 13; // @gotags: copier:"TaskId"
int64 total_count = 14; // @gotags: copier:"TotalCount"
int64 total_sample = 15; // @gotags: copier:"TotalSample"
uint32 update_time = 16; // @gotags: copier:"UpdateTime"
string version_format = 17; // @gotags: copier:"VersionFormat"
string version_id = 18; // @gotags: copier:"VersionId"
string msg = 19; // @gotags: copier:"Msg"
}
/******************List Services End*************************/
/******************Create Processor Task Start*************************/
message CreateProcessorTaskReq{
string project_id = 1;
@ -1057,6 +1061,7 @@ message CreateProcessorTaskReq{
message CreateProcessorTaskResp{
int32 code = 1; // @gotags: copier:"Code"
string task_id = 2;
string msg = 3;
}
message ProcessorDataSource{
@ -1360,14 +1365,19 @@ message CreateServiceReq{
string subnet_network_id = 9; // @gotags: copier:"SubnetNetworkId"
repeated ServiceConfig config = 10; // @gotags: copier:"Config"
string project_id = 11; // @gotags: copier:"ProjectId"
}
message CreateServiceResp{
CreateServiceResp200 resp200 = 1; //@gotags: copier:"Resp200"
CreateServiceResp400 resp400 = 2; //@gotags: copier:"Resp400"
}
message CreateServiceResp200{
string service_id = 1; // @gotags: copier:"ServiceId"
repeated string resource_ids = 2; // @gotags: copier:"ResourceIds"
int32 code = 3; // @gotags: copier:"Code"
string msg = 4; //@gotags: copier:"Msg"
}
message CreateServiceResp400{
string error_code = 1; //@gotags: copier:"ErrorCode"
string error_msg = 2; //@gotags: copier:"ErrorMsg"
}
message Scheduler{
@ -1410,9 +1420,17 @@ message DeleteServiceReq{
}
message DeleteServiceResp{
string msg = 1; // @gotags: copier:"Msg"
int32 code = 2; // @gotags: copier:"Code"
DeleteServiceResp200 resp200 = 1; //@gotags: copier:"Resp200"
DeleteServiceResp400 resp400 = 2; //@gotags: copier:"Resp400"
}
message DeleteServiceResp200{
}
message DeleteServiceResp400{
string error_code = 1; //@gotags: copier:"ErrorCode"
string error_msg = 2; //@gotags: copier:"ErrorMsg"
}
/******************Delete Service End*************************/
/******************Show Service Start*************************/
@ -1422,6 +1440,10 @@ message ShowServiceReq{
}
message ShowServiceResp{
ShowServiceResp200 resp200 = 1; //@gotags: copier:"Resp200"
ShowServiceResp400 resp400 = 2; //@gotags: copier:"Resp400"
}
message ShowServiceResp200{
uint32 failed_times = 1; // @gotags: copier:"FailedTimes"
string owner = 2; // @gotags: copier:"Owner"
int32 due_time = 3; // @gotags: copier:"DueTime"
@ -1450,14 +1472,15 @@ message ShowServiceResp{
string vpc_id = 26; // @gotags: copier:"VpcId"
string subnet_network_id = 27; // @gotags: copier:"SubnetNetworkId"
string security_group_id = 28; // @gotags: copier:"SecurityGroupId"
string error_msg = 29; // @gotags: copier:"ErrorMsg"
repeated QueryServiceConfig config = 30; // @gotags: copier:"Config"
repeated QueryServiceConfig config = 29; // @gotags: copier:"Config"
string debug_url = 30; // @gotags: copier:"DebugUrl"
string access_address = 31; // @gotags: copier:"AccessAddress"
string bind_access_address = 32; // @gotags: copier:"BindAccessAddress"
string update_time = 33; // @gotags: copier:"UpdateTime"
string debug_url = 34; // @gotags: copier:"DebugUrl"
string msg = 35; // @gotags: copier:"Msg"
int32 code = 36; // @gotags: copier:"Code"
}
message ShowServiceResp400{
string error_code = 1; //@gotags: copier:"ErrorCode"
string error_msg = 2; //@gotags: copier:"ErrorMsg"
}
message QueryServiceConfig{
@ -1502,11 +1525,17 @@ message ListServicesReq{
}
message ListServicesResp{
int32 code = 1; // @gotags: copier:"Code"
int32 total_count = 2; // @gotags: copier:"TotalCount"
int32 count = 3; // @gotags: copier:"Count"
repeated ListServices services = 4; // @gotags: copier:"Services"
string msg = 5; // @gotags: copier:"Msg"
ListServicesResp200 resp200 = 1; //@gotags: copier:"Resp200"
ListServicesResp400 resp400 = 2; //@gotags: copier:"Resp400"
}
message ListServicesResp200{
int32 total_count = 1; // @gotags: copier:"TotalCount"
int32 count = 2; // @gotags: copier:"Count"
repeated ListServices services = 3; // @gotags: copier:"Services"
}
message ListServicesResp400{
string error_code = 1; //@gotags: copier:"ErrorCode"
string error_msg = 2; //@gotags: copier:"ErrorMsg"
}
message ListServices{
@ -1548,12 +1577,17 @@ message ListClustersReq{
}
message ListClustersResp{
int32 code = 1; // @gotags: copier:"Code"
ListClustersResp200 resp200 = 1; //@gotags: copier:"Resp200"
ListClustersResp400 resp400 = 2; //@gotags: copier:"Resp400"
}
message ListClustersResp200{
int32 count = 2; // @gotags: copier:"Count"
repeated Cluster clusters= 3; // @gotags: copier:"Clusters"
string msg = 4; // @gotags: copier:"Msg"
}
message ListClustersResp400{
string error_code = 1; //@gotags: copier:"ErrorCode"
string error_msg = 2; //@gotags: copier:"ErrorMsg"
}
message Cluster{
string owner = 1; // @gotags: copier:"Owner"
string cluster_name = 2; // @gotags: copier:"ClusterName"
@ -1882,7 +1916,7 @@ service ModelArts {
//get modelarts Token
rpc GetToken(TokenReq) returns (TokenResp);
//get modelarts Token
rpc GetDatasetList(datasetReq) returns (datasetResp);
rpc GetDatasetList(DatasetReq) returns (DatasetResp);
//create DateSet
rpc CreateDataSet(CreateDataSetReq) returns (CreateDataSetResq);
//create DateSet

View File

@ -133,3 +133,20 @@ func convertStructToQueryUrl[T any](request *http.Request, param T) {
request.URL.RawQuery = query.Encode()
}
func HttpClientWithBodyAndCode(method string, url string, payload io.Reader, token string) (int, []byte, error) {
request, err := http.NewRequest(method, url, payload)
request.Header.Add("Content-Type", "application/json")
request.Header.Add("User-Agent", "API Explorer")
request.Header.Add("x-auth-token", token)
client := &http.Client{}
res, err := client.Do(request)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
return res.StatusCode, body, err
}