Compare commits

...

55 Commits

Author SHA1 Message Date
qiwang 939c3144cd update the models,add cmd of modelarts 2024-09-09 15:25:01 +08:00
devad 44aa133bd1 Delete internal/util/maven.tar 2024-09-09 11:04:15 +08:00
qiwang b4b5ba7701 update the models,add cmd of modelarts 2024-09-09 10:46:16 +08:00
qiwang 07ff355339 update the models of modelarts 2024-09-05 17:29:54 +08:00
qiwang 2d501c2e27 update the images of modelarts 2024-09-04 09:29:34 +08:00
qiwang 89bdb15637 update the model of modelarts 2024-08-31 11:15:31 +08:00
qiwang 36810865cc update the Specifications of modelarts 2024-08-29 11:21:35 +08:00
qiwang 54ce66d377 Complete the npu of modelarts 2024-08-26 09:04:27 +08:00
qiwang 1727d09f03 Complete the npu of modelarts 2024-07-24 17:56:08 +08:00
qiwang f74b47ca20 Complete the showservice of modelarts 2024-07-23 14:02:34 +08:00
qiwang 50d17f36d0 Complete the updateservice of modelarts 2024-07-22 17:20:17 +08:00
qiwang 589aeac5df Complete the resource flavor of modelarts 2024-07-20 11:01:45 +08:00
qiwang fcc8341130 Complete the deployment service of modelarts 2024-07-15 17:38:11 +08:00
qiwang e32920dde2 Merge remote-tracking branch 'origin/master' 2024-07-15 17:33:13 +08:00
qiwang bdf026c621 Complete the deployment service of modelarts 2024-07-15 17:32:17 +08:00
jagger ef1b817351 fix ci/cd bug 2024-07-12 12:17:52 +08:00
jagger 9f0aeac741 fix ci/cd bug 2024-07-12 12:02:38 +08:00
jagger c8db20a535 fix ci/cd bug 2024-07-12 11:50:28 +08:00
qiwang 9301ca1b74 Start and stop the online tasks of completing modelarts 2024-07-11 17:32:12 +08:00
qiwang 9e63acee17 Complete the service deployment specification interface supported by modelarts query 2024-07-11 15:18:30 +08:00
qiwang 527d16908b Merge remote-tracking branch 'origin/master' 2024-07-11 10:09:14 +08:00
qiwang 869d7cbe3c add modelarts interface 2024-07-11 10:08:46 +08:00
devad b8e06a6b5a refactor: .devops/dev.yml 2024-07-02 00:46:39 +00:00
jagger e70d80ad53 fix bugs 2024-07-01 16:14:06 +08:00
devad c01f34bd1d refactor: .devops/dev.yml 2024-06-28 09:48:45 +00:00
qiwang e0abad034f update modelarts access_address 2024-06-26 09:53:47 +08:00
qiwang e5dddd8d70 update modelarts access_address 2024-06-25 21:19:24 +08:00
qiwang 3e94bb4128 update modelarts access_address 2024-06-25 20:32:16 +08:00
qiwang e18c0e682b Merge remote-tracking branch 'origin/master'
# Conflicts:
#	internal/logic/modelartsservice/imagereasoningurllogic.go
2024-06-25 19:11:26 +08:00
qiwang 2e95367986 update modelarts access_address 2024-06-25 19:10:37 +08:00
zhouqunjie 723deae32b fix :service name 2024-06-25 14:12:05 +08:00
zhouqunjie d7b82fafc7 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	internal/logic/modelartsservice/imagereasoningurllogic.go
2024-06-25 14:09:03 +08:00
zhouqunjie 75be68b5c1 remove url suffix 2024-06-25 14:08:00 +08:00
qiwang 18fb2dfbdf update modelarts access_address 2024-06-25 10:57:12 +08:00
qiwang 94de0bdcf6 update modelarts access_address 2024-06-24 18:06:03 +08:00
qiwang 33e2fdc655 update modelarts access_address 2024-06-22 15:42:44 +08:00
qiwang 5dcad373c1 add modelarts reasoning 2024-06-20 14:57:02 +08:00
qiwang 82e6f25c16 add modelarts reasoning 2024-06-20 11:21:42 +08:00
qiwang 2e53f5e2bf Merge remote-tracking branch 'origin/master' 2024-06-14 17:38:07 +08:00
qiwang 81f1a0de01 update modelarts 2024-06-14 17:37:35 +08:00
jagger d5ad96a5bd fix ci/cd bug 2024-06-11 16:54:40 +08:00
jagger 0542d85f67 fix ci/cd bug 2024-06-11 16:50:37 +08:00
jagger d53ffd4df1 fix ci/cd bug 2024-06-11 16:46:54 +08:00
jagger 689bb339a9 feat TrainingJobLogsPreview 2024-05-15 08:52:24 +08:00
nudtpc 15e13a7b57 Merge pull request 'fix' (#1) from devad/pcm-modelarts:master into master 2024-05-14 10:32:33 +08:00
jagger 9fdff34b1c 🐛 Fixed 2024-05-13 15:32:01 +08:00
devad 724c7c4cc0 🐛 Fixed 2023-11-01 16:51:49 +08:00
devad f6fd0505d2 🐛 Fixed CreateTrainingJob without error codes 2023-10-24 19:55:30 +08:00
devad fbc4c19408 🐛 Fixed CreateTrainingJob environments bugs 2023-10-24 18:37:55 +08:00
devad 3f25f907cb 🐛 Fixed ListReposDetails without error codes 2023-10-24 16:16:50 +08:00
devad 0f2270b93e 🐛 Fixed GetTrainingJobs without error codes
Signed-off-by: devad <cossjie@foxmail.com>
2023-10-24 11:34:09 +08:00
devad c1b0d3670b Add GetTrainingJobs fun
Signed-off-by: devad <cossjie@foxmail.com>
2023-10-24 10:54:11 +08:00
devad d862b91bb0 Delete '.idea/.gitignore' 2023-10-24 09:21:03 +08:00
devad 6f6be12a98 📝 update README.md 2023-10-24 09:08:14 +08:00
devad 98cc47d40d fix 2023-10-24 08:58:37 +08:00
148 changed files with 23838 additions and 13072 deletions

65
.devops/阿里云.yml Normal file
View File

@ -0,0 +1,65 @@
version: 2
name: 阿里云
description: ""
global:
concurrent: 1
param:
- ref: ssh_host
name: ""
value: '"47.92.39.128"'
required: false
type: STRING
hidden: true
- ref: ssh_user
name: ""
value: '"root"'
required: false
type: STRING
hidden: true
workflow:
- ref: start
name: 开始
task: start
- ref: end
name: 结束
task: end
needs:
- ssh_cmd_0
- ref: git_clone_0
name: git clone
task: git_clone@1.2.9
input:
remote_url: '"https://gitlink.org.cn/JointCloud/pcm-modelarts.git"'
ref: '"refs/heads/master"'
commit_id: '""'
depth: 1
needs:
- start
- ref: docker_image_build_0
name: docker镜像构建
task: docker_image_build@1.6.0
input:
docker_username: ((aly.docker_user))
docker_password: ((aly.docker_password))
image_name: '"registry.cn-hangzhou.aliyuncs.com/jcce/pcm-modelarts"'
image_tag: '"latest"'
registry_address: '"registry.cn-hangzhou.aliyuncs.com"'
docker_file: '"Dockerfile"'
docker_build_path: git_clone_0.git_path
workspace: git_clone_0.git_path
image_push: true
build_args: '""'
needs:
- git_clone_0
- ref: ssh_cmd_0
name: ssh执行命令
task: ssh_cmd@1.1.1
input:
ssh_private_key: ((aly.ssh_private_key))
ssh_ip: global.ssh_host
ssh_port: '"22"'
ssh_user: global.ssh_user
ssh_cmd: '"kubectl rollout restart deployment pcm-modelarts -n ns-admin"'
needs:
- docker_image_build_0

30
.gitignore vendored Normal file
View File

@ -0,0 +1,30 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
coverage.txt
# buf for protobuf
buf.lock
# idea project
.idea/
.vscode/
# config file
configs/tenanter.yaml
log/
/go_build_gitlink_org_cn_JCCE_PCM
etc/
/uploads/
/vendor

8
.idea/.gitignore vendored
View File

@ -1,8 +0,0 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -1,20 +1,28 @@
FROM alpine:3.16.2
WORKDIR /home
FROM registry.cn-hangzhou.aliyuncs.com/jcce-images/golang:1.22.4-alpine3.20 AS builder
# 修改alpine源为上海交通大学
WORKDIR /app
COPY . .
ENV GO111MODULE=on GOPROXY=https://goproxy.cn,direct
RUN go mod download
RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o pcm-modelarts
FROM registry.cn-hangzhou.aliyuncs.com/jcce-images/alpine:3.20
WORKDIR /app
#修改alpine源为上海交通大学
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.sjtug.sjtu.edu.cn/g' /etc/apk/repositories && \
apk update && \
apk upgrade && \
apk add --no-cache ca-certificates && update-ca-certificates && \
apk add --update tzdata && \
rm -rf /var/cache/apk/*
COPY pcm-modelarts /home/
COPY etc/pcmmodelarts.yaml /home/
COPY --from=builder /app/pcm-modelarts .
COPY --from=builder /app/etc/pcmmodelarts.yaml .
ENV TZ=Asia/Shanghai
EXPOSE 2003
EXPOSE 2002
ENTRYPOINT ./pcm-modelarts -f pcmmodelarts.yaml
ENTRYPOINT ./pcm-modelarts --f pcmmodelarts.yaml

View File

@ -1,2 +1,9 @@
rpc-gen:
goctl rpc protoc ./pb/*.proto --go_out=./ --go-grpc_out=./ --zrpc_out=.
goctl rpc protoc ./pb/*.proto --go_out=./ --go-grpc_out=./ --zrpc_out=. -m
protoc-go-inject-tag -input="modelarts/*.pb.go" -remove_tag_comment
Generate:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o pcm-modelarts pcmmodelarts.go
Generate-ARM64:
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 GOARM=7 go build -o pcm-modelarts pcmmodelarts.go

View File

@ -1,2 +1,3 @@
# pcm-participant-modelarts
# pcm-modelarts
etc文件下[pcmmodelarts.yaml](etc%2Fpcmmodelarts.yaml)配置文件的值请根据实际情况修改

View File

@ -0,0 +1,473 @@
// Code generated by goctl. DO NOT EDIT.
// Source: pcm-modelarts.proto
package imagesservice
import (
"context"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
type (
ActionProgress = modelarts.ActionProgress
AdvancedConfigAl = modelarts.AdvancedConfigAl
AlgoConfigs = modelarts.AlgoConfigs
Algorithm = modelarts.Algorithm
AlgorithmResponse = modelarts.AlgorithmResponse
Algorithms = modelarts.Algorithms
AnnotationFormatConfig = modelarts.AnnotationFormatConfig
AttributesAlRq = modelarts.AttributesAlRq
Auth = modelarts.Auth
AutoSearch = modelarts.AutoSearch
AutoSearchAlgoConfigParameter = modelarts.AutoSearchAlgoConfigParameter
Billing = modelarts.Billing
ChatglmReasoningReq = modelarts.ChatglmReasoningReq
ChatglmReasoningResp = modelarts.ChatglmReasoningResp
Children = modelarts.Children
Cluster = modelarts.Cluster
ClusterNode = modelarts.ClusterNode
CodeTree = modelarts.CodeTree
Config = modelarts.Config
ConfigResponse = modelarts.ConfigResponse
Constraint = modelarts.Constraint
ConstraintAlRp = modelarts.ConstraintAlRp
ConstraintAlRq = modelarts.ConstraintAlRq
ConstraintCreateTraining = modelarts.ConstraintCreateTraining
ContainerHooks = modelarts.ContainerHooks
ContainerHooksResp = modelarts.ContainerHooksResp
Cpu = modelarts.Cpu
CreateAlgorithmReq = modelarts.CreateAlgorithmReq
CreateAlgorithmResp = modelarts.CreateAlgorithmResp
CreateDataSetReq = modelarts.CreateDataSetReq
CreateDataSetResq = modelarts.CreateDataSetResq
CreateModelReq = modelarts.CreateModelReq
CreateModelRequestInferParams = modelarts.CreateModelRequestInferParams
CreateModelRequestModelApis = modelarts.CreateModelRequestModelApis
CreateModelRequestTemplateInput = modelarts.CreateModelRequestTemplateInput
CreateModelResp = modelarts.CreateModelResp
CreateNotebookParam = modelarts.CreateNotebookParam
CreateNotebookReq = modelarts.CreateNotebookReq
CreateNotebookResp = modelarts.CreateNotebookResp
CreateProcessorTaskReq = modelarts.CreateProcessorTaskReq
CreateProcessorTaskResp = modelarts.CreateProcessorTaskResp
CreateRepoReq = modelarts.CreateRepoReq
CreateServiceReq = modelarts.CreateServiceReq
CreateServiceResp = modelarts.CreateServiceResp
CreateTrainingJobConfigReq = modelarts.CreateTrainingJobConfigReq
CreateTrainingJobConfigResp = modelarts.CreateTrainingJobConfigResp
CreateTrainingJobReq = modelarts.CreateTrainingJobReq
CreateTrainingJobResp = modelarts.CreateTrainingJobResp
CreateTrainingJobResp400 = modelarts.CreateTrainingJobResp400
CreateVisualizationJobParam = modelarts.CreateVisualizationJobParam
CreateVisualizationJobReq = modelarts.CreateVisualizationJobReq
CreateVisualizationJobResp = modelarts.CreateVisualizationJobResp
CustomHooks = modelarts.CustomHooks
CustomSpec = modelarts.CustomSpec
DataSetReq = modelarts.DataSetReq
DataSetResp = modelarts.DataSetResp
DataSets = modelarts.DataSets
DataSource = modelarts.DataSource
DataSources = modelarts.DataSources
DataVolumesRes = modelarts.DataVolumesRes
Dataset = modelarts.Dataset
DatasetTra = modelarts.DatasetTra
DeleteAlgorithmsReq = modelarts.DeleteAlgorithmsReq
DeleteAlgorithmsResp = modelarts.DeleteAlgorithmsResp
DeleteDataSetReq = modelarts.DeleteDataSetReq
DeleteDataSetResq = modelarts.DeleteDataSetResq
DeleteImagesReq = modelarts.DeleteImagesReq
DeleteImagesResp = modelarts.DeleteImagesResp
DeleteModelReq = modelarts.DeleteModelReq
DeleteModelResp = modelarts.DeleteModelResp
DeleteModelResponseFailedList = modelarts.DeleteModelResponseFailedList
DeleteRepoReq = modelarts.DeleteRepoReq
DeleteRepoTagReq = modelarts.DeleteRepoTagReq
DeleteServiceReq = modelarts.DeleteServiceReq
DeleteServiceResp = modelarts.DeleteServiceResp
DeleteTrainingJobConfigReq = modelarts.DeleteTrainingJobConfigReq
DeleteTrainingJobConfigResp = modelarts.DeleteTrainingJobConfigResp
DeleteTrainingJobReq = modelarts.DeleteTrainingJobReq
DeleteTrainingJobResp = modelarts.DeleteTrainingJobResp
DescribeProcessorTaskReq = modelarts.DescribeProcessorTaskReq
DescribeProcessorTaskResp = modelarts.DescribeProcessorTaskResp
DetailTrainingJobsReq = modelarts.DetailTrainingJobsReq
Disk = modelarts.Disk
Domain = modelarts.Domain
EndpointsReq = modelarts.EndpointsReq
EndpointsRes = modelarts.EndpointsRes
Engine = modelarts.Engine
EngineAlRp = modelarts.EngineAlRp
EngineAlRq = modelarts.EngineAlRq
EngineCreateTraining = modelarts.EngineCreateTraining
Errors = modelarts.Errors
ExportParams = modelarts.ExportParams
ExportTaskDataResp = modelarts.ExportTaskDataResp
ExportTaskReq = modelarts.ExportTaskReq
ExportTaskStatus = modelarts.ExportTaskStatus
FileData = modelarts.FileData
FileRequest = modelarts.FileRequest
FileResponse = modelarts.FileResponse
FileStatistics = modelarts.FileStatistics
Flavor = modelarts.Flavor
FlavorDetail = modelarts.FlavorDetail
FlavorInfo = modelarts.FlavorInfo
FlavorResponse = modelarts.FlavorResponse
GetExportTaskStatusOfDatasetReq = modelarts.GetExportTaskStatusOfDatasetReq
GetExportTaskStatusOfDatasetResp = modelarts.GetExportTaskStatusOfDatasetResp
GetExportTasksOfDatasetReq = modelarts.GetExportTasksOfDatasetReq
GetExportTasksOfDatasetResp = modelarts.GetExportTasksOfDatasetResp
GetNotebookFlavorsReq = modelarts.GetNotebookFlavorsReq
GetNotebookFlavorsResp = modelarts.GetNotebookFlavorsResp
GetNotebookFlavorsResp_Billing = modelarts.GetNotebookFlavorsResp_Billing
GetNotebookFlavorsResp_Data = modelarts.GetNotebookFlavorsResp_Data
GetNotebookFlavorsResp_Gpu = modelarts.GetNotebookFlavorsResp_Gpu
GetNotebookStorageReq = modelarts.GetNotebookStorageReq
GetNotebookStorageResp = modelarts.GetNotebookStorageResp
GetPoolsRuntimeMetricsReq = modelarts.GetPoolsRuntimeMetricsReq
GetPoolsRuntimeMetricsResp = modelarts.GetPoolsRuntimeMetricsResp
GetPoolsRuntimeMetricsResp_Allocated = modelarts.GetPoolsRuntimeMetricsResp_Allocated
GetPoolsRuntimeMetricsResp_Capacity = modelarts.GetPoolsRuntimeMetricsResp_Capacity
GetPoolsRuntimeMetricsResp_Items = modelarts.GetPoolsRuntimeMetricsResp_Items
GetPoolsRuntimeMetricsResp_Labels = modelarts.GetPoolsRuntimeMetricsResp_Labels
GetPoolsRuntimeMetricsResp_MaxValue = modelarts.GetPoolsRuntimeMetricsResp_MaxValue
GetPoolsRuntimeMetricsResp_Metadata = modelarts.GetPoolsRuntimeMetricsResp_Metadata
GetPoolsRuntimeMetricsResp_Table = modelarts.GetPoolsRuntimeMetricsResp_Table
GetPoolsRuntimeMetricsResp_Value = modelarts.GetPoolsRuntimeMetricsResp_Value
GetPoolsRuntimeMetricsResp_Value1 = modelarts.GetPoolsRuntimeMetricsResp_Value1
GetResourceFlavorsReq = modelarts.GetResourceFlavorsReq
GetResourceFlavorsResp = modelarts.GetResourceFlavorsResp
GetResourceFlavorsResp_DataVolumes = modelarts.GetResourceFlavorsResp_DataVolumes
GetResourceFlavorsResp_Items = modelarts.GetResourceFlavorsResp_Items
GetResourceFlavorsResp_Labels = modelarts.GetResourceFlavorsResp_Labels
GetResourceFlavorsResp_Metadata = modelarts.GetResourceFlavorsResp_Metadata
GetResourceFlavorsResp_Metadata1 = modelarts.GetResourceFlavorsResp_Metadata1
GetResourceFlavorsResp_Npu = modelarts.GetResourceFlavorsResp_Npu
GetResourceFlavorsResp_Phase = modelarts.GetResourceFlavorsResp_Phase
GetResourceFlavorsResp_Spec = modelarts.GetResourceFlavorsResp_Spec
GetResourceFlavorsResp_Status = modelarts.GetResourceFlavorsResp_Status
GetTrainingJobLogsPreviewReq = modelarts.GetTrainingJobLogsPreviewReq
GetTrainingJobLogsPreviewResp = modelarts.GetTrainingJobLogsPreviewResp
GetVisualizationJobParam = modelarts.GetVisualizationJobParam
GetVisualizationJobReq = modelarts.GetVisualizationJobReq
GetVisualizationJobResp = modelarts.GetVisualizationJobResp
Gpu = modelarts.Gpu
GuideDoc = modelarts.GuideDoc
Hooks = modelarts.Hooks
I18NDescription = modelarts.I18NDescription
Identity = modelarts.Identity
Image = modelarts.Image
ImageInfo = modelarts.ImageInfo
ImageReasoningReq = modelarts.ImageReasoningReq
ImageReasoningResp = modelarts.ImageReasoningResp
ImageReasoningUrlReq = modelarts.ImageReasoningUrlReq
ImageReasoningUrlResp = modelarts.ImageReasoningUrlResp
ImportConfig = modelarts.ImportConfig
ImportTaskDataReq = modelarts.ImportTaskDataReq
ImportTaskDataResp = modelarts.ImportTaskDataResp
ImportTasks = modelarts.ImportTasks
Input = modelarts.Input
InputDataInfo = modelarts.InputDataInfo
InputTraining = modelarts.InputTraining
Inputs = modelarts.Inputs
InputsAlRp = modelarts.InputsAlRp
InputsAlRq = modelarts.InputsAlRq
InterfaceType = modelarts.InterfaceType
Items = modelarts.Items
JobAlgorithmResponse = modelarts.JobAlgorithmResponse
JobConfigAl = modelarts.JobConfigAl
JobConfigAlRq = modelarts.JobConfigAlRq
JobMetadata = modelarts.JobMetadata
JobProgress = modelarts.JobProgress
JobResponse = modelarts.JobResponse
Jobs = modelarts.Jobs
Lease = modelarts.Lease
LeaseReq = modelarts.LeaseReq
ListAiEnginesReq = modelarts.ListAiEnginesReq
ListAiEnginesResp = modelarts.ListAiEnginesResp
ListAlgorithmsReq = modelarts.ListAlgorithmsReq
ListAlgorithmsResp = modelarts.ListAlgorithmsResp
ListClustersReq = modelarts.ListClustersReq
ListClustersResp = modelarts.ListClustersResp
ListClustersResp200 = modelarts.ListClustersResp200
ListClustersResp400 = modelarts.ListClustersResp400
ListImagesReq = modelarts.ListImagesReq
ListImagesResp = modelarts.ListImagesResp
ListImagesResp_Data = modelarts.ListImagesResp_Data
ListImportTasksReq = modelarts.ListImportTasksReq
ListImportTasksResp = modelarts.ListImportTasksResp
ListModelReq = modelarts.ListModelReq
ListModelResp = modelarts.ListModelResp
ListNamespacesReq = modelarts.ListNamespacesReq
ListNamespacesResp = modelarts.ListNamespacesResp
ListNotebookParam = modelarts.ListNotebookParam
ListNotebookReq = modelarts.ListNotebookReq
ListNotebookResp = modelarts.ListNotebookResp
ListRepoReq = modelarts.ListRepoReq
ListReposDetailsResp = modelarts.ListReposDetailsResp
ListRepositoryTagsReq = modelarts.ListRepositoryTagsReq
ListRepositoryTagsResp = modelarts.ListRepositoryTagsResp
ListServices = modelarts.ListServices
ListServicesReq = modelarts.ListServicesReq
ListServicesResp = modelarts.ListServicesResp
ListSpecificationsReq = modelarts.ListSpecificationsReq
ListSpecificationsResp = modelarts.ListSpecificationsResp
ListSpecificationsResp_CpuInfo = modelarts.ListSpecificationsResp_CpuInfo
ListSpecificationsResp_GpuInfo = modelarts.ListSpecificationsResp_GpuInfo
ListSpecificationsResp_MemoryInfo = modelarts.ListSpecificationsResp_MemoryInfo
ListSpecificationsResp_NpuInfo = modelarts.ListSpecificationsResp_NpuInfo
ListSpecificationsResp_Specifications = modelarts.ListSpecificationsResp_Specifications
ListTrainingJobConfigReq = modelarts.ListTrainingJobConfigReq
ListTrainingJobConfigResp = modelarts.ListTrainingJobConfigResp
ListTrainingJobsreq = modelarts.ListTrainingJobsreq
ListTrainingJobsresp = modelarts.ListTrainingJobsresp
LogExportPath = modelarts.LogExportPath
LogExportPathCreateTraining = modelarts.LogExportPathCreateTraining
Memory = modelarts.Memory
MetadataAlRp = modelarts.MetadataAlRp
MetadataAlRq = modelarts.MetadataAlRq
MetadataCrAl = modelarts.MetadataCrAl
MetadataS = modelarts.MetadataS
Methods = modelarts.Methods
MetricsPoolsRequest = modelarts.MetricsPoolsRequest
MetricsPoolsResponse = modelarts.MetricsPoolsResponse
MetricsPoolsResponse_SomeMessage = modelarts.MetricsPoolsResponse_SomeMessage
MetricsPoolsResponse_SomeMessage_Allocated = modelarts.MetricsPoolsResponse_SomeMessage_Allocated
MetricsPoolsResponse_SomeMessage_Capacity = modelarts.MetricsPoolsResponse_SomeMessage_Capacity
MetricsPoolsResponse_SomeMessage_Items = modelarts.MetricsPoolsResponse_SomeMessage_Items
MetricsPoolsResponse_SomeMessage_Maxvalue = modelarts.MetricsPoolsResponse_SomeMessage_Maxvalue
MetricsPoolsResponse_SomeMessage_Metadata = modelarts.MetricsPoolsResponse_SomeMessage_Metadata
MetricsPoolsResponse_SomeMessage_Table = modelarts.MetricsPoolsResponse_SomeMessage_Table
MetricsPoolsResponse_SomeMessage_Value = modelarts.MetricsPoolsResponse_SomeMessage_Value
MetricsPoolsResponse_SomeMessage_Value1 = modelarts.MetricsPoolsResponse_SomeMessage_Value1
ModelDependencies = modelarts.ModelDependencies
ModelHealth = modelarts.ModelHealth
ModelInOutputParams = modelarts.ModelInOutputParams
ModelListItem = modelarts.ModelListItem
ModelParamsInfo = modelarts.ModelParamsInfo
ModelSpecification = modelarts.ModelSpecification
MountNotebookStorageParam = modelarts.MountNotebookStorageParam
MountNotebookStorageReq = modelarts.MountNotebookStorageReq
MountNotebookStorageResp = modelarts.MountNotebookStorageResp
NamespaceInfo = modelarts.NamespaceInfo
NamespaceReq = modelarts.NamespaceReq
Nfs = modelarts.Nfs
NotebookResp = modelarts.NotebookResp
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
Packages = modelarts.Packages
Parameter = modelarts.Parameter
ParameterS = modelarts.ParameterS
ParametersAlRp = modelarts.ParametersAlRp
ParametersAlRq = modelarts.ParametersAlRq
ParametersTrainJob = modelarts.ParametersTrainJob
Password = modelarts.Password
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
ReposDetails = modelarts.ReposDetails
RepositoryTags = modelarts.RepositoryTags
Resource = modelarts.Resource
ResourceCreateTraining = modelarts.ResourceCreateTraining
ResourceRequirements = modelarts.ResourceRequirements
Resp = modelarts.Resp
RewardAttrs = modelarts.RewardAttrs
Schedule = modelarts.Schedule
Scheduler = modelarts.Scheduler
SchemaMaps = modelarts.SchemaMaps
Scope = modelarts.Scope
SearchCondition = modelarts.SearchCondition
SearchLabel = modelarts.SearchLabel
SearchLabels = modelarts.SearchLabels
SearchParams = modelarts.SearchParams
SearchProp = modelarts.SearchProp
ServiceConfig = modelarts.ServiceConfig
ShareInfo = modelarts.ShareInfo
ShareInfoAlRp = modelarts.ShareInfoAlRp
ShowAlgorithmByUuidReq = modelarts.ShowAlgorithmByUuidReq
ShowAlgorithmByUuidResp = modelarts.ShowAlgorithmByUuidResp
ShowModelDetail = modelarts.ShowModelDetail
ShowModelReq = modelarts.ShowModelReq
ShowModelResp = modelarts.ShowModelResp
ShowRepositoryReq = modelarts.ShowRepositoryReq
ShowRepositoryResp = modelarts.ShowRepositoryResp
ShowServiceReq = modelarts.ShowServiceReq
ShowServiceResp = modelarts.ShowServiceResp
SourceInfo = modelarts.SourceInfo
Spec = modelarts.Spec
Specs = modelarts.Specs
SpecsC = modelarts.SpecsC
StartNotebookParam = modelarts.StartNotebookParam
StartNotebookReq = modelarts.StartNotebookReq
StartNotebookResp = modelarts.StartNotebookResp
Status = modelarts.Status
StopNotebookReq = modelarts.StopNotebookReq
StopNotebookResp = modelarts.StopNotebookResp
Tags = modelarts.Tags
TagsAlRp = modelarts.TagsAlRp
TaskResponse = modelarts.TaskResponse
TaskStatuses = modelarts.TaskStatuses
Template = modelarts.Template
TemplateParam = modelarts.TemplateParam
TokenReq = modelarts.TokenReq
TokenResp = modelarts.TokenResp
TrainingJobFlavorsReq = modelarts.TrainingJobFlavorsReq
TrainingJobFlavorsResp = modelarts.TrainingJobFlavorsResp
UpdateRepoReq = modelarts.UpdateRepoReq
UpdateServiceReq = modelarts.UpdateServiceReq
UpdateServiceResp = modelarts.UpdateServiceResp
User = modelarts.User
UserNotebookDomain = modelarts.UserNotebookDomain
UserNotebookResp = modelarts.UserNotebookResp
VolumeReq = modelarts.VolumeReq
VolumeRes = modelarts.VolumeRes
Volumes = modelarts.Volumes
Weigou = modelarts.Weigou
WorkPath = modelarts.WorkPath
ImagesService interface {
// CreateNamespace 创建组织
CreateNamespace(ctx context.Context, in *NamespaceReq, opts ...grpc.CallOption) (*Resp, error)
// 查询组织列表
ListNamespaces(ctx context.Context, in *ListNamespacesReq, opts ...grpc.CallOption) (*ListNamespacesResp, error)
// 删除组织
DeleteNamespaces(ctx context.Context, in *NamespaceReq, opts ...grpc.CallOption) (*Resp, error)
// 获取组织详情
ShowNamespace(ctx context.Context, in *NamespaceReq, opts ...grpc.CallOption) (*NamespaceInfo, error)
// 在组织下创建镜像仓库
CreateRepo(ctx context.Context, in *CreateRepoReq, opts ...grpc.CallOption) (*Resp, error)
// 删除组织下的镜像仓库
DeleteRepo(ctx context.Context, in *DeleteRepoReq, opts ...grpc.CallOption) (*Resp, error)
// 查询镜像仓库列表
ListReposDetails(ctx context.Context, in *ListRepoReq, opts ...grpc.CallOption) (*ListReposDetailsResp, error)
// 查询镜像仓库概要信息
ShowRepository(ctx context.Context, in *ShowRepositoryReq, opts ...grpc.CallOption) (*ShowRepositoryResp, error)
// 更新镜像仓库的概要信息
UpdateRepo(ctx context.Context, in *UpdateRepoReq, opts ...grpc.CallOption) (*Resp, error)
// 删除指定tag的镜像
DeleteRepoTag(ctx context.Context, in *DeleteRepoTagReq, opts ...grpc.CallOption) (*Resp, error)
// 查询镜像tag列表
ListRepositoryTags(ctx context.Context, in *ListRepositoryTagsReq, opts ...grpc.CallOption) (*ListRepositoryTagsResp, error)
// 镜像上传
UploadFile(ctx context.Context, in *FileRequest, opts ...grpc.CallOption) (*FileResponse, error)
// 镜像下载
DownloadFile(ctx context.Context, in *FileRequest, opts ...grpc.CallOption) (*FileData, error)
// 查询资源实时利用率
GetMetricsPools(ctx context.Context, in *MetricsPoolsRequest, opts ...grpc.CallOption) (*MetricsPoolsResponse, error)
}
defaultImagesService struct {
cli zrpc.Client
}
)
func NewImagesService(cli zrpc.Client) ImagesService {
return &defaultImagesService{
cli: cli,
}
}
// CreateNamespace 创建组织
func (m *defaultImagesService) CreateNamespace(ctx context.Context, in *NamespaceReq, opts ...grpc.CallOption) (*Resp, error) {
client := modelarts.NewImagesServiceClient(m.cli.Conn())
return client.CreateNamespace(ctx, in, opts...)
}
// 查询组织列表
func (m *defaultImagesService) ListNamespaces(ctx context.Context, in *ListNamespacesReq, opts ...grpc.CallOption) (*ListNamespacesResp, error) {
client := modelarts.NewImagesServiceClient(m.cli.Conn())
return client.ListNamespaces(ctx, in, opts...)
}
// 删除组织
func (m *defaultImagesService) DeleteNamespaces(ctx context.Context, in *NamespaceReq, opts ...grpc.CallOption) (*Resp, error) {
client := modelarts.NewImagesServiceClient(m.cli.Conn())
return client.DeleteNamespaces(ctx, in, opts...)
}
// 获取组织详情
func (m *defaultImagesService) ShowNamespace(ctx context.Context, in *NamespaceReq, opts ...grpc.CallOption) (*NamespaceInfo, error) {
client := modelarts.NewImagesServiceClient(m.cli.Conn())
return client.ShowNamespace(ctx, in, opts...)
}
// 在组织下创建镜像仓库
func (m *defaultImagesService) CreateRepo(ctx context.Context, in *CreateRepoReq, opts ...grpc.CallOption) (*Resp, error) {
client := modelarts.NewImagesServiceClient(m.cli.Conn())
return client.CreateRepo(ctx, in, opts...)
}
// 删除组织下的镜像仓库
func (m *defaultImagesService) DeleteRepo(ctx context.Context, in *DeleteRepoReq, opts ...grpc.CallOption) (*Resp, error) {
client := modelarts.NewImagesServiceClient(m.cli.Conn())
return client.DeleteRepo(ctx, in, opts...)
}
// 查询镜像仓库列表
func (m *defaultImagesService) ListReposDetails(ctx context.Context, in *ListRepoReq, opts ...grpc.CallOption) (*ListReposDetailsResp, error) {
client := modelarts.NewImagesServiceClient(m.cli.Conn())
return client.ListReposDetails(ctx, in, opts...)
}
// 查询镜像仓库概要信息
func (m *defaultImagesService) ShowRepository(ctx context.Context, in *ShowRepositoryReq, opts ...grpc.CallOption) (*ShowRepositoryResp, error) {
client := modelarts.NewImagesServiceClient(m.cli.Conn())
return client.ShowRepository(ctx, in, opts...)
}
// 更新镜像仓库的概要信息
func (m *defaultImagesService) UpdateRepo(ctx context.Context, in *UpdateRepoReq, opts ...grpc.CallOption) (*Resp, error) {
client := modelarts.NewImagesServiceClient(m.cli.Conn())
return client.UpdateRepo(ctx, in, opts...)
}
// 删除指定tag的镜像
func (m *defaultImagesService) DeleteRepoTag(ctx context.Context, in *DeleteRepoTagReq, opts ...grpc.CallOption) (*Resp, error) {
client := modelarts.NewImagesServiceClient(m.cli.Conn())
return client.DeleteRepoTag(ctx, in, opts...)
}
// 查询镜像tag列表
func (m *defaultImagesService) ListRepositoryTags(ctx context.Context, in *ListRepositoryTagsReq, opts ...grpc.CallOption) (*ListRepositoryTagsResp, error) {
client := modelarts.NewImagesServiceClient(m.cli.Conn())
return client.ListRepositoryTags(ctx, in, opts...)
}
// 镜像上传
func (m *defaultImagesService) UploadFile(ctx context.Context, in *FileRequest, opts ...grpc.CallOption) (*FileResponse, error) {
client := modelarts.NewImagesServiceClient(m.cli.Conn())
return client.UploadFile(ctx, in, opts...)
}
// 镜像下载
func (m *defaultImagesService) DownloadFile(ctx context.Context, in *FileRequest, opts ...grpc.CallOption) (*FileData, error) {
client := modelarts.NewImagesServiceClient(m.cli.Conn())
return client.DownloadFile(ctx, in, opts...)
}
// 查询资源实时利用率
func (m *defaultImagesService) GetMetricsPools(ctx context.Context, in *MetricsPoolsRequest, opts ...grpc.CallOption) (*MetricsPoolsResponse, error) {
client := modelarts.NewImagesServiceClient(m.cli.Conn())
return client.GetMetricsPools(ctx, in, opts...)
}

View File

@ -0,0 +1,731 @@
// Code generated by goctl. DO NOT EDIT.
// Source: pcm-modelarts.proto
package modelartsservice
import (
"context"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
type (
ActionProgress = modelarts.ActionProgress
AdvancedConfigAl = modelarts.AdvancedConfigAl
AlgoConfigs = modelarts.AlgoConfigs
Algorithm = modelarts.Algorithm
AlgorithmResponse = modelarts.AlgorithmResponse
Algorithms = modelarts.Algorithms
AnnotationFormatConfig = modelarts.AnnotationFormatConfig
AttributesAlRq = modelarts.AttributesAlRq
Auth = modelarts.Auth
AutoSearch = modelarts.AutoSearch
AutoSearchAlgoConfigParameter = modelarts.AutoSearchAlgoConfigParameter
Billing = modelarts.Billing
ChatglmReasoningReq = modelarts.ChatglmReasoningReq
ChatglmReasoningResp = modelarts.ChatglmReasoningResp
Children = modelarts.Children
Cluster = modelarts.Cluster
ClusterNode = modelarts.ClusterNode
CodeTree = modelarts.CodeTree
Config = modelarts.Config
ConfigResponse = modelarts.ConfigResponse
Constraint = modelarts.Constraint
ConstraintAlRp = modelarts.ConstraintAlRp
ConstraintAlRq = modelarts.ConstraintAlRq
ConstraintCreateTraining = modelarts.ConstraintCreateTraining
ContainerHooks = modelarts.ContainerHooks
ContainerHooksResp = modelarts.ContainerHooksResp
Cpu = modelarts.Cpu
CreateAlgorithmReq = modelarts.CreateAlgorithmReq
CreateAlgorithmResp = modelarts.CreateAlgorithmResp
CreateDataSetReq = modelarts.CreateDataSetReq
CreateDataSetResq = modelarts.CreateDataSetResq
CreateModelReq = modelarts.CreateModelReq
CreateModelRequestInferParams = modelarts.CreateModelRequestInferParams
CreateModelRequestModelApis = modelarts.CreateModelRequestModelApis
CreateModelRequestTemplateInput = modelarts.CreateModelRequestTemplateInput
CreateModelResp = modelarts.CreateModelResp
CreateNotebookParam = modelarts.CreateNotebookParam
CreateNotebookReq = modelarts.CreateNotebookReq
CreateNotebookResp = modelarts.CreateNotebookResp
CreateProcessorTaskReq = modelarts.CreateProcessorTaskReq
CreateProcessorTaskResp = modelarts.CreateProcessorTaskResp
CreateRepoReq = modelarts.CreateRepoReq
CreateServiceReq = modelarts.CreateServiceReq
CreateServiceResp = modelarts.CreateServiceResp
CreateTrainingJobConfigReq = modelarts.CreateTrainingJobConfigReq
CreateTrainingJobConfigResp = modelarts.CreateTrainingJobConfigResp
CreateTrainingJobReq = modelarts.CreateTrainingJobReq
CreateTrainingJobResp = modelarts.CreateTrainingJobResp
CreateTrainingJobResp400 = modelarts.CreateTrainingJobResp400
CreateVisualizationJobParam = modelarts.CreateVisualizationJobParam
CreateVisualizationJobReq = modelarts.CreateVisualizationJobReq
CreateVisualizationJobResp = modelarts.CreateVisualizationJobResp
CustomHooks = modelarts.CustomHooks
CustomSpec = modelarts.CustomSpec
DataSetReq = modelarts.DataSetReq
DataSetResp = modelarts.DataSetResp
DataSets = modelarts.DataSets
DataSource = modelarts.DataSource
DataSources = modelarts.DataSources
DataVolumesRes = modelarts.DataVolumesRes
Dataset = modelarts.Dataset
DatasetTra = modelarts.DatasetTra
DeleteAlgorithmsReq = modelarts.DeleteAlgorithmsReq
DeleteAlgorithmsResp = modelarts.DeleteAlgorithmsResp
DeleteDataSetReq = modelarts.DeleteDataSetReq
DeleteDataSetResq = modelarts.DeleteDataSetResq
DeleteImagesReq = modelarts.DeleteImagesReq
DeleteImagesResp = modelarts.DeleteImagesResp
DeleteModelReq = modelarts.DeleteModelReq
DeleteModelResp = modelarts.DeleteModelResp
DeleteModelResponseFailedList = modelarts.DeleteModelResponseFailedList
DeleteRepoReq = modelarts.DeleteRepoReq
DeleteRepoTagReq = modelarts.DeleteRepoTagReq
DeleteServiceReq = modelarts.DeleteServiceReq
DeleteServiceResp = modelarts.DeleteServiceResp
DeleteTrainingJobConfigReq = modelarts.DeleteTrainingJobConfigReq
DeleteTrainingJobConfigResp = modelarts.DeleteTrainingJobConfigResp
DeleteTrainingJobReq = modelarts.DeleteTrainingJobReq
DeleteTrainingJobResp = modelarts.DeleteTrainingJobResp
DescribeProcessorTaskReq = modelarts.DescribeProcessorTaskReq
DescribeProcessorTaskResp = modelarts.DescribeProcessorTaskResp
DetailTrainingJobsReq = modelarts.DetailTrainingJobsReq
Disk = modelarts.Disk
Domain = modelarts.Domain
EndpointsReq = modelarts.EndpointsReq
EndpointsRes = modelarts.EndpointsRes
Engine = modelarts.Engine
EngineAlRp = modelarts.EngineAlRp
EngineAlRq = modelarts.EngineAlRq
EngineCreateTraining = modelarts.EngineCreateTraining
Errors = modelarts.Errors
ExportParams = modelarts.ExportParams
ExportTaskDataResp = modelarts.ExportTaskDataResp
ExportTaskReq = modelarts.ExportTaskReq
ExportTaskStatus = modelarts.ExportTaskStatus
FileData = modelarts.FileData
FileRequest = modelarts.FileRequest
FileResponse = modelarts.FileResponse
FileStatistics = modelarts.FileStatistics
Flavor = modelarts.Flavor
FlavorDetail = modelarts.FlavorDetail
FlavorInfo = modelarts.FlavorInfo
FlavorResponse = modelarts.FlavorResponse
GetExportTaskStatusOfDatasetReq = modelarts.GetExportTaskStatusOfDatasetReq
GetExportTaskStatusOfDatasetResp = modelarts.GetExportTaskStatusOfDatasetResp
GetExportTasksOfDatasetReq = modelarts.GetExportTasksOfDatasetReq
GetExportTasksOfDatasetResp = modelarts.GetExportTasksOfDatasetResp
GetNotebookFlavorsReq = modelarts.GetNotebookFlavorsReq
GetNotebookFlavorsResp = modelarts.GetNotebookFlavorsResp
GetNotebookFlavorsResp_Billing = modelarts.GetNotebookFlavorsResp_Billing
GetNotebookFlavorsResp_Data = modelarts.GetNotebookFlavorsResp_Data
GetNotebookFlavorsResp_Gpu = modelarts.GetNotebookFlavorsResp_Gpu
GetNotebookStorageReq = modelarts.GetNotebookStorageReq
GetNotebookStorageResp = modelarts.GetNotebookStorageResp
GetPoolsRuntimeMetricsReq = modelarts.GetPoolsRuntimeMetricsReq
GetPoolsRuntimeMetricsResp = modelarts.GetPoolsRuntimeMetricsResp
GetPoolsRuntimeMetricsResp_Allocated = modelarts.GetPoolsRuntimeMetricsResp_Allocated
GetPoolsRuntimeMetricsResp_Capacity = modelarts.GetPoolsRuntimeMetricsResp_Capacity
GetPoolsRuntimeMetricsResp_Items = modelarts.GetPoolsRuntimeMetricsResp_Items
GetPoolsRuntimeMetricsResp_Labels = modelarts.GetPoolsRuntimeMetricsResp_Labels
GetPoolsRuntimeMetricsResp_MaxValue = modelarts.GetPoolsRuntimeMetricsResp_MaxValue
GetPoolsRuntimeMetricsResp_Metadata = modelarts.GetPoolsRuntimeMetricsResp_Metadata
GetPoolsRuntimeMetricsResp_Table = modelarts.GetPoolsRuntimeMetricsResp_Table
GetPoolsRuntimeMetricsResp_Value = modelarts.GetPoolsRuntimeMetricsResp_Value
GetPoolsRuntimeMetricsResp_Value1 = modelarts.GetPoolsRuntimeMetricsResp_Value1
GetResourceFlavorsReq = modelarts.GetResourceFlavorsReq
GetResourceFlavorsResp = modelarts.GetResourceFlavorsResp
GetResourceFlavorsResp_DataVolumes = modelarts.GetResourceFlavorsResp_DataVolumes
GetResourceFlavorsResp_Items = modelarts.GetResourceFlavorsResp_Items
GetResourceFlavorsResp_Labels = modelarts.GetResourceFlavorsResp_Labels
GetResourceFlavorsResp_Metadata = modelarts.GetResourceFlavorsResp_Metadata
GetResourceFlavorsResp_Metadata1 = modelarts.GetResourceFlavorsResp_Metadata1
GetResourceFlavorsResp_Npu = modelarts.GetResourceFlavorsResp_Npu
GetResourceFlavorsResp_Phase = modelarts.GetResourceFlavorsResp_Phase
GetResourceFlavorsResp_Spec = modelarts.GetResourceFlavorsResp_Spec
GetResourceFlavorsResp_Status = modelarts.GetResourceFlavorsResp_Status
GetTrainingJobLogsPreviewReq = modelarts.GetTrainingJobLogsPreviewReq
GetTrainingJobLogsPreviewResp = modelarts.GetTrainingJobLogsPreviewResp
GetVisualizationJobParam = modelarts.GetVisualizationJobParam
GetVisualizationJobReq = modelarts.GetVisualizationJobReq
GetVisualizationJobResp = modelarts.GetVisualizationJobResp
Gpu = modelarts.Gpu
GuideDoc = modelarts.GuideDoc
Hooks = modelarts.Hooks
I18NDescription = modelarts.I18NDescription
Identity = modelarts.Identity
Image = modelarts.Image
ImageInfo = modelarts.ImageInfo
ImageReasoningReq = modelarts.ImageReasoningReq
ImageReasoningResp = modelarts.ImageReasoningResp
ImageReasoningUrlReq = modelarts.ImageReasoningUrlReq
ImageReasoningUrlResp = modelarts.ImageReasoningUrlResp
ImportConfig = modelarts.ImportConfig
ImportTaskDataReq = modelarts.ImportTaskDataReq
ImportTaskDataResp = modelarts.ImportTaskDataResp
ImportTasks = modelarts.ImportTasks
Input = modelarts.Input
InputDataInfo = modelarts.InputDataInfo
InputTraining = modelarts.InputTraining
Inputs = modelarts.Inputs
InputsAlRp = modelarts.InputsAlRp
InputsAlRq = modelarts.InputsAlRq
InterfaceType = modelarts.InterfaceType
Items = modelarts.Items
JobAlgorithmResponse = modelarts.JobAlgorithmResponse
JobConfigAl = modelarts.JobConfigAl
JobConfigAlRq = modelarts.JobConfigAlRq
JobMetadata = modelarts.JobMetadata
JobProgress = modelarts.JobProgress
JobResponse = modelarts.JobResponse
Jobs = modelarts.Jobs
Lease = modelarts.Lease
LeaseReq = modelarts.LeaseReq
ListAiEnginesReq = modelarts.ListAiEnginesReq
ListAiEnginesResp = modelarts.ListAiEnginesResp
ListAlgorithmsReq = modelarts.ListAlgorithmsReq
ListAlgorithmsResp = modelarts.ListAlgorithmsResp
ListClustersReq = modelarts.ListClustersReq
ListClustersResp = modelarts.ListClustersResp
ListClustersResp200 = modelarts.ListClustersResp200
ListClustersResp400 = modelarts.ListClustersResp400
ListImagesReq = modelarts.ListImagesReq
ListImagesResp = modelarts.ListImagesResp
ListImagesResp_Data = modelarts.ListImagesResp_Data
ListImportTasksReq = modelarts.ListImportTasksReq
ListImportTasksResp = modelarts.ListImportTasksResp
ListModelReq = modelarts.ListModelReq
ListModelResp = modelarts.ListModelResp
ListNamespacesReq = modelarts.ListNamespacesReq
ListNamespacesResp = modelarts.ListNamespacesResp
ListNotebookParam = modelarts.ListNotebookParam
ListNotebookReq = modelarts.ListNotebookReq
ListNotebookResp = modelarts.ListNotebookResp
ListRepoReq = modelarts.ListRepoReq
ListReposDetailsResp = modelarts.ListReposDetailsResp
ListRepositoryTagsReq = modelarts.ListRepositoryTagsReq
ListRepositoryTagsResp = modelarts.ListRepositoryTagsResp
ListServices = modelarts.ListServices
ListServicesReq = modelarts.ListServicesReq
ListServicesResp = modelarts.ListServicesResp
ListSpecificationsReq = modelarts.ListSpecificationsReq
ListSpecificationsResp = modelarts.ListSpecificationsResp
ListSpecificationsResp_CpuInfo = modelarts.ListSpecificationsResp_CpuInfo
ListSpecificationsResp_GpuInfo = modelarts.ListSpecificationsResp_GpuInfo
ListSpecificationsResp_MemoryInfo = modelarts.ListSpecificationsResp_MemoryInfo
ListSpecificationsResp_NpuInfo = modelarts.ListSpecificationsResp_NpuInfo
ListSpecificationsResp_Specifications = modelarts.ListSpecificationsResp_Specifications
ListTrainingJobConfigReq = modelarts.ListTrainingJobConfigReq
ListTrainingJobConfigResp = modelarts.ListTrainingJobConfigResp
ListTrainingJobsreq = modelarts.ListTrainingJobsreq
ListTrainingJobsresp = modelarts.ListTrainingJobsresp
LogExportPath = modelarts.LogExportPath
LogExportPathCreateTraining = modelarts.LogExportPathCreateTraining
Memory = modelarts.Memory
MetadataAlRp = modelarts.MetadataAlRp
MetadataAlRq = modelarts.MetadataAlRq
MetadataCrAl = modelarts.MetadataCrAl
MetadataS = modelarts.MetadataS
Methods = modelarts.Methods
MetricsPoolsRequest = modelarts.MetricsPoolsRequest
MetricsPoolsResponse = modelarts.MetricsPoolsResponse
MetricsPoolsResponse_SomeMessage = modelarts.MetricsPoolsResponse_SomeMessage
MetricsPoolsResponse_SomeMessage_Allocated = modelarts.MetricsPoolsResponse_SomeMessage_Allocated
MetricsPoolsResponse_SomeMessage_Capacity = modelarts.MetricsPoolsResponse_SomeMessage_Capacity
MetricsPoolsResponse_SomeMessage_Items = modelarts.MetricsPoolsResponse_SomeMessage_Items
MetricsPoolsResponse_SomeMessage_Maxvalue = modelarts.MetricsPoolsResponse_SomeMessage_Maxvalue
MetricsPoolsResponse_SomeMessage_Metadata = modelarts.MetricsPoolsResponse_SomeMessage_Metadata
MetricsPoolsResponse_SomeMessage_Table = modelarts.MetricsPoolsResponse_SomeMessage_Table
MetricsPoolsResponse_SomeMessage_Value = modelarts.MetricsPoolsResponse_SomeMessage_Value
MetricsPoolsResponse_SomeMessage_Value1 = modelarts.MetricsPoolsResponse_SomeMessage_Value1
ModelDependencies = modelarts.ModelDependencies
ModelHealth = modelarts.ModelHealth
ModelInOutputParams = modelarts.ModelInOutputParams
ModelListItem = modelarts.ModelListItem
ModelParamsInfo = modelarts.ModelParamsInfo
ModelSpecification = modelarts.ModelSpecification
MountNotebookStorageParam = modelarts.MountNotebookStorageParam
MountNotebookStorageReq = modelarts.MountNotebookStorageReq
MountNotebookStorageResp = modelarts.MountNotebookStorageResp
NamespaceInfo = modelarts.NamespaceInfo
NamespaceReq = modelarts.NamespaceReq
Nfs = modelarts.Nfs
NotebookResp = modelarts.NotebookResp
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
Packages = modelarts.Packages
Parameter = modelarts.Parameter
ParameterS = modelarts.ParameterS
ParametersAlRp = modelarts.ParametersAlRp
ParametersAlRq = modelarts.ParametersAlRq
ParametersTrainJob = modelarts.ParametersTrainJob
Password = modelarts.Password
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
ReposDetails = modelarts.ReposDetails
RepositoryTags = modelarts.RepositoryTags
Resource = modelarts.Resource
ResourceCreateTraining = modelarts.ResourceCreateTraining
ResourceRequirements = modelarts.ResourceRequirements
Resp = modelarts.Resp
RewardAttrs = modelarts.RewardAttrs
Schedule = modelarts.Schedule
Scheduler = modelarts.Scheduler
SchemaMaps = modelarts.SchemaMaps
Scope = modelarts.Scope
SearchCondition = modelarts.SearchCondition
SearchLabel = modelarts.SearchLabel
SearchLabels = modelarts.SearchLabels
SearchParams = modelarts.SearchParams
SearchProp = modelarts.SearchProp
ServiceConfig = modelarts.ServiceConfig
ShareInfo = modelarts.ShareInfo
ShareInfoAlRp = modelarts.ShareInfoAlRp
ShowAlgorithmByUuidReq = modelarts.ShowAlgorithmByUuidReq
ShowAlgorithmByUuidResp = modelarts.ShowAlgorithmByUuidResp
ShowModelDetail = modelarts.ShowModelDetail
ShowModelReq = modelarts.ShowModelReq
ShowModelResp = modelarts.ShowModelResp
ShowRepositoryReq = modelarts.ShowRepositoryReq
ShowRepositoryResp = modelarts.ShowRepositoryResp
ShowServiceReq = modelarts.ShowServiceReq
ShowServiceResp = modelarts.ShowServiceResp
SourceInfo = modelarts.SourceInfo
Spec = modelarts.Spec
Specs = modelarts.Specs
SpecsC = modelarts.SpecsC
StartNotebookParam = modelarts.StartNotebookParam
StartNotebookReq = modelarts.StartNotebookReq
StartNotebookResp = modelarts.StartNotebookResp
Status = modelarts.Status
StopNotebookReq = modelarts.StopNotebookReq
StopNotebookResp = modelarts.StopNotebookResp
Tags = modelarts.Tags
TagsAlRp = modelarts.TagsAlRp
TaskResponse = modelarts.TaskResponse
TaskStatuses = modelarts.TaskStatuses
Template = modelarts.Template
TemplateParam = modelarts.TemplateParam
TokenReq = modelarts.TokenReq
TokenResp = modelarts.TokenResp
TrainingJobFlavorsReq = modelarts.TrainingJobFlavorsReq
TrainingJobFlavorsResp = modelarts.TrainingJobFlavorsResp
UpdateRepoReq = modelarts.UpdateRepoReq
UpdateServiceReq = modelarts.UpdateServiceReq
UpdateServiceResp = modelarts.UpdateServiceResp
User = modelarts.User
UserNotebookDomain = modelarts.UserNotebookDomain
UserNotebookResp = modelarts.UserNotebookResp
VolumeReq = modelarts.VolumeReq
VolumeRes = modelarts.VolumeRes
Volumes = modelarts.Volumes
Weigou = modelarts.Weigou
WorkPath = modelarts.WorkPath
ModelArtsService interface {
// get modelarts Token
GetToken(ctx context.Context, in *TokenReq, opts ...grpc.CallOption) (*TokenResp, error)
// get modelarts Token
GetDatasetList(ctx context.Context, in *DataSetReq, opts ...grpc.CallOption) (*DataSetResp, error)
// create DateSet
CreateDataSet(ctx context.Context, in *CreateDataSetReq, opts ...grpc.CallOption) (*CreateDataSetResq, error)
// create DateSet
DeleteDataSet(ctx context.Context, in *DeleteDataSetReq, opts ...grpc.CallOption) (*DeleteDataSetResq, error)
// creat task 创建导入任务
CreateTask(ctx context.Context, in *ImportTaskDataReq, opts ...grpc.CallOption) (*ImportTaskDataResp, error)
// get taskList 查询数据集导入任务列表
GetImportTaskList(ctx context.Context, in *ListImportTasksReq, opts ...grpc.CallOption) (*ListImportTasksResp, error)
// ListTrainingJobs 查询训练作业列表
GetListTrainingJobs(ctx context.Context, in *ListTrainingJobsreq, opts ...grpc.CallOption) (*ListTrainingJobsresp, error)
// GetTrainingJobs 查询训练详情
GetTrainingJobs(ctx context.Context, in *DetailTrainingJobsReq, opts ...grpc.CallOption) (*JobResponse, error)
// CreateTrainingJob 创建训练作业
CreateTrainingJob(ctx context.Context, in *CreateTrainingJobReq, opts ...grpc.CallOption) (*CreateTrainingJobResp, error)
// DeleteTrainingJobConfig 删除训练作业
DeleteTrainingJob(ctx context.Context, in *DeleteTrainingJobReq, opts ...grpc.CallOption) (*DeleteTrainingJobResp, error)
// CreateTrainingJobConfig 创建训练作业参数
CreateTrainingJobConfig(ctx context.Context, in *CreateTrainingJobConfigReq, opts ...grpc.CallOption) (*CreateTrainingJobConfigResp, error)
// DeleteTrainingJobConfig 删除训练作业参数
DeleteTrainingJobConfig(ctx context.Context, in *DeleteTrainingJobConfigReq, opts ...grpc.CallOption) (*DeleteTrainingJobConfigResp, error)
// ListTrainingJobConfig 查询训练作业参数
ListTrainingJobConfig(ctx context.Context, in *ListTrainingJobConfigReq, opts ...grpc.CallOption) (*ListTrainingJobConfigResp, error)
// CreateAlgorithm 创建算法
CreateAlgorithm(ctx context.Context, in *CreateAlgorithmReq, opts ...grpc.CallOption) (*CreateAlgorithmResp, error)
// ListAlgorithms 查询算法
ListAlgorithms(ctx context.Context, in *ListAlgorithmsReq, opts ...grpc.CallOption) (*ListAlgorithmsResp, error)
// DeleteAlgorithms 删除算法
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)
// 查询训练作业指定任务的日志(预览)
GetTrainingJobLogsPreview(ctx context.Context, in *GetTrainingJobLogsPreviewReq, opts ...grpc.CallOption) (*GetTrainingJobLogsPreviewResp, 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)
GetExportTaskStatusOfDataset(ctx context.Context, in *GetExportTaskStatusOfDatasetReq, opts ...grpc.CallOption) (*GetExportTaskStatusOfDatasetResp, error)
// processor task
CreateProcessorTask(ctx context.Context, in *CreateProcessorTaskReq, opts ...grpc.CallOption) (*CreateProcessorTaskResp, error)
DescribeProcessorTask(ctx context.Context, in *DescribeProcessorTaskReq, opts ...grpc.CallOption) (*DescribeProcessorTaskResp, error)
// model management
CreateModel(ctx context.Context, in *CreateModelReq, opts ...grpc.CallOption) (*CreateModelResp, error)
DeleteModel(ctx context.Context, in *DeleteModelReq, opts ...grpc.CallOption) (*DeleteModelResp, error)
ListModels(ctx context.Context, in *ListModelReq, opts ...grpc.CallOption) (*ListModelResp, error)
ShowModels(ctx context.Context, in *ShowModelReq, opts ...grpc.CallOption) (*ShowModelResp, error)
// service management
CreateService(ctx context.Context, in *CreateServiceReq, opts ...grpc.CallOption) (*CreateServiceResp, error)
ListServices(ctx context.Context, in *ListServicesReq, opts ...grpc.CallOption) (*ListServicesResp, error)
ShowService(ctx context.Context, in *ShowServiceReq, opts ...grpc.CallOption) (*ShowServiceResp, error)
DeleteService(ctx context.Context, in *DeleteServiceReq, opts ...grpc.CallOption) (*DeleteServiceResp, error)
ListClusters(ctx context.Context, in *ListClustersReq, opts ...grpc.CallOption) (*ListClustersResp, error)
ListSpecifications(ctx context.Context, in *ListSpecificationsReq, opts ...grpc.CallOption) (*ListSpecificationsResp, error)
UpdateService(ctx context.Context, in *UpdateServiceReq, opts ...grpc.CallOption) (*UpdateServiceResp, error)
// pools
GetPoolsRuntimeMetrics(ctx context.Context, in *GetPoolsRuntimeMetricsReq, opts ...grpc.CallOption) (*GetPoolsRuntimeMetricsResp, error)
// ResourceFlavor
GetResourceFlavors(ctx context.Context, in *GetResourceFlavorsReq, opts ...grpc.CallOption) (*GetResourceFlavorsResp, error)
// notebook task
ListNotebook(ctx context.Context, in *ListNotebookReq, opts ...grpc.CallOption) (*ListNotebookResp, error)
CreateNotebook(ctx context.Context, in *CreateNotebookReq, opts ...grpc.CallOption) (*CreateNotebookResp, error)
StartNotebook(ctx context.Context, in *StartNotebookReq, opts ...grpc.CallOption) (*StartNotebookResp, error)
StopNotebook(ctx context.Context, in *StopNotebookReq, opts ...grpc.CallOption) (*StopNotebookResp, error)
GetNotebookStorage(ctx context.Context, in *GetNotebookStorageReq, opts ...grpc.CallOption) (*GetNotebookStorageResp, error)
MountNotebookStorage(ctx context.Context, in *MountNotebookStorageReq, opts ...grpc.CallOption) (*MountNotebookStorageResp, error)
GetNotebookFlavors(ctx context.Context, in *GetNotebookFlavorsReq, opts ...grpc.CallOption) (*GetNotebookFlavorsResp, error)
ListImages(ctx context.Context, in *ListImagesReq, opts ...grpc.CallOption) (*ListImagesResp, error)
DeleteNotebook(ctx context.Context, in *DeleteImagesReq, opts ...grpc.CallOption) (*DeleteImagesResp, error)
// visualization-jobs
GetVisualizationJob(ctx context.Context, in *GetVisualizationJobReq, opts ...grpc.CallOption) (*GetVisualizationJobResp, error)
CreateVisualizationJob(ctx context.Context, in *CreateVisualizationJobReq, opts ...grpc.CallOption) (*CreateVisualizationJobResp, error)
// reasoning
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)
}
defaultModelArtsService struct {
cli zrpc.Client
}
)
func NewModelArtsService(cli zrpc.Client) ModelArtsService {
return &defaultModelArtsService{
cli: cli,
}
}
// get modelarts Token
func (m *defaultModelArtsService) GetToken(ctx context.Context, in *TokenReq, opts ...grpc.CallOption) (*TokenResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.GetToken(ctx, in, opts...)
}
// get modelarts Token
func (m *defaultModelArtsService) GetDatasetList(ctx context.Context, in *DataSetReq, opts ...grpc.CallOption) (*DataSetResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.GetDatasetList(ctx, in, opts...)
}
// create DateSet
func (m *defaultModelArtsService) CreateDataSet(ctx context.Context, in *CreateDataSetReq, opts ...grpc.CallOption) (*CreateDataSetResq, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.CreateDataSet(ctx, in, opts...)
}
// create DateSet
func (m *defaultModelArtsService) DeleteDataSet(ctx context.Context, in *DeleteDataSetReq, opts ...grpc.CallOption) (*DeleteDataSetResq, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.DeleteDataSet(ctx, in, opts...)
}
// creat task 创建导入任务
func (m *defaultModelArtsService) CreateTask(ctx context.Context, in *ImportTaskDataReq, opts ...grpc.CallOption) (*ImportTaskDataResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.CreateTask(ctx, in, opts...)
}
// get taskList 查询数据集导入任务列表
func (m *defaultModelArtsService) GetImportTaskList(ctx context.Context, in *ListImportTasksReq, opts ...grpc.CallOption) (*ListImportTasksResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.GetImportTaskList(ctx, in, opts...)
}
// ListTrainingJobs 查询训练作业列表
func (m *defaultModelArtsService) GetListTrainingJobs(ctx context.Context, in *ListTrainingJobsreq, opts ...grpc.CallOption) (*ListTrainingJobsresp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.GetListTrainingJobs(ctx, in, opts...)
}
// GetTrainingJobs 查询训练详情
func (m *defaultModelArtsService) GetTrainingJobs(ctx context.Context, in *DetailTrainingJobsReq, opts ...grpc.CallOption) (*JobResponse, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.GetTrainingJobs(ctx, in, opts...)
}
// CreateTrainingJob 创建训练作业
func (m *defaultModelArtsService) CreateTrainingJob(ctx context.Context, in *CreateTrainingJobReq, opts ...grpc.CallOption) (*CreateTrainingJobResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.CreateTrainingJob(ctx, in, opts...)
}
// DeleteTrainingJobConfig 删除训练作业
func (m *defaultModelArtsService) DeleteTrainingJob(ctx context.Context, in *DeleteTrainingJobReq, opts ...grpc.CallOption) (*DeleteTrainingJobResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.DeleteTrainingJob(ctx, in, opts...)
}
// CreateTrainingJobConfig 创建训练作业参数
func (m *defaultModelArtsService) CreateTrainingJobConfig(ctx context.Context, in *CreateTrainingJobConfigReq, opts ...grpc.CallOption) (*CreateTrainingJobConfigResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.CreateTrainingJobConfig(ctx, in, opts...)
}
// DeleteTrainingJobConfig 删除训练作业参数
func (m *defaultModelArtsService) DeleteTrainingJobConfig(ctx context.Context, in *DeleteTrainingJobConfigReq, opts ...grpc.CallOption) (*DeleteTrainingJobConfigResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.DeleteTrainingJobConfig(ctx, in, opts...)
}
// ListTrainingJobConfig 查询训练作业参数
func (m *defaultModelArtsService) ListTrainingJobConfig(ctx context.Context, in *ListTrainingJobConfigReq, opts ...grpc.CallOption) (*ListTrainingJobConfigResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.ListTrainingJobConfig(ctx, in, opts...)
}
// CreateAlgorithm 创建算法
func (m *defaultModelArtsService) CreateAlgorithm(ctx context.Context, in *CreateAlgorithmReq, opts ...grpc.CallOption) (*CreateAlgorithmResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.CreateAlgorithm(ctx, in, opts...)
}
// ListAlgorithms 查询算法
func (m *defaultModelArtsService) ListAlgorithms(ctx context.Context, in *ListAlgorithmsReq, opts ...grpc.CallOption) (*ListAlgorithmsResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.ListAlgorithms(ctx, in, opts...)
}
// DeleteAlgorithms 删除算法
func (m *defaultModelArtsService) DeleteAlgorithms(ctx context.Context, in *DeleteAlgorithmsReq, opts ...grpc.CallOption) (*DeleteAlgorithmsResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.DeleteAlgorithms(ctx, in, opts...)
}
// ShowAlgorithmByUuid 展示算法详情
func (m *defaultModelArtsService) ShowAlgorithmByUuid(ctx context.Context, in *ShowAlgorithmByUuidReq, opts ...grpc.CallOption) (*ShowAlgorithmByUuidResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.ShowAlgorithmByUuid(ctx, in, opts...)
}
// training-job-flavors 获取训练作业支持的公共规格
func (m *defaultModelArtsService) GetTrainingJobFlavors(ctx context.Context, in *TrainingJobFlavorsReq, opts ...grpc.CallOption) (*TrainingJobFlavorsResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.GetTrainingJobFlavors(ctx, in, opts...)
}
// GET ai-engines 查询作业引擎规格
func (m *defaultModelArtsService) GetAiEnginesList(ctx context.Context, in *ListAiEnginesReq, opts ...grpc.CallOption) (*ListAiEnginesResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.GetAiEnginesList(ctx, in, opts...)
}
// 查询训练作业指定任务的日志(预览)
func (m *defaultModelArtsService) GetTrainingJobLogsPreview(ctx context.Context, in *GetTrainingJobLogsPreviewReq, opts ...grpc.CallOption) (*GetTrainingJobLogsPreviewResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.GetTrainingJobLogsPreview(ctx, in, opts...)
}
// export task
func (m *defaultModelArtsService) ExportTask(ctx context.Context, in *ExportTaskReq, opts ...grpc.CallOption) (*ExportTaskDataResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.ExportTask(ctx, in, opts...)
}
func (m *defaultModelArtsService) GetExportTasksOfDataset(ctx context.Context, in *GetExportTasksOfDatasetReq, opts ...grpc.CallOption) (*GetExportTasksOfDatasetResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.GetExportTasksOfDataset(ctx, in, opts...)
}
func (m *defaultModelArtsService) GetExportTaskStatusOfDataset(ctx context.Context, in *GetExportTaskStatusOfDatasetReq, opts ...grpc.CallOption) (*GetExportTaskStatusOfDatasetResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.GetExportTaskStatusOfDataset(ctx, in, opts...)
}
// processor task
func (m *defaultModelArtsService) CreateProcessorTask(ctx context.Context, in *CreateProcessorTaskReq, opts ...grpc.CallOption) (*CreateProcessorTaskResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.CreateProcessorTask(ctx, in, opts...)
}
func (m *defaultModelArtsService) DescribeProcessorTask(ctx context.Context, in *DescribeProcessorTaskReq, opts ...grpc.CallOption) (*DescribeProcessorTaskResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.DescribeProcessorTask(ctx, in, opts...)
}
// model management
func (m *defaultModelArtsService) CreateModel(ctx context.Context, in *CreateModelReq, opts ...grpc.CallOption) (*CreateModelResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.CreateModel(ctx, in, opts...)
}
func (m *defaultModelArtsService) DeleteModel(ctx context.Context, in *DeleteModelReq, opts ...grpc.CallOption) (*DeleteModelResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.DeleteModel(ctx, in, opts...)
}
func (m *defaultModelArtsService) ListModels(ctx context.Context, in *ListModelReq, opts ...grpc.CallOption) (*ListModelResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.ListModels(ctx, in, opts...)
}
func (m *defaultModelArtsService) ShowModels(ctx context.Context, in *ShowModelReq, opts ...grpc.CallOption) (*ShowModelResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.ShowModels(ctx, in, opts...)
}
// service management
func (m *defaultModelArtsService) CreateService(ctx context.Context, in *CreateServiceReq, opts ...grpc.CallOption) (*CreateServiceResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.CreateService(ctx, in, opts...)
}
func (m *defaultModelArtsService) ListServices(ctx context.Context, in *ListServicesReq, opts ...grpc.CallOption) (*ListServicesResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.ListServices(ctx, in, opts...)
}
func (m *defaultModelArtsService) ShowService(ctx context.Context, in *ShowServiceReq, opts ...grpc.CallOption) (*ShowServiceResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.ShowService(ctx, in, opts...)
}
func (m *defaultModelArtsService) DeleteService(ctx context.Context, in *DeleteServiceReq, opts ...grpc.CallOption) (*DeleteServiceResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.DeleteService(ctx, in, opts...)
}
func (m *defaultModelArtsService) ListClusters(ctx context.Context, in *ListClustersReq, opts ...grpc.CallOption) (*ListClustersResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.ListClusters(ctx, in, opts...)
}
func (m *defaultModelArtsService) ListSpecifications(ctx context.Context, in *ListSpecificationsReq, opts ...grpc.CallOption) (*ListSpecificationsResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.ListSpecifications(ctx, in, opts...)
}
func (m *defaultModelArtsService) UpdateService(ctx context.Context, in *UpdateServiceReq, opts ...grpc.CallOption) (*UpdateServiceResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.UpdateService(ctx, in, opts...)
}
// pools
func (m *defaultModelArtsService) GetPoolsRuntimeMetrics(ctx context.Context, in *GetPoolsRuntimeMetricsReq, opts ...grpc.CallOption) (*GetPoolsRuntimeMetricsResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.GetPoolsRuntimeMetrics(ctx, in, opts...)
}
// ResourceFlavor
func (m *defaultModelArtsService) GetResourceFlavors(ctx context.Context, in *GetResourceFlavorsReq, opts ...grpc.CallOption) (*GetResourceFlavorsResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.GetResourceFlavors(ctx, in, opts...)
}
// notebook task
func (m *defaultModelArtsService) ListNotebook(ctx context.Context, in *ListNotebookReq, opts ...grpc.CallOption) (*ListNotebookResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.ListNotebook(ctx, in, opts...)
}
func (m *defaultModelArtsService) CreateNotebook(ctx context.Context, in *CreateNotebookReq, opts ...grpc.CallOption) (*CreateNotebookResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.CreateNotebook(ctx, in, opts...)
}
func (m *defaultModelArtsService) StartNotebook(ctx context.Context, in *StartNotebookReq, opts ...grpc.CallOption) (*StartNotebookResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.StartNotebook(ctx, in, opts...)
}
func (m *defaultModelArtsService) StopNotebook(ctx context.Context, in *StopNotebookReq, opts ...grpc.CallOption) (*StopNotebookResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.StopNotebook(ctx, in, opts...)
}
func (m *defaultModelArtsService) GetNotebookStorage(ctx context.Context, in *GetNotebookStorageReq, opts ...grpc.CallOption) (*GetNotebookStorageResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.GetNotebookStorage(ctx, in, opts...)
}
func (m *defaultModelArtsService) MountNotebookStorage(ctx context.Context, in *MountNotebookStorageReq, opts ...grpc.CallOption) (*MountNotebookStorageResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.MountNotebookStorage(ctx, in, opts...)
}
func (m *defaultModelArtsService) GetNotebookFlavors(ctx context.Context, in *GetNotebookFlavorsReq, opts ...grpc.CallOption) (*GetNotebookFlavorsResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.GetNotebookFlavors(ctx, in, opts...)
}
func (m *defaultModelArtsService) ListImages(ctx context.Context, in *ListImagesReq, opts ...grpc.CallOption) (*ListImagesResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.ListImages(ctx, in, opts...)
}
func (m *defaultModelArtsService) DeleteNotebook(ctx context.Context, in *DeleteImagesReq, opts ...grpc.CallOption) (*DeleteImagesResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.DeleteNotebook(ctx, in, opts...)
}
// visualization-jobs
func (m *defaultModelArtsService) GetVisualizationJob(ctx context.Context, in *GetVisualizationJobReq, opts ...grpc.CallOption) (*GetVisualizationJobResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.GetVisualizationJob(ctx, in, opts...)
}
func (m *defaultModelArtsService) CreateVisualizationJob(ctx context.Context, in *CreateVisualizationJobReq, opts ...grpc.CallOption) (*CreateVisualizationJobResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.CreateVisualizationJob(ctx, in, opts...)
}
// reasoning
func (m *defaultModelArtsService) ImageReasoning(ctx context.Context, in *ImageReasoningReq, opts ...grpc.CallOption) (*ImageReasoningResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.ImageReasoning(ctx, in, opts...)
}
func (m *defaultModelArtsService) ImageReasoningUrl(ctx context.Context, in *ImageReasoningUrlReq, opts ...grpc.CallOption) (*ImageReasoningUrlResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.ImageReasoningUrl(ctx, in, opts...)
}
func (m *defaultModelArtsService) ChatglmReasoning(ctx context.Context, in *ChatglmReasoningReq, opts ...grpc.CallOption) (*ChatglmReasoningResp, error) {
client := modelarts.NewModelArtsServiceClient(m.cli.Conn())
return client.ChatglmReasoning(ctx, in, opts...)
}

View File

@ -1,15 +1,49 @@
NacosConfig:
DataId: pcm-modelarts-rpc.yaml
Group: DEFAULT_GROUP
ServerConfigs:
# - IpAddr: 127.0.0.1
# Port: 8848
- IpAddr: nacos.jcce.dev
Port: 8848
ClientConfig:
NamespaceId: test
TimeoutMs: 5000
NotLoadCacheAtStart: true
LogDir:
CacheDir:
LogLevel: debug
Name: pcm.modelarts.rpc
ListenOn: 0.0.0.0:2002
AdapterId:
Timeout: 500000
Participant:
Name: modelarts #参与者名称
Address: "" #内网地址
RpcAddress: 0.0.0.0:2002 #rpc协议地址和端口
Type: "0"
TenantId: 1 #租户id
TenantName: "host" #租户名
CoreClientConf:
Url: "localhost:8999"
DataSource: ""
ModelArtsConf:
JobLogsPath: "/nudt-cloudream2/job-logs/"
Platform: "modelarts-CloudBrain2"
CloudBrain2:
AK: "UNEHPHO4Z7YSNPKRXFE4"
SK: "JWXCE9qcYbc7RjpSRIWt4WgG3ZKF6Q4lPzkJReX9"
Endpoint: "https://modelarts.cn-south-222.ai.pcl.cn/"
ProjectId: "d18190e28e3f45a281ef0b0696ec9d52"
DomainId: "f107f69fc36d49e3b0f6277afe3720ab"
SwrEndpoint: "swr.cn-south-222.ai.pcl.cn"
SwrApiEndpoint: "https://swr-api.cn-south-222.ai.pcl.cn/"
Platform: "modelarts-CloudBrain2"
Njaci:
AK: ""
SK: ""
Endpoint: ""
ProjectId: ""
DomainId: ""
SwrEndpoint: ""
SwrApiEndpoint: ""
Platform: ""
# core rpc
PcmCoreRpcConf:
# target: nacos://10.101.15.7:8848/pcm.core.rpc?timeout=30s&namespaceid=test&groupname=DEFAULT_GROUP&appName=pcm.modelarts.rpc
Endpoints:
- pcm-core-rpc:2004
NonBlock: true
ParticipantId:

153
go.mod
View File

@ -1,106 +1,107 @@
module gitlink.org.cn/jcce-pcm/pcm-participant-modelarts
module gitlink.org.cn/JointCloud/pcm-modelarts
go 1.19
go 1.21
require (
github.com/JCCE-nudt/apigw-go-sdk v0.0.0-20230525025609-34159d6f2818
github.com/bitly/go-simplejson v0.5.1
github.com/docker/docker v24.0.5+incompatible
github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.61
github.com/robfig/cron/v3 v3.0.1
github.com/zeromicro/go-zero v1.5.3
gitlink.org.cn/jcce-pcm/pcm-coordinator v0.1.5
gitlink.org.cn/jcce-pcm/utils v0.0.1
google.golang.org/grpc v1.56.2
google.golang.org/protobuf v1.31.0
k8s.io/apimachinery v0.27.3
github.com/zeromicro/go-zero v1.6.3
google.golang.org/grpc v1.63.0
google.golang.org/protobuf v1.33.0
k8s.io/apimachinery v0.29.3
)
require (
github.com/JCCE-nudt/zero-contrib/zrpc/registry/nacos v0.0.0-20230419021610-13bbc83fbc3c // indirect
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/emicklei/go-restful/v3 v3.12.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/go-resty/resty/v2 v2.7.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 // indirect
github.com/jinzhu/copier v0.3.5 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/google/pprof v0.0.0-20240117000934-35fc243c5815 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nacos-group/nacos-sdk-go/v2 v2.2.1 // indirect
github.com/openzipkin/zipkin-go v0.4.1 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/onsi/ginkgo/v2 v2.14.0 // indirect
github.com/onsi/gomega v1.30.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/openzipkin/zipkin-go v0.4.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.15.1 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.52.2 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
github.com/redis/go-redis/v9 v9.5.1 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
go.etcd.io/etcd/api/v3 v3.5.9 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.9 // indirect
go.etcd.io/etcd/client/v3 v3.5.9 // indirect
go.opentelemetry.io/otel v1.14.0 // indirect
go.opentelemetry.io/otel/exporters/jaeger v1.14.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.14.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.14.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.14.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.14.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0 // indirect
go.opentelemetry.io/otel/exporters/zipkin v1.14.0 // indirect
go.opentelemetry.io/otel/sdk v1.14.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/automaxprocs v1.5.2 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
go.etcd.io/etcd/api/v3 v3.5.13 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.13 // indirect
go.etcd.io/etcd/client/v3 v3.5.13 // indirect
go.opentelemetry.io/otel v1.25.0 // indirect
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.25.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.25.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.25.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.25.0 // indirect
go.opentelemetry.io/otel/exporters/zipkin v1.25.0 // indirect
go.opentelemetry.io/otel/metric v1.25.0 // indirect
go.opentelemetry.io/otel/sdk v1.25.0 // indirect
go.opentelemetry.io/otel/trace v1.25.0 // indirect
go.opentelemetry.io/proto/otlp v1.1.0 // indirect
go.uber.org/automaxprocs v1.5.3 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.19.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.18.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.26.3 // indirect
k8s.io/client-go v0.26.3 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
gotest.tools/v3 v3.5.1 // indirect
k8s.io/api v0.29.3 // indirect
k8s.io/client-go v0.29.3 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240403164606-bc84c2ddaf99 // indirect
k8s.io/utils v0.0.0-20240310230437-4693a0247e57 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

1638
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,4 @@
package initialize
type ModelArtsClient struct {
}

View File

@ -1,68 +0,0 @@
package common
import (
"bytes"
"encoding/json"
"io"
"log"
"net/http"
"time"
)
const (
IAMUser = "pcmmodelarts"
IAMPassword = "!QAZ2wsx3edc4"
IAMDomain = "hw_008618597947378_01"
AuthMethod = "password"
IAMTokenUrl = "https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens"
ProjectName = "cn-north-4"
TokenHeader = "X-Subject-Token"
Status_created = 201
)
var (
token, expiredAt = GenerateToken()
)
func GenerateToken() (string, time.Time) {
a := Auth{}
a.Auth.Scope.Project.Name = ProjectName
a.Auth.Identity.Methods = append(a.Auth.Identity.Methods, AuthMethod)
a.Auth.Identity.Password.User.Name = IAMUser
a.Auth.Identity.Password.User.Password = IAMPassword
a.Auth.Identity.Password.User.Domain.Name = IAMDomain
jsonStr, _ := json.Marshal(a)
req_url, err := http.NewRequest("POST", IAMTokenUrl, bytes.NewBuffer(jsonStr))
if err != nil {
log.Fatal(err)
}
c := http.Client{Timeout: time.Duration(3) * time.Second}
respUrl, err := c.Do(req_url)
if err != nil {
log.Fatal(err)
}
if respUrl.StatusCode != Status_created {
panic("获取token失败")
}
defer respUrl.Body.Close()
var t Token
result, _ := io.ReadAll(respUrl.Body)
json.Unmarshal(result, &t)
return respUrl.Header.Get(TokenHeader), t.Token.ExpiresAt
}
func GetToken() string {
if time.Now().After(expiredAt) {
token, expiredAt = GenerateToken()
}
return token
}

View File

@ -1,71 +0,0 @@
package common
import "time"
type Token struct {
Token struct {
ExpiresAt time.Time `json:"expires_at"`
Methods []string `json:"methods"`
Catalog []struct {
Endpoints []struct {
Id string `json:"id"`
Interface string `json:"interface"`
Region string `json:"region"`
RegionId string `json:"region_id"`
Url string `json:"url"`
} `json:"endpoints"`
Id string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
} `json:"catalog"`
Roles []struct {
Id string `json:"id"`
Name string `json:"name"`
} `json:"roles"`
Project struct {
Domain struct {
Id string `json:"id"`
Name string `json:"name"`
} `json:"domain"`
Id string `json:"id"`
Name string `json:"name"`
} `json:"project"`
IssuedAt time.Time `json:"issued_at"`
User struct {
Domain struct {
Id string `json:"id"`
Name string `json:"name"`
} `json:"domain"`
Id string `json:"id"`
Name string `json:"name"`
PasswordExpiresAt string `json:"password_expires_at"`
} `json:"user"`
} `json:"token"`
}
type Auth struct {
Auth struct {
Identity struct {
Methods []string `json:"methods"`
Password struct {
User struct {
Name string `json:"name"`
Password string `json:"password"`
Domain struct {
Name string `json:"name"`
} `json:"domain"`
} `json:"user"`
} `json:"password"`
} `json:"identity"`
Scope struct {
Project struct {
Name string `json:"name"`
} `json:"project"`
} `json:"scope"`
} `json:"auth"`
}
type Error struct {
ErrorCode string `json:"error_code"`
ErrorMsg string `json:"error_msg"`
}

View File

@ -9,5 +9,5 @@ type Config struct {
zrpc.RpcServerConf
LogConf logx.LogConf
PcmCoreRpcConf zrpc.RpcClientConf
ModelArtsConfig
ModelArtsConf ModelArtsConf
}

View File

@ -1,15 +1,19 @@
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"`
type ModelArtsConf struct {
CloudBrain2 Conf `json:"CloudBrain2"`
Njaci Conf `json:"Njaci"`
JobLogsPath string `json:"JobLogsPath"`
Platform string `json:"Platform"`
}
type Conf struct {
AK string `json:"AK"`
SK string `json:"SK"`
Endpoint string `json:"Endpoint"`
ProjectId string `json:"ProjectId"`
DomainId string `json:"DomainId"`
SwrEndpoint string `json:"SwrEndpoint"`
SwrApiEndpoint string `json:"SwrApiEndpoint"`
Platform string `json:"Platform"`
}

View File

@ -1,95 +0,0 @@
package logic
import (
"bytes"
"context"
"encoding/json"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"net/http"
"strings"
)
type CreateAlgorithmLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateAlgorithmLogic {
return &CreateAlgorithmLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// CreateAlgorithm 创建算法
func (l *CreateAlgorithmLogic) CreateAlgorithm(in *modelarts.CreateAlgorithmReq) (*modelarts.CreateAlgorithmResp, error) {
var resp modelarts.CreateAlgorithmResp
//根据智算类型判断走华为智算还是南京智算
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)
}
return &resp, nil
}

View File

@ -1,90 +0,0 @@
package logic
import (
"bytes"
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strings"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateDataSetLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateDataSetLogic {
return &CreateDataSetLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// create DateSet
func (l *CreateDataSetLogic) CreateDataSet(in *modelarts.CreateDataSetReq) (*modelarts.CreateDataSetResq, error) {
// todo: add your logic here and delete this line
var resp modelarts.CreateDataSetResq
//根据智算类型判断走华为智算还是南京智算
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
}

View File

@ -1,91 +0,0 @@
package logic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"bytes"
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strings"
)
type CreateModelLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateModelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateModelLogic {
return &CreateModelLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// model management
func (l *CreateModelLogic) CreateModel(in *modelarts.CreateModelReq) (*modelarts.CreateModelResp, error) {
// todo: add your logic here and delete this line
var resp modelarts.CreateModelResp
//根据智算类型判断走华为智算还是南京智算
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)
}
return &resp, nil
}

View File

@ -1,105 +0,0 @@
package logic
import (
"bytes"
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
)
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 *modelarts.CreateNotebookReq) (*modelarts.CreateNotebookResp, error) {
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)
}
return resp, nil
}

View File

@ -1,92 +0,0 @@
package logic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"bytes"
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strings"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateProcessorTaskLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateProcessorTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateProcessorTaskLogic {
return &CreateProcessorTaskLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// processor task
func (l *CreateProcessorTaskLogic) CreateProcessorTask(in *modelarts.CreateProcessorTaskReq) (*modelarts.CreateProcessorTaskResp, error) {
// todo: add your logic here and delete this line
var resp modelarts.CreateProcessorTaskResp
//根据智算类型判断走华为智算还是南京智算
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)
}
return &resp, nil
}

View File

@ -1,102 +0,0 @@
package logic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"bytes"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strings"
)
import (
"context"
)
type CreateServiceLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateServiceLogic {
return &CreateServiceLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// service management
func (l *CreateServiceLogic) CreateService(in *modelarts.CreateServiceReq) (*modelarts.CreateServiceResp, error) {
// todo: add your logic here and delete this line
var resp modelarts.CreateServiceResp
//根据智算类型判断走华为智算还是南京智算
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)
}
return &resp, nil
}

View File

@ -1,95 +0,0 @@
package logic
import (
"bytes"
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strings"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateTaskLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTaskLogic {
return &CreateTaskLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// creat task 创建导入任务
func (l *CreateTaskLogic) CreateTask(in *modelarts.ImportTaskDataReq) (*modelarts.ImportTaskDataResp, error) {
var resp modelarts.ImportTaskDataResp
//根据智算类型判断走华为智算还是南京智算
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)
}
return &resp, nil
}

View File

@ -1,89 +0,0 @@
package logic
import (
"bytes"
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strings"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateTrainingJobConfigLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateTrainingJobConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTrainingJobConfigLogic {
return &CreateTrainingJobConfigLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// CreateTrainingJobConfig 创建训练作业参数
func (l *CreateTrainingJobConfigLogic) CreateTrainingJobConfig(in *modelarts.CreateTrainingJobConfigReq) (*modelarts.CreateTrainingJobConfigResp, error) {
var resp modelarts.CreateTrainingJobConfigResp
//根据智算类型判断走华为智算还是南京智算
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
}

View File

@ -1,97 +0,0 @@
package logic
import (
"bytes"
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strings"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateTrainingJobLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateTrainingJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTrainingJobLogic {
return &CreateTrainingJobLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// CreateTrainingJob 创建训练作业
func (l *CreateTrainingJobLogic) CreateTrainingJob(in *modelarts.CreateTrainingJobReq) (*modelarts.CreateTrainingJobResp, error) {
var resp modelarts.CreateTrainingJobResp
//根据智算类型判断走华为智算还是南京智算
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)
}
return &resp, nil
}

View File

@ -1,88 +0,0 @@
package logic
import (
"bytes"
"context"
"encoding/json"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"net/http"
"strings"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateVisualizationJobLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateVisualizationJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateVisualizationJobLogic {
return &CreateVisualizationJobLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *CreateVisualizationJobLogic) CreateVisualizationJob(in *modelarts.CreateVisualizationJobReq) (*modelarts.CreateVisualizationJobResp, error) {
var resp modelarts.CreateVisualizationJobResp
//根据智算类型判断走华为智算还是南京智算
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())
}
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)
}
return &resp, nil
}

View File

@ -1,217 +0,0 @@
package logic
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/pcmcoreclient"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"time"
)
func InitCron(svc *svc.ServiceContext) {
submitJobLogic := NewCreateTrainingJobLogic(context.Background(), svc)
listLogic := NewGetListTrainingJobsLogic(context.Background(), svc)
svc.Cron.AddFunc("*/5 * * * * ?", func() {
syncInfoReq := pcmcoreclient.SyncInfoReq{
Kind: "ai",
ServiceName: "modelArts",
}
// 查询core端分发下来的任务列表
infoList, err := queryCoreInfoList(svc)
if err != nil {
logx.Error(err)
return
}
// 提交任务
submitJob(infoList, submitJobLogic)
// 查询运行中的任务列表同步信息
listReq := modelarts.ListTrainingJobsreq{
ProjectId: "0a62ffb0d48026c12fbfc011b8d23f0b",
Limit: 10,
OffSet: 0,
ModelArtsType: "cn-north-4.myhuawei",
}
listJob, err := listLogic.GetListTrainingJobs(&listReq)
if err != nil {
logx.Error(err)
return
}
for index, _ := range infoList.AiInfoList {
for _, job := range listJob.Items {
if job.Metadata.Name == infoList.AiInfoList[index].Name {
infoList.AiInfoList[index].ProjectId = job.ProjectId
infoList.AiInfoList[index].JobId = job.Metadata.Id
createTime := time.Unix(int64(job.Metadata.CreateTime)/1000, 0)
infoList.AiInfoList[index].CreateTime = time.Time.String(createTime)
if job.Status.StartTime != 0 {
startTime := time.Unix(int64(job.Status.StartTime)/1000, 0)
infoList.AiInfoList[index].StartTime = time.Time.String(startTime)
}
infoList.AiInfoList[index].RunningTime = int64(job.Status.Duration) / 1000
infoList.AiInfoList[index].Status = job.Status.Phase
}
}
}
// 同步信息到core端
if len(infoList.AiInfoList) != 0 {
syncInfoReq.AiInfoList = infoList.AiInfoList
svc.PcmCoreRpc.SyncInfo(context.Background(), &syncInfoReq)
}
})
}
func submitJob(infoList *pcmcoreclient.InfoListResp, submitJobLogic *CreateTrainingJobLogic) {
for index, _ := range infoList.AiInfoList {
if infoList.AiInfoList[index].Status == "Saved" {
submitReq := modelarts.CreateTrainingJobReq{
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{
//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: infoList.AiInfoList[index].FlavorId,
NodeCount: 1,
Policy: "regular",
FlavorLabel: "[限时免费] GPU: 1*NVIDIA-V100(32GB) | CPU: 8 核 64GB 780GB",
},
},
}
jobResult, _ := submitJobLogic.CreateTrainingJob(&submitReq)
if jobResult.Code == 200 {
infoList.AiInfoList[index].Status = jobResult.Status.Phase
infoList.AiInfoList[index].ProjectId = jobResult.Metadata.Id
} else {
infoList.AiInfoList[index].Result = "Failed"
infoList.AiInfoList[index].Result = jobResult.Msg
}
}
}
}
func queryCoreInfoList(svc *svc.ServiceContext) (*pcmcoreclient.InfoListResp, error) {
infoReq := pcmcoreclient.InfoListReq{
Kind: "ai",
ServiceName: "modelArts",
}
infoList, err := svc.PcmCoreRpc.InfoList(context.Background(), &infoReq)
if err != nil {
return nil, err
}
return infoList, nil
}

View File

@ -1,99 +0,0 @@
package logic
import (
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strings"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteAlgorithmsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteAlgorithmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteAlgorithmsLogic {
return &DeleteAlgorithmsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// DeleteAlgorithms 删除算法
func (l *DeleteAlgorithmsLogic) DeleteAlgorithms(in *modelarts.DeleteAlgorithmsReq) (*modelarts.DeleteAlgorithmsResp, error) {
var resp modelarts.DeleteAlgorithmsResp
//根据智算类型判断走华为智算还是南京智算
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
}

View File

@ -1,103 +0,0 @@
package logic
import (
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strings"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"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),
}
}
// create DateSet
func (l *DeleteDataSetLogic) DeleteDataSet(in *modelarts.DeleteDataSetReq) (*modelarts.DeleteDataSetResq, error) {
// todo: add your logic here and delete this line
var resp modelarts.DeleteDataSetResq
//根据智算类型判断走华为智算还是南京智算
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"
}
}
return &resp, nil
}

View File

@ -1,104 +0,0 @@
package logic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strings"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteModelLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteModelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteModelLogic {
return &DeleteModelLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *DeleteModelLogic) DeleteModel(in *modelarts.DeleteModelReq) (*modelarts.DeleteModelResp, error) {
// todo: add your logic here and delete this line
var resp modelarts.DeleteModelResp
//根据智算类型判断走华为智算还是南京智算
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"
}
}
return &resp, nil
}

View File

@ -1,97 +0,0 @@
package logic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteServiceLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteServiceLogic {
return &DeleteServiceLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *DeleteServiceLogic) DeleteService(in *modelarts.DeleteServiceReq) (*modelarts.DeleteServiceResp, error) {
var resp modelarts.DeleteServiceResp
//根据智算类型判断走华为智算还是南京智算
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
}

View File

@ -1,93 +0,0 @@
package logic
import (
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strings"
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteTrainingJobConfigLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteTrainingJobConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTrainingJobConfigLogic {
return &DeleteTrainingJobConfigLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// DeleteTrainingJobConfig 删除训练作业参数
func (l *DeleteTrainingJobConfigLogic) DeleteTrainingJobConfig(in *modelarts.DeleteTrainingJobConfigReq) (*modelarts.DeleteTrainingJobConfigResp, error) {
var resp modelarts.DeleteTrainingJobConfigResp
//根据智算类型判断走华为智算还是南京智算
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
}

View File

@ -1,100 +0,0 @@
package logic
import (
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strings"
)
type DeleteTrainingJobLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteTrainingJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTrainingJobLogic {
return &DeleteTrainingJobLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// DeleteTrainingJobConfig 删除训练作业
func (l *DeleteTrainingJobLogic) DeleteTrainingJob(in *modelarts.DeleteTrainingJobReq) (*modelarts.DeleteTrainingJobResp, error) {
var resp modelarts.DeleteTrainingJobResp
//根据智算类型判断走华为智算还是南京智算
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
}

View File

@ -1,82 +0,0 @@
package logic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"github.com/zeromicro/go-zero/core/logx"
)
type DescribeProcessorTaskLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDescribeProcessorTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DescribeProcessorTaskLogic {
return &DescribeProcessorTaskLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *DescribeProcessorTaskLogic) DescribeProcessorTask(in *modelarts.DescribeProcessorTaskReq) (*modelarts.DescribeProcessorTaskResp, error) {
// todo: add your logic here and delete this line
var resp modelarts.DescribeProcessorTaskResp
//根据智算类型判断走华为智算还是南京智算
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)
}
return &resp, nil
}

View File

@ -1,99 +0,0 @@
package logic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"bytes"
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
_ "gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strings"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
)
type ExportTaskLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewExportTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ExportTaskLogic {
return &ExportTaskLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// ExportTask for modelarts
func (l *ExportTaskLogic) ExportTask(in *modelarts.ExportTaskReq) (*modelarts.ExportTaskDataResp, error) {
var resp modelarts.ExportTaskDataResp
//根据智算类型判断走华为智算还是南京智算
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)
}
return &resp, nil
}

View File

@ -1,89 +0,0 @@
package logic
import (
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/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
}

View File

@ -1,96 +0,0 @@
package logic
import (
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strconv"
"strings"
)
type GetDatasetListLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetDatasetListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDatasetListLogic {
return &GetDatasetListLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// find datasetList
func (l *GetDatasetListLogic) GetDatasetList(in *modelarts.DataSetReq) (*modelarts.DataSetResp, error) {
projectId := in.ProjectId
var resp modelarts.DataSetResp
offset := strconv.Itoa(int(in.Offset))
judgeLimit := strconv.Itoa(int(in.Limit))
var limit string
if judgeLimit != "0" {
limit = strconv.Itoa(int(in.Limit))
} else {
limit = "10"
}
//根据智算类型判断走华为智算还是南京智算
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)
}
return &resp, nil
}

View File

@ -1,106 +0,0 @@
package logic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strconv"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
)
type GetExportTasksOfDatasetLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetExportTasksOfDatasetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetExportTasksOfDatasetLogic {
return &GetExportTasksOfDatasetLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
//type Pppp struct {
// TotalCount int `json:"total_count"`
// ExportTasks []*Modelarts.ExportTaskStatus `json:"export_tasks"`
//}
func (l *GetExportTasksOfDatasetLogic) GetExportTasksOfDataset(in *modelarts.GetExportTasksOfDatasetReq) (*modelarts.GetExportTasksOfDatasetResp, error) {
var resp modelarts.GetExportTasksOfDatasetResp
offset := strconv.Itoa(int(in.Offset))
judgeLimit := strconv.Itoa(int(in.Limit))
var limit string
if judgeLimit != "0" {
limit = strconv.Itoa(int(in.Limit))
} else {
limit = "10"
}
//根据智算类型判断走华为智算还是南京智算
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)
}
return &resp, nil
}

View File

@ -1,94 +0,0 @@
package logic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type GetExportTaskStatusOfDatasetLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetExportTaskStatusOfDatasetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetExportTaskStatusOfDatasetLogic {
return &GetExportTaskStatusOfDatasetLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *GetExportTaskStatusOfDatasetLogic) GetExportTaskStatusOfDataset(in *modelarts.GetExportTaskStatusOfDatasetReq) (*modelarts.GetExportTaskStatusOfDatasetResp, error) {
var resp modelarts.GetExportTaskStatusOfDatasetResp
//根据智算类型判断走华为智算还是南京智算
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)
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)
}
return &resp, nil
}

View File

@ -1,99 +0,0 @@
package logic
import (
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"log"
"net/http"
"strconv"
"strings"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type GetImportTaskListLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetImportTaskListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetImportTaskListLogic {
return &GetImportTaskListLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// find taskList 查询数据集导入任务列表
func (l *GetImportTaskListLogic) GetImportTaskList(in *modelarts.ListImportTasksReq) (*modelarts.ListImportTasksResp, error) {
var resp modelarts.ListImportTasksResp
judgeLimit := strconv.Itoa(int(in.Limit))
offset := strconv.Itoa(int(in.Offset))
token := common.GetToken()
var limit string
if judgeLimit != "0" {
limit = strconv.Itoa(int(in.Limit))
} else {
limit = "10"
}
//根据智算类型判断走华为智算还是南京智算
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)
}
return &resp, nil
}

View File

@ -1,103 +0,0 @@
package logic
import (
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strconv"
"strings"
"github.com/zeromicro/go-zero/core/logx"
)
type GetListTrainingJobsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetListTrainingJobsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetListTrainingJobsLogic {
return &GetListTrainingJobsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// get ListTrainingJobs1
func (l *GetListTrainingJobsLogic) GetListTrainingJobs(in *modelarts.ListTrainingJobsreq) (*modelarts.ListTrainingJobsresp, error) {
var resp modelarts.ListTrainingJobsresp
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 {
limit = "10"
}
//根据智算类型判断走华为智算还是南京智算
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)
}
json.Unmarshal(body, &resp)
}
return &resp, nil
}

View File

@ -1,82 +0,0 @@
package logic
import (
"context"
"encoding/json"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"net/http"
"strings"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type GetNotebookStorageLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetNotebookStorageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetNotebookStorageLogic {
return &GetNotebookStorageLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *GetNotebookStorageLogic) GetNotebookStorage(in *modelarts.GetNotebookStorageReq) (*modelarts.GetNotebookStorageResp, error) {
var resp modelarts.GetNotebookStorageResp
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{}
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)
}
return &resp, nil
}

View File

@ -1,88 +0,0 @@
package logic
import (
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"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
}

View File

@ -1,83 +0,0 @@
package logic
import (
"context"
"encoding/json"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"net/http"
"strings"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type GetVisualizationJobLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetVisualizationJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVisualizationJobLogic {
return &GetVisualizationJobLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// visualization-jobs
func (l *GetVisualizationJobLogic) GetVisualizationJob(in *modelarts.GetVisualizationJobReq) (*modelarts.GetVisualizationJobResp, error) {
var resp modelarts.GetVisualizationJobResp
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()
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)
}
return &resp, nil
}

View File

@ -0,0 +1,44 @@
package imagesservicelogic
import (
"bytes"
"context"
"encoding/json"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateNamespaceLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateNamespaceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateNamespaceLogic {
return &CreateNamespaceLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// CreateNamespace 创建组织
func (l *CreateNamespaceLogic) CreateNamespace(in *modelarts.NamespaceReq) (*modelarts.Resp, error) {
apiUrl := "v2/manage/namespaces"
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
url := platform.SwrEndpoint + apiUrl
var resp modelarts.Resp
reqByte, err := json.Marshal(in)
body, err := util.SendRequest("POST", url, bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,47 @@
package imagesservicelogic
import (
"bytes"
"context"
"encoding/json"
"fmt"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateRepoLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateRepoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateRepoLogic {
return &CreateRepoLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 在组织下创建镜像仓库
func (l *CreateRepoLogic) CreateRepo(in *modelarts.CreateRepoReq) (*modelarts.Resp, error) {
var resp modelarts.Resp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
swrUrl := platform.SwrApiEndpoint
url := swrUrl + fmt.Sprintf("v2/manage/namespaces/%s/repos", in.Namespace)
reqByte, err := json.Marshal(in)
body, err := util.SendRequest("POST", url, bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,43 @@
package imagesservicelogic
import (
"context"
"encoding/json"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteNamespacesLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteNamespacesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteNamespacesLogic {
return &DeleteNamespacesLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 删除组织
func (l *DeleteNamespacesLogic) DeleteNamespaces(in *modelarts.NamespaceReq) (*modelarts.Resp, error) {
var resp modelarts.Resp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
swrUrl := platform.SwrApiEndpoint
url := swrUrl + "v2/manage/namespaces/" + in.Namespace
body, err := util.SendRequest("DELETE", url, nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,47 @@
package imagesservicelogic
import (
"bytes"
"context"
"fmt"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteRepoLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteRepoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteRepoLogic {
return &DeleteRepoLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 删除组织下的镜像仓库
func (l *DeleteRepoLogic) DeleteRepo(in *modelarts.DeleteRepoReq) (*modelarts.Resp, error) {
var resp modelarts.Resp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
swrUrl := platform.SwrApiEndpoint
url := swrUrl + fmt.Sprintf("v2/manage/namespaces/%s/repos/%s", in.Namespace, in.Repository)
reqByte, err := json.Marshal(in)
body, _ := util.SendRequest("DELETE", url, bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,45 @@
package imagesservicelogic
import (
"bytes"
"context"
"fmt"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteRepoTagLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteRepoTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteRepoTagLogic {
return &DeleteRepoTagLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 删除指定tag的镜像
func (l *DeleteRepoTagLogic) DeleteRepoTag(in *modelarts.DeleteRepoTagReq) (*modelarts.Resp, error) {
var resp modelarts.Resp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
swrUrl := platform.SwrApiEndpoint
url := swrUrl + fmt.Sprintf("v2/manage/namespaces/%s/repos/%s/tags/%s", in.Namespace, in.Repository, in.Tag)
reqByte, err := json.Marshal(in)
body, _ := util.SendRequest("DELETE", url, bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,41 @@
package imagesservicelogic
import (
"context"
"os"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type DownloadFileLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDownloadFileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DownloadFileLogic {
return &DownloadFileLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 镜像下载
func (l *DownloadFileLogic) DownloadFile(in *modelarts.FileRequest) (*modelarts.FileData, error) {
//获取项目路径
dir, _ := os.Getwd()
logx.Infof("项目路径 dir: %s", dir)
// 在这里实现文件下载逻辑,例如从指定位置读取文件内容并返回
filename := in.FileName
filePath := "./uploads/" + filename
content, err := os.ReadFile(filePath)
if err != nil {
return nil, err
}
return &modelarts.FileData{Filename: filename, Content: content}, nil
}

View File

@ -0,0 +1,31 @@
package imagesservicelogic
import (
"context"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type GetMetricsPoolsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetMetricsPoolsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetMetricsPoolsLogic {
return &GetMetricsPoolsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 查询资源实时利用率
func (l *GetMetricsPoolsLogic) GetMetricsPools(in *modelarts.MetricsPoolsRequest) (*modelarts.MetricsPoolsResponse, error) {
// todo: add your logic here and delete this line
return &modelarts.MetricsPoolsResponse{}, nil
}

View File

@ -0,0 +1,44 @@
package imagesservicelogic
import (
"bytes"
"context"
"encoding/json"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type ListNamespacesLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListNamespacesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListNamespacesLogic {
return &ListNamespacesLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 查询组织列表
func (l *ListNamespacesLogic) ListNamespaces(in *modelarts.ListNamespacesReq) (*modelarts.ListNamespacesResp, error) {
var resp modelarts.ListNamespacesResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
url := platform.SwrApiEndpoint + "v2/manage/namespaces"
reqByte, err := json.Marshal(in)
body, _ := util.SendRequest("GET", url, bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,64 @@
package imagesservicelogic
import (
"bytes"
"context"
"fmt"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"k8s.io/apimachinery/pkg/util/json"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type ListReposDetailsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListReposDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListReposDetailsLogic {
return &ListReposDetailsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 查询镜像仓库列表
func (l *ListReposDetailsLogic) ListReposDetails(in *modelarts.ListRepoReq) (*modelarts.ListReposDetailsResp, error) {
var resp modelarts.ListReposDetailsResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
swrUrl := platform.SwrApiEndpoint
var baseURL = "v2/manage/repos?"
if in.Offset == "" {
in.Offset = "0"
}
if in.Limit == "" {
in.Limit = "10"
}
filterUrl := fmt.Sprintf("filter=limit::%s|offset::%s", in.Limit, in.Offset)
if in.Namespace != "" {
baseURL = baseURL + filterUrl + fmt.Sprintf("|namespace::%s", in.Namespace)
} else {
baseURL = baseURL + filterUrl
}
url := swrUrl + baseURL
reqByte, err := json.Marshal(in)
body, err := util.SendRequest("GET", url, bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
err = json.Unmarshal(*body, &resp)
if resp.Errors != nil {
return &resp, nil
}
err = json.Unmarshal(*body, &resp.Items)
return &resp, nil
}

View File

@ -0,0 +1,47 @@
package imagesservicelogic
import (
"bytes"
"context"
"fmt"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
"github.com/zeromicro/go-zero/core/logx"
)
type ListRepositoryTagsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListRepositoryTagsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListRepositoryTagsLogic {
return &ListRepositoryTagsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 查询镜像tag列表
func (l *ListRepositoryTagsLogic) ListRepositoryTags(in *modelarts.ListRepositoryTagsReq) (*modelarts.ListRepositoryTagsResp, error) {
var resp modelarts.ListRepositoryTagsResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
swrUrl := platform.SwrApiEndpoint
url := swrUrl + fmt.Sprintf("v2/manage/namespaces/%s/repos/%s/tags", in.Namespace, in.Repository)
reqByte, err := json.Marshal(in)
body, err := util.SendRequest("GET", url, bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp.Items)
return &resp, nil
}

View File

@ -0,0 +1,45 @@
package imagesservicelogic
import (
"context"
"encoding/json"
"fmt"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type ShowNamespaceLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewShowNamespaceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowNamespaceLogic {
return &ShowNamespaceLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 获取组织详情
func (l *ShowNamespaceLogic) ShowNamespace(in *modelarts.NamespaceReq) (*modelarts.NamespaceInfo, error) {
var resp modelarts.NamespaceInfo
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
swrUrl := platform.SwrApiEndpoint
url := swrUrl + fmt.Sprintf("v2/manage/namespaces/%s", in.Namespace)
body, err := util.SendRequest("GET", url, nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,46 @@
package imagesservicelogic
import (
"bytes"
"context"
"fmt"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
"github.com/zeromicro/go-zero/core/logx"
)
type ShowRepositoryLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewShowRepositoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowRepositoryLogic {
return &ShowRepositoryLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// ShowRepository 查询镜像仓库概要信息
func (l *ShowRepositoryLogic) ShowRepository(in *modelarts.ShowRepositoryReq) (*modelarts.ShowRepositoryResp, error) {
var resp modelarts.ShowRepositoryResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
swrUrl := platform.SwrApiEndpoint
url := swrUrl + fmt.Sprintf("v2/manage/namespaces/%s/repos/%s", in.Namespace, in.Repository)
reqByte, err := json.Marshal(in)
body, err := util.SendRequest("GET", url, bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,48 @@
package imagesservicelogic
import (
"bytes"
"context"
"fmt"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
"github.com/zeromicro/go-zero/core/logx"
)
type UpdateRepoLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewUpdateRepoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateRepoLogic {
return &UpdateRepoLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// UpdateRepo 更新镜像仓库的概要信息
func (l *UpdateRepoLogic) UpdateRepo(in *modelarts.UpdateRepoReq) (*modelarts.Resp, error) {
var resp modelarts.Resp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
swrUrl := platform.SwrApiEndpoint
url := swrUrl + fmt.Sprintf("v2/manage/namespaces/%s/repos/%s", in.Namespace, in.Repository)
reqByte, err := json.Marshal(in)
body, _ := util.SendRequest("PATCH", url, bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,39 @@
package imagesservicelogic
import (
"context"
"log"
"os"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type UploadFileLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewUploadFileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UploadFileLogic {
return &UploadFileLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 镜像上传
func (l *UploadFileLogic) UploadFile(in *modelarts.FileRequest) (*modelarts.FileResponse, error) {
// 在这里实现文件上传逻辑,例如将文件保存到指定位置或进行其他处理
log.Printf("Uploading file: %s", in.FileName)
// 将请求中的文件内容写入文件
filePath := "./uploads/" + in.FileName
err := os.WriteFile(filePath, in.Content, 0644)
if err != nil {
return nil, err
}
return &modelarts.FileResponse{FilePath: filePath}, nil
}

View File

@ -1,96 +0,0 @@
package logic
import (
"bytes"
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strconv"
)
type ListAlgorithmsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListAlgorithmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListAlgorithmsLogic {
return &ListAlgorithmsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// ListAlgorithms 查询算法
func (l *ListAlgorithmsLogic) ListAlgorithms(in *modelarts.ListAlgorithmsReq) (*modelarts.ListAlgorithmsResp, error) {
var resp modelarts.ListAlgorithmsResp
offset := strconv.Itoa(int(in.Offset))
judgeLimit := strconv.Itoa(int(in.Limit))
var limit string
if judgeLimit != "0" {
limit = strconv.Itoa(int(in.Limit))
} else {
limit = "10"
}
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)
}
return &resp, nil
}

View File

@ -1,98 +0,0 @@
package logic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strconv"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type ListClustersLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListClustersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListClustersLogic {
return &ListClustersLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *ListClustersLogic) ListClusters(in *modelarts.ListClustersReq) (*modelarts.ListClustersResp, error) {
// todo: add your logic here and delete this line
var resp modelarts.ListClustersResp
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 {
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
}

View File

@ -1,88 +0,0 @@
package logic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"bytes"
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type ListModelsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListModelsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListModelsLogic {
return &ListModelsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *ListModelsLogic) ListModels(in *modelarts.ListModelReq) (*modelarts.ListModelResp, error) {
// todo: add your logic here and delete this line
var resp modelarts.ListModelResp
//根据智算类型判断走华为智算还是南京智算
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)
}
return &resp, nil
}

View File

@ -1,101 +0,0 @@
package logic
import (
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
)
type ListNotebookLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListNotebookLogic {
return &ListNotebookLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// notebook task
func (l *ListNotebookLogic) ListNotebook(in *modelarts.ListNotebookReq) (*modelarts.ListNotebookResp, error) {
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)
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)
}
return resp, nil
}

View File

@ -1,99 +0,0 @@
package logic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"bytes"
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strconv"
)
type ListServicesLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListServicesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListServicesLogic {
return &ListServicesLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *ListServicesLogic) ListServices(in *modelarts.ListServicesReq) (*modelarts.ListServicesResp, error) {
var resp modelarts.ListServicesResp
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 {
limit = "10"
}
//根据智算类型判断走华为智算还是南京智算
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)
}
return &resp, nil
}

View File

@ -1,85 +0,0 @@
package logic
import (
"bytes"
"context"
"fmt"
"github.com/JCCE-nudt/apigw-go-sdk/core"
"github.com/bitly/go-simplejson"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/common"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strconv"
)
type ListTrainingJobConfigLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListTrainingJobConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListTrainingJobConfigLogic {
return &ListTrainingJobConfigLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// ListTrainingJobConfig 查询训练作业参数
func (l *ListTrainingJobConfigLogic) ListTrainingJobConfig(in *modelarts.ListTrainingJobConfigReq) (*modelarts.ListTrainingJobConfigResp, error) {
var resp modelarts.ListTrainingJobConfigResp
perPage := strconv.Itoa(int(in.PerPage))
page := strconv.Itoa(int(in.Page))
//根据智算类型判断走华为智算还是南京智算
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)
}
return &resp, nil
}

View File

@ -0,0 +1,34 @@
package modelartsservicelogic
import (
"bytes"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"k8s.io/apimachinery/pkg/util/json"
"log"
)
type ChatglmReq struct {
Promt string `json:"promt,omitempty"`
Platform string `json:"platform,omitempty"`
ServiceId string `json:"service_id,omitempty"`
}
type ChatglmResp struct {
}
// 文本推理 Chatglm
func ChatglmReasoning(req ChatglmReq) (ChatglmResp, error) {
var resp ChatglmResp
platform, err := util.GetModelArtsConfWithPlatform(req.Platform)
if err != nil {
log.Print(err)
}
reqByte, err := json.Marshal(req)
body, err := util.SendRequest("POST", platform.Endpoint+"v1/infers/"+req.ServiceId+"/image",
bytes.NewBuffer(reqByte), req.Platform)
if err != nil {
log.Print(err)
}
json.Unmarshal(*body, &resp)
return resp, nil
}

View File

@ -0,0 +1,44 @@
package modelartsservicelogic
import (
"bytes"
"context"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"k8s.io/apimachinery/pkg/util/json"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type ChatglmReasoningLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewChatglmReasoningLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ChatglmReasoningLogic {
return &ChatglmReasoningLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *ChatglmReasoningLogic) ChatglmReasoning(in *modelarts.ChatglmReasoningReq) (*modelarts.ChatglmReasoningResp, error) {
// todo: add your logic here and delete this line
var resp modelarts.ChatglmReasoningResp
/*platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}*/
reqByte, err := json.Marshal(in)
body, err := util.SendRequest("GET", "https://modelarts-inference.cloudbrain2.pcl.ac.cn/v1/infers/3509cf9e-dfa6-4c65-aaab-a5c0698788f8",
bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,42 @@
package modelartsservicelogic
import (
"bytes"
"context"
"encoding/json"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
)
type CreateAlgorithmLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateAlgorithmLogic {
return &CreateAlgorithmLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// CreateAlgorithm 创建算法
func (l *CreateAlgorithmLogic) CreateAlgorithm(in *modelarts.CreateAlgorithmReq) (*modelarts.CreateAlgorithmResp, error) {
var resp modelarts.CreateAlgorithmResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
reqByte, err := json.Marshal(in)
body, err := util.SendRequest("POST", platform.Endpoint+"v2/"+platform.ProjectId+"/algorithms",
bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,43 @@
package modelartsservicelogic
import (
"bytes"
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
)
type CreateDataSetLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateDataSetLogic {
return &CreateDataSetLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// create DateSet
func (l *CreateDataSetLogic) CreateDataSet(in *modelarts.CreateDataSetReq) (*modelarts.CreateDataSetResq, error) {
var resp modelarts.CreateDataSetResq
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
reqByte, err := json.Marshal(in)
body, err := util.SendRequest("POST", platform.Endpoint+"v2/"+platform.ProjectId+"/datasets",
bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,54 @@
package modelartsservicelogic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"bytes"
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
)
type CreateModelLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateModelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateModelLogic {
return &CreateModelLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// model management
func (l *CreateModelLogic) CreateModel(in *modelarts.CreateModelReq) (*modelarts.CreateModelResp, error) {
var resp modelarts.CreateModelResp
platform, err := util.GetModelArtsConfWithPlatform(l.svcCtx.Config.ModelArtsConf.Platform)
if err != nil {
return nil, err
}
reqByte, err := json.Marshal(in)
body, err := util.SendRequest("POST", platform.Endpoint+"v1/"+platform.ProjectId+"/models",
bytes.NewBuffer(reqByte), l.svcCtx.Config.ModelArtsConf.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
if len(resp.ModelId) != 0 {
resp.Code = 200
resp.Msg = "Success"
} else {
resp.Code = 201
resp.Msg = "Create Model is fail"
}
return &resp, nil
}

View File

@ -0,0 +1,44 @@
package modelartsservicelogic
import (
"bytes"
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
)
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 *modelarts.CreateNotebookReq) (*modelarts.CreateNotebookResp, error) {
resp := &modelarts.CreateNotebookResp{}
platform, err := util.GetModelArtsConfWithPlatform(l.svcCtx.Config.ModelArtsConf.Platform)
if err != nil {
return nil, err
}
reqByte, err := json.Marshal(in)
body, err := util.SendRequest("POST", platform.Endpoint+"v1/"+platform.ProjectId+"/notebooks",
bytes.NewBuffer(reqByte), l.svcCtx.Config.ModelArtsConf.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return resp, nil
}

View File

@ -0,0 +1,49 @@
package modelartsservicelogic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"bytes"
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
)
type CreateProcessorTaskLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateProcessorTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateProcessorTaskLogic {
return &CreateProcessorTaskLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// processor task
func (l *CreateProcessorTaskLogic) CreateProcessorTask(in *modelarts.CreateProcessorTaskReq) (*modelarts.CreateProcessorTaskResp, error) {
var resp modelarts.CreateProcessorTaskResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
reqByte, err := json.Marshal(in)
body, err := util.SendRequest("POST", platform.Endpoint+"v2/"+platform.ProjectId+"/processor-tasks/",
bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,52 @@
package modelartsservicelogic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"bytes"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
)
import (
"context"
)
type CreateServiceLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateServiceLogic {
return &CreateServiceLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// service management
func (l *CreateServiceLogic) CreateService(in *modelarts.CreateServiceReq) (*modelarts.CreateServiceResp, error) {
var resp modelarts.CreateServiceResp
platform, err := util.GetModelArtsConfWithPlatform(l.svcCtx.Config.ModelArtsConf.Platform)
if err != nil {
return nil, err
}
reqByte, err := json.Marshal(in)
body, err := util.SendRequest("POST", platform.Endpoint+"v1/"+platform.ProjectId+"/services",
bytes.NewBuffer(reqByte), l.svcCtx.Config.ModelArtsConf.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,45 @@
package modelartsservicelogic
import (
"bytes"
"context"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateTaskLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTaskLogic {
return &CreateTaskLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// creat task 创建导入任务
func (l *CreateTaskLogic) CreateTask(in *modelarts.ImportTaskDataReq) (*modelarts.ImportTaskDataResp, error) {
var resp modelarts.ImportTaskDataResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
reqByte, err := json.Marshal(in)
body, err := util.SendRequest("POST", platform.Endpoint+"v2/"+platform.ProjectId+"/datasets"+in.DatasetId+"/import-tasks",
bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,44 @@
package modelartsservicelogic
import (
"bytes"
"context"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateTrainingJobConfigLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateTrainingJobConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTrainingJobConfigLogic {
return &CreateTrainingJobConfigLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// CreateTrainingJobConfig 创建训练作业参数
func (l *CreateTrainingJobConfigLogic) CreateTrainingJobConfig(in *modelarts.CreateTrainingJobConfigReq) (*modelarts.CreateTrainingJobConfigResp, error) {
var resp modelarts.CreateTrainingJobConfigResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
reqByte, err := json.Marshal(in)
body, err := util.SendRequest("POST", platform.Endpoint+"v1/"+platform.ProjectId+"/training-job-configs",
bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,48 @@
package modelartsservicelogic
import (
"bytes"
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
"reflect"
)
type CreateTrainingJobLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateTrainingJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTrainingJobLogic {
return &CreateTrainingJobLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// CreateTrainingJob 创建训练作业
func (l *CreateTrainingJobLogic) CreateTrainingJob(in *modelarts.CreateTrainingJobReq) (*modelarts.CreateTrainingJobResp, error) {
var resp modelarts.CreateTrainingJobResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
if reflect.ValueOf(in.Spec.LogExportPath).IsNil() {
in.Spec.LogExportPath = &modelarts.LogExportPath{ObsUrl: l.svcCtx.Config.ModelArtsConf.JobLogsPath}
}
reqByte, err := json.Marshal(in)
body, err := util.SendRequest("POST", platform.Endpoint+"v2/"+platform.ProjectId+"/training-jobs",
bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,44 @@
package modelartsservicelogic
import (
"bytes"
"context"
"encoding/json"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateVisualizationJobLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateVisualizationJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateVisualizationJobLogic {
return &CreateVisualizationJobLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *CreateVisualizationJobLogic) CreateVisualizationJob(in *modelarts.CreateVisualizationJobReq) (*modelarts.CreateVisualizationJobResp, error) {
var resp modelarts.CreateVisualizationJobResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
reqByte, err := json.Marshal(in)
body, err := util.SendRequest("POST", platform.Endpoint+"v1/"+platform.ProjectId+"/visualization-jobs",
bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,41 @@
package modelartsservicelogic
import (
"context"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteAlgorithmsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteAlgorithmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteAlgorithmsLogic {
return &DeleteAlgorithmsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// DeleteAlgorithms 删除算法
func (l *DeleteAlgorithmsLogic) DeleteAlgorithms(in *modelarts.DeleteAlgorithmsReq) (*modelarts.DeleteAlgorithmsResp, error) {
var resp modelarts.DeleteAlgorithmsResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
body, err := util.SendRequest("DELETE", platform.Endpoint+"v2/"+platform.ProjectId+"/algorithms/"+in.AlgorithmId,
nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,42 @@
package modelartsservicelogic
import (
"context"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
"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),
}
}
// create DateSet
func (l *DeleteDataSetLogic) DeleteDataSet(in *modelarts.DeleteDataSetReq) (*modelarts.DeleteDataSetResq, error) {
var resp modelarts.DeleteDataSetResq
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
body, err := util.SendRequest("DELETE", platform.Endpoint+"v2/"+platform.ProjectId+"/datasets/"+in.DatasetId,
nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,47 @@
package modelartsservicelogic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"context"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteModelLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteModelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteModelLogic {
return &DeleteModelLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *DeleteModelLogic) DeleteModel(in *modelarts.DeleteModelReq) (*modelarts.DeleteModelResp, error) {
var resp modelarts.DeleteModelResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
body, err := util.SendRequest("DELETE", platform.Endpoint+platform.ProjectId+"/models/"+in.ModelId,
nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,30 @@
package modelartsservicelogic
import (
"context"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"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 *modelarts.DeleteImagesReq) (*modelarts.DeleteImagesResp, error) {
// todo: add your logic here and delete this line
return &modelarts.DeleteImagesResp{}, nil
}

View File

@ -0,0 +1,44 @@
package modelartsservicelogic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
)
type DeleteServiceLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteServiceLogic {
return &DeleteServiceLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *DeleteServiceLogic) DeleteService(in *modelarts.DeleteServiceReq) (*modelarts.DeleteServiceResp, error) {
var resp modelarts.DeleteServiceResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
body, err := util.SendRequest("DELETE", platform.Endpoint+platform.ProjectId+"/services/"+in.ServiceId,
nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,42 @@
package modelartsservicelogic
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
)
type DeleteTrainingJobConfigLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteTrainingJobConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTrainingJobConfigLogic {
return &DeleteTrainingJobConfigLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// DeleteTrainingJobConfig 删除训练作业参数
func (l *DeleteTrainingJobConfigLogic) DeleteTrainingJobConfig(in *modelarts.DeleteTrainingJobConfigReq) (*modelarts.DeleteTrainingJobConfigResp, error) {
var resp modelarts.DeleteTrainingJobConfigResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
body, err := util.SendRequest("DELETE", platform.Endpoint+"v1/"+platform.ProjectId+"/training-job-configs/"+in.ConfigName,
nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,43 @@
package modelartsservicelogic
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
)
type DeleteTrainingJobLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteTrainingJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTrainingJobLogic {
return &DeleteTrainingJobLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// DeleteTrainingJobConfig 删除训练作业
func (l *DeleteTrainingJobLogic) DeleteTrainingJob(in *modelarts.DeleteTrainingJobReq) (*modelarts.DeleteTrainingJobResp, error) {
var resp modelarts.DeleteTrainingJobResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
body, err := util.SendRequest("DELETE", platform.Endpoint+"v2/"+platform.ProjectId+"/training-jobs/"+in.TrainingJobId,
nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,48 @@
package modelartsservicelogic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
)
type DescribeProcessorTaskLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDescribeProcessorTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DescribeProcessorTaskLogic {
return &DescribeProcessorTaskLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *DescribeProcessorTaskLogic) DescribeProcessorTask(in *modelarts.DescribeProcessorTaskReq) (*modelarts.DescribeProcessorTaskResp, error) {
var resp modelarts.DescribeProcessorTaskResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
body, err := util.SendRequest("GET", platform.Endpoint+"v2/"+platform.ProjectId+"/processor-tasks/"+in.TaskId,
nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,51 @@
package modelartsservicelogic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"bytes"
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
_ "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
)
type ExportTaskLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewExportTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ExportTaskLogic {
return &ExportTaskLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// ExportTask for modelarts
func (l *ExportTaskLogic) ExportTask(in *modelarts.ExportTaskReq) (*modelarts.ExportTaskDataResp, error) {
var resp modelarts.ExportTaskDataResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
reqByte, err := json.Marshal(in)
body, err := util.SendRequest("POST", platform.Endpoint+"v2/"+platform.ProjectId+"/datasets/"+in.DatasetId+"/export-tasks",
bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,45 @@
package modelartsservicelogic
import (
"context"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
"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) {
var resp modelarts.ListAiEnginesResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
body, err := util.SendRequest("GET", platform.Endpoint+"v2/"+platform.ProjectId+"/training-job-engines",
nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,52 @@
package modelartsservicelogic
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
"strconv"
)
type GetDatasetListLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetDatasetListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDatasetListLogic {
return &GetDatasetListLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// find datasetList
func (l *GetDatasetListLogic) GetDatasetList(in *modelarts.DataSetReq) (*modelarts.DataSetResp, error) {
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
var resp modelarts.DataSetResp
offset := strconv.Itoa(int(in.Offset))
judgeLimit := strconv.Itoa(int(in.Limit))
var limit string
if judgeLimit != "0" {
limit = strconv.Itoa(int(in.Limit))
} else {
limit = "10"
}
url := fmt.Sprintf("%sv2/%s/datasets?offset=%s&limit=%s&dataset_version=%s", platform.Endpoint, platform.ProjectId, offset, limit, in.DatasetVersion)
body, err := util.SendRequest("GET", url,
nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,57 @@
package modelartsservicelogic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"context"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
"strconv"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
)
type GetExportTasksOfDatasetLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetExportTasksOfDatasetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetExportTasksOfDatasetLogic {
return &GetExportTasksOfDatasetLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *GetExportTasksOfDatasetLogic) GetExportTasksOfDataset(in *modelarts.GetExportTasksOfDatasetReq) (*modelarts.GetExportTasksOfDatasetResp, error) {
var resp modelarts.GetExportTasksOfDatasetResp
offset := strconv.Itoa(int(in.Offset))
judgeLimit := strconv.Itoa(int(in.Limit))
var limit string
if judgeLimit != "0" {
limit = strconv.Itoa(int(in.Limit))
} else {
limit = "10"
}
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
body, err := util.SendRequest("GET", platform.Endpoint+"v2/"+platform.ProjectId+"/datasets/"+in.DatasetId+"/export-tasks?limit="+limit+"&offset="+offset,
nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,49 @@
package modelartsservicelogic
/*
desc: "AI core微服务"
author: "xie"
*/
import (
"context"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
"github.com/zeromicro/go-zero/core/logx"
)
type GetExportTaskStatusOfDatasetLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetExportTaskStatusOfDatasetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetExportTaskStatusOfDatasetLogic {
return &GetExportTaskStatusOfDatasetLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *GetExportTaskStatusOfDatasetLogic) GetExportTaskStatusOfDataset(in *modelarts.GetExportTaskStatusOfDatasetReq) (*modelarts.GetExportTaskStatusOfDatasetResp, error) {
var resp modelarts.GetExportTaskStatusOfDatasetResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
body, err := util.SendRequest("GET", platform.Endpoint+"v2/"+platform.ProjectId+"/datasets/"+in.ResourceId+"/export-tasks/"+in.TaskId,
nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,53 @@
package modelartsservicelogic
import (
"context"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
"strconv"
"github.com/zeromicro/go-zero/core/logx"
)
type GetImportTaskListLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetImportTaskListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetImportTaskListLogic {
return &GetImportTaskListLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// find taskList 查询数据集导入任务列表
func (l *GetImportTaskListLogic) GetImportTaskList(in *modelarts.ListImportTasksReq) (*modelarts.ListImportTasksResp, error) {
var resp modelarts.ListImportTasksResp
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 {
limit = "10"
}
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
body, err := util.SendRequest("GET", platform.Endpoint+"v2/"+platform.ProjectId+"/datasets/"+in.DatasetId+"/import-tasks?limit="+limit+"&offset="+offset,
nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,51 @@
package modelartsservicelogic
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
"strconv"
)
type GetListTrainingJobsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetListTrainingJobsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetListTrainingJobsLogic {
return &GetListTrainingJobsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// get GetListTrainingJobs 查询训练作业列表
func (l *GetListTrainingJobsLogic) GetListTrainingJobs(in *modelarts.ListTrainingJobsreq) (*modelarts.ListTrainingJobsresp, error) {
var resp modelarts.ListTrainingJobsresp
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 {
limit = "10"
}
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
body, err := util.SendRequest("POST", platform.Endpoint+"v2/"+platform.ProjectId+"/training-job-searches?offset="+offset+"&"+"limit="+limit,
nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,54 @@
package modelartsservicelogic
import (
"context"
"fmt"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"k8s.io/apimachinery/pkg/util/json"
"strconv"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type GetNotebookFlavorsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetNotebookFlavorsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetNotebookFlavorsLogic {
return &GetNotebookFlavorsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *GetNotebookFlavorsLogic) GetNotebookFlavors(in *modelarts.GetNotebookFlavorsReq) (*modelarts.GetNotebookFlavorsResp, error) {
// todo: add your logic here and delete this line
platform, err := util.GetModelArtsConfWithPlatform(l.svcCtx.Config.ModelArtsConf.Platform)
if err != nil {
return nil, err
}
var resp modelarts.GetNotebookFlavorsResp
offset := strconv.Itoa(int(in.OffSet))
judgeLimit := strconv.Itoa(int(in.Limit))
var limit string
if judgeLimit != "0" {
limit = strconv.Itoa(int(in.Limit))
} else {
limit = "10"
}
url := fmt.Sprintf("%sv1/%s/notebooks/flavors?offset=%s&limit=%s&type=%s&category=%s", platform.Endpoint, platform.ProjectId, offset, limit, in.Type, in.Category)
body, err := util.SendRequest("GET", url,
nil, l.svcCtx.Config.ModelArtsConf.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,43 @@
package modelartsservicelogic
import (
"context"
"encoding/json"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type GetNotebookStorageLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetNotebookStorageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetNotebookStorageLogic {
return &GetNotebookStorageLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *GetNotebookStorageLogic) GetNotebookStorage(in *modelarts.GetNotebookStorageReq) (*modelarts.GetNotebookStorageResp, error) {
var resp modelarts.GetNotebookStorageResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
body, err := util.SendRequest("GET", platform.Endpoint+"v1/"+platform.ProjectId+"/notebooks"+in.InstanceId+"/storage",
nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,46 @@
package modelartsservicelogic
import (
"context"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"k8s.io/apimachinery/pkg/util/json"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type GetPoolsRuntimeMetricsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetPoolsRuntimeMetricsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPoolsRuntimeMetricsLogic {
return &GetPoolsRuntimeMetricsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// pools
func (l *GetPoolsRuntimeMetricsLogic) GetPoolsRuntimeMetrics(in *modelarts.GetPoolsRuntimeMetricsReq) (*modelarts.GetPoolsRuntimeMetricsResp, error) {
// todo: add your logic here and delete this line
var resp modelarts.GetPoolsRuntimeMetricsResp
platform, err := util.GetModelArtsConfWithPlatform(l.svcCtx.Config.ModelArtsConf.Platform)
if err != nil {
return nil, err
}
body, err := util.SendRequest("GET", platform.Endpoint+"v2/"+platform.ProjectId+"/metrics/runtime/pools",
nil, l.svcCtx.Config.ModelArtsConf.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,46 @@
package modelartsservicelogic
import (
"context"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"k8s.io/apimachinery/pkg/util/json"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type GetResourceFlavorsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetResourceFlavorsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetResourceFlavorsLogic {
return &GetResourceFlavorsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// ResourceFlavor
func (l *GetResourceFlavorsLogic) GetResourceFlavors(in *modelarts.GetResourceFlavorsReq) (*modelarts.GetResourceFlavorsResp, error) {
// todo: add your logic here and delete this line
var resp modelarts.GetResourceFlavorsResp
platform, err := util.GetModelArtsConfWithPlatform(l.svcCtx.Config.ModelArtsConf.Platform)
if err != nil {
return nil, err
}
body, err := util.SendRequest("GET", platform.Endpoint+"v1/"+platform.ProjectId+"/resourceflavors",
nil, l.svcCtx.Config.ModelArtsConf.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -1,4 +1,4 @@
package logic
package modelartsservicelogic
import (
"bytes"
@ -9,8 +9,8 @@ import (
"net/http"
"time"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
@ -31,7 +31,6 @@ func NewGetTokenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetToken
// getToken
func (l *GetTokenLogic) GetToken(in *modelarts.TokenReq) (*modelarts.TokenResp, error) {
// todo: add your logic here and delete this line
var resp modelarts.TokenResp
TokenUrl := "v3/auth/tokens"

View File

@ -0,0 +1,43 @@
package modelartsservicelogic
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"k8s.io/apimachinery/pkg/util/json"
)
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) {
var resp modelarts.TrainingJobFlavorsResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
body, err := util.SendRequest("GET", platform.Endpoint+"v2/"+platform.ProjectId+"/training-job-flavors?flavor_type="+in.FlavorType,
nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,51 @@
package modelartsservicelogic
import (
"context"
"fmt"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"k8s.io/apimachinery/pkg/util/json"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type GetTrainingJobLogsPreviewLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetTrainingJobLogsPreviewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTrainingJobLogsPreviewLogic {
return &GetTrainingJobLogsPreviewLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 查询训练作业指定任务的日志(预览)
func (l *GetTrainingJobLogsPreviewLogic) GetTrainingJobLogsPreview(in *modelarts.GetTrainingJobLogsPreviewReq) (*modelarts.GetTrainingJobLogsPreviewResp, error) {
var resp modelarts.GetTrainingJobLogsPreviewResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
url := fmt.Sprintf("%sv2/%s/training-jobs/%s/tasks/%s/logs/preview",
platform.Endpoint,
platform.ProjectId,
in.TrainingJobId,
in.TaskId)
body, err := util.SendRequest("GET", url,
nil, in.Platform)
if err != nil {
logx.Errorf("查询训练作业指定任务的日志(预览)失败,请求url: %s\n err%v", url, err)
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,44 @@
package modelartsservicelogic
import (
"context"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"k8s.io/apimachinery/pkg/util/json"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type GetTrainingJobsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetTrainingJobsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTrainingJobsLogic {
return &GetTrainingJobsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// GetTrainingJobs 查询训练详情
func (l *GetTrainingJobsLogic) GetTrainingJobs(in *modelarts.DetailTrainingJobsReq) (*modelarts.JobResponse, error) {
var resp modelarts.JobResponse
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
body, err := util.SendRequest("GET", platform.Endpoint+"v2/"+platform.ProjectId+"/training-jobs/"+in.TrainingJobId,
nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

View File

@ -0,0 +1,44 @@
package modelartsservicelogic
import (
"context"
"encoding/json"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type GetVisualizationJobLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetVisualizationJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVisualizationJobLogic {
return &GetVisualizationJobLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// visualization-jobs
func (l *GetVisualizationJobLogic) GetVisualizationJob(in *modelarts.GetVisualizationJobReq) (*modelarts.GetVisualizationJobResp, error) {
var resp modelarts.GetVisualizationJobResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
body, err := util.SendRequest("GET", platform.Endpoint+"v1/"+platform.ProjectId+"/visualization-jobs",
nil, in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}

Some files were not shown because too many files have changed in this diff Show More