Documentation
¶
Index ¶
- Constants
- Variables
- func BuildImagesByDockerfile(jobUuid, spaceUuid, spaceName, imagePath string) (string, string)
- func BuildSpaceTaskImage(spaceUuid string, files []models.SpaceFile) (bool, string, string, string, string, error)
- func CancelJob(c *gin.Context)
- func CheckWalletWhiteList(jobSourceURI string) bool
- func CronTaskForEcp()
- func DeploySpaceTask(jobSourceURI, hostName string, duration int, jobUuid string, taskUuid string, ...) string
- func DoProof(c *gin.Context)
- func DoUbiTaskForDocker(c *gin.Context)
- func DoUbiTaskForK8s(c *gin.Context)
- func ExtractExposedPort(dockerfilePath string) (string, error)
- func GenerateNodeID(cpRepoPath string) (string, string, string)
- func GetCpResource(c *gin.Context)
- func GetJobStatus(c *gin.Context)
- func GetNodeId(cpRepoPath string) string
- func GetNodeResource(allPods []corev1.Pod, node *corev1.Node) (map[string]int64, map[string]int64, *models.NodeResource)
- func GetOwnerAddressAndWorkerAddress() (string, string, error)
- func GetServiceProviderInfo(c *gin.Context)
- func GetSpaceLog(c *gin.Context)
- func GetTaskInfoOnChain(rpcName string, taskContract string) (ecp.ECPTaskTaskInfo, error)
- func InitComputingProvider(cpRepoPath string) string
- func ReNewJob(c *gin.Context)
- func ReceiveJob(c *gin.Context)
- func ReceiveUbiProofForDocker(c *gin.Context)
- func ReceiveUbiProofForK8s(c *gin.Context)
- func RedeployJob(c *gin.Context)
- func RemoveContainerIfExists(imageName string) error
- func RestartResourceExporter() error
- func RunContainer(imageName, dockerfilePath string) string
- func RunDockerCompose(dockerComposeContent, cpPath string) error
- func StatisticalSources(c *gin.Context)
- func StopPreviousServices(dockerComposeContent, cpPath string) error
- func SyncCpAccountInfo()
- func WhiteList(c *gin.Context)
- type ComposeApiService
- type CpInfoService
- type CpResourceSummary
- type CronTask
- type Deploy
- func (d *Deploy) DockerfileToK8s()
- func (d *Deploy) ModelInferenceToK8s() error
- func (d *Deploy) WithDockerfile(image, dockerfilePath string) *Deploy
- func (d *Deploy) WithGpuProductName(gpuProductName string) *Deploy
- func (d *Deploy) WithHardware(cpu, memory, storage int, gpuModel string, gpuNum int) *Deploy
- func (d *Deploy) WithImage(images string) *Deploy
- func (d *Deploy) WithModelSettingFile(modelsSettingFile string) *Deploy
- func (d *Deploy) WithSpaceInfo(spaceUuid, spaceName string) *Deploy
- func (d *Deploy) WithSpacePath(spacePath string) *Deploy
- func (d *Deploy) WithYamlInfo(yamlPath string) *Deploy
- func (d *Deploy) YamlToK8s()
- type DockerService
- func (ds *DockerService) BuildImage(buildPath, imageName string) error
- func (ds *DockerService) CheckRunningContainer(containerName string) (bool, error)
- func (ds *DockerService) CleanResource()
- func (ds *DockerService) ContainerCreateAndStart(config *container.Config, hostConfig *container.HostConfig, ...) error
- func (ds *DockerService) ContainerLogs(containerName string) (string, error)
- func (ds *DockerService) GetContainerLogStream(containerName string) (io.ReadCloser, error)
- func (ds *DockerService) PullImage(imageName string) error
- func (ds *DockerService) PushImage(imagesName string) error
- func (ds *DockerService) RemoveContainerByName(containerName string) error
- func (ds *DockerService) RemoveImage(imageId string) error
- type ErrorLine
- type JobService
- func (jobServ JobService) DeleteJobEntityBySpaceUuId(spaceUuid string) error
- func (jobServ JobService) DeleteJobs(spaceIds []string) (err error)
- func (jobServ JobService) GetJobEntityByJobUuid(jobUuid string) (models.JobEntity, error)
- func (jobServ JobService) GetJobEntityBySpaceUuid(spaceUuid string) (models.JobEntity, error)
- func (jobServ JobService) GetJobEntityByTaskUuid(taskUuid string) (models.JobEntity, error)
- func (jobServ JobService) GetJobList() (list []*models.JobEntity, err error)
- func (jobServ JobService) SaveJobEntity(job *models.JobEntity) (err error)
- func (jobServ JobService) UpdateJobEntityByJobUuid(job *models.JobEntity) (err error)
- func (jobServ JobService) UpdateJobEntityBySpaceUuid(job *models.JobEntity) (err error)
- func (jobServ JobService) UpdateJobResultUrlByJobUuid(jobUuid string, resultUrl string) (err error)
- type K8sService
- func (s *K8sService) AddNodeLabel(nodeName, key string) error
- func (s *K8sService) CreateConfigMap(ctx context.Context, k8sNameSpace, spaceUuid, basePath, configName string) (*coreV1.ConfigMap, error)
- func (s *K8sService) CreateDeployment(ctx context.Context, nameSpace string, deploy *appV1.Deployment) (result *appV1.Deployment, err error)
- func (s *K8sService) CreateIngress(ctx context.Context, k8sNameSpace, spaceUuid, hostName string, port int32) (*networkingv1.Ingress, error)
- func (s *K8sService) CreateNameSpace(ctx context.Context, nameSpace *coreV1.Namespace, opts metaV1.CreateOptions) (result *coreV1.Namespace, err error)
- func (s *K8sService) CreateNetworkPolicy(ctx context.Context, namespace string) (*networkingv1.NetworkPolicy, error)
- func (s *K8sService) CreateService(ctx context.Context, nameSpace, spaceUuid string, containerPort int32) (result *coreV1.Service, err error)
- func (s *K8sService) CreateServiceByNodePort(ctx context.Context, nameSpace, taskUuid string, containerPort int32) (result *coreV1.Service, err error)
- func (s *K8sService) DeleteDeployRs(ctx context.Context, namespace, spaceUuid string) error
- func (s *K8sService) DeleteDeployment(ctx context.Context, namespace, deploymentName string) error
- func (s *K8sService) DeleteIngress(ctx context.Context, nameSpace, ingressName string) error
- func (s *K8sService) DeleteNameSpace(ctx context.Context, nameSpace string) error
- func (s *K8sService) DeletePod(ctx context.Context, namespace, spaceUuid string) error
- func (s *K8sService) DeleteService(ctx context.Context, namespace, serviceName string) error
- func (s *K8sService) GetAPIServerEndpoint() string
- func (s *K8sService) GetAllActivePod(ctx context.Context) ([]coreV1.Pod, error)
- func (s *K8sService) GetDeploymentActiveCount() (int, error)
- func (s *K8sService) GetDeploymentImages(ctx context.Context, namespace, deploymentName string) ([]string, error)
- func (s *K8sService) GetDeploymentStatus(namespace, spaceUuid string) (string, error)
- func (s *K8sService) GetNameSpace(ctx context.Context, nameSpace string, opts metaV1.GetOptions) (result *coreV1.Namespace, err error)
- func (s *K8sService) GetNodeGpuSummary(ctx context.Context) (map[string]map[string]int64, error)
- func (s *K8sService) GetPodLogByPodName(namespace, podName string, podLogOptions *coreV1.PodLogOptions) (string, error)
- func (s *K8sService) GetPods(namespace, spaceUuid string) (bool, error)
- func (s *K8sService) GetResourceExporterPodLog(ctx context.Context) (map[string]models.CollectNodeInfo, error)
- func (s *K8sService) GetServiceByName(ctx context.Context, namespace, serviceName string, opts metaV1.GetOptions) (result *coreV1.Service, err error)
- func (s *K8sService) ListNamespace(ctx context.Context) ([]string, error)
- func (s *K8sService) ListUsedImage(ctx context.Context, nameSpace string) ([]string, error)
- func (s *K8sService) PodDoCommand(namespace, podName, containerName string, podCmd []string) error
- func (s *K8sService) StatisticalSources(ctx context.Context) ([]*models.NodeResource, error)
- func (s *K8sService) WaitForPodRunningByHttp(namespace, spaceUuid, serviceIp string) (string, error)
- func (s *K8sService) WaitForPodRunningByTcp(namespace, taskUuid string) (string, error)
- type StorageService
- func (storage *StorageService) CreateBucket(bucketName string)
- func (storage *StorageService) CreateFolder(folderName string)
- func (storage *StorageService) DeleteBucket(bucketName string) error
- func (storage *StorageService) GetGatewayUrl() (*string, error)
- func (storage *StorageService) UploadFileToBucket(objectName, filePath string, replace bool) (*bucket.OssFile, error)
- type TaskService
- func (taskServ TaskService) GetAllTask(tailNum int) (list []*models.TaskEntity, err error)
- func (taskServ TaskService) GetTaskEntity(taskId int64) (*models.TaskEntity, error)
- func (taskServ TaskService) GetTaskList(taskStatus, tailNum int) (list []*models.TaskEntity, err error)
- func (taskServ TaskService) GetTaskListNoReward() (list []*models.TaskEntity, err error)
- func (taskServ TaskService) SaveTaskEntity(task *models.TaskEntity) (err error)
- type WsClient
Constants ¶
View Source
const ( ResourceCpu string = "cpu" ResourceMem string = "mem" ResourceStorage string = "storage" )
View Source
const ( PingMsg = "ping" PingPeriod = 3 * time.Second )
View Source
const BuildFileName = "build.log"
Variables ¶
View Source
var NotFoundError = errors.New("not found resource")
View Source
var TaskMap sync.Map
Functions ¶
func BuildImagesByDockerfile ¶
func BuildSpaceTaskImage ¶
func CheckWalletWhiteList ¶ added in v0.4.6
func CronTaskForEcp ¶ added in v0.5.0
func CronTaskForEcp()
func DeploySpaceTask ¶
func DoUbiTaskForDocker ¶ added in v0.4.6
func DoUbiTaskForK8s ¶ added in v0.4.6
func ExtractExposedPort ¶
func GetCpResource ¶ added in v0.4.6
func GetJobStatus ¶ added in v0.5.0
func GetNodeResource ¶
func GetOwnerAddressAndWorkerAddress ¶ added in v0.5.0
func GetServiceProviderInfo ¶
func GetSpaceLog ¶
func GetTaskInfoOnChain ¶ added in v0.5.0
func GetTaskInfoOnChain(rpcName string, taskContract string) (ecp.ECPTaskTaskInfo, error)
func InitComputingProvider ¶
func ReceiveJob ¶
func ReceiveUbiProofForDocker ¶ added in v0.4.6
func ReceiveUbiProofForK8s ¶ added in v0.4.6
func RedeployJob ¶
func RemoveContainerIfExists ¶
func RestartResourceExporter ¶ added in v0.5.0
func RestartResourceExporter() error
func RunContainer ¶
func RunDockerCompose ¶ added in v0.4.6
func StatisticalSources ¶
func StopPreviousServices ¶ added in v0.4.6
func SyncCpAccountInfo ¶ added in v0.5.0
func SyncCpAccountInfo()
Types ¶
type ComposeApiService ¶ added in v0.4.6
func NewComposeService ¶ added in v0.4.6
func NewComposeService() (*ComposeApiService, error)
func (*ComposeApiService) ServiceDown ¶ added in v0.4.6
func (cas *ComposeApiService) ServiceDown(dockerComposeBody string) error
func (*ComposeApiService) ServiceUp ¶ added in v0.4.6
func (cas *ComposeApiService) ServiceUp(dockerComposeBody string) error
type CpInfoService ¶ added in v0.5.0
func NewCpInfoService ¶ added in v0.5.0
func NewCpInfoService() CpInfoService
func (CpInfoService) GetCpInfoEntityByAccountAddress ¶ added in v0.5.0
func (cpServ CpInfoService) GetCpInfoEntityByAccountAddress(accountAddress string) (*models.CpInfoEntity, error)
func (CpInfoService) SaveCpInfoEntity ¶ added in v0.5.0
func (cpServ CpInfoService) SaveCpInfoEntity(cp *models.CpInfoEntity) (err error)
func (CpInfoService) UpdateCpInfoByNodeId ¶ added in v0.5.0
func (cpServ CpInfoService) UpdateCpInfoByNodeId(cp *models.CpInfoEntity) (err error)
type CpResourceSummary ¶ added in v0.5.0
type CpResourceSummary struct {
ClusterInfo []*models.NodeResource
}
type CronTask ¶
type CronTask struct {
// contains filtered or unexported fields
}
func NewCronTask ¶
type Deploy ¶
type Deploy struct {
SpacePath string
TaskType string
DeployName string
// contains filtered or unexported fields
}
func (*Deploy) DockerfileToK8s ¶
func (d *Deploy) DockerfileToK8s()
func (*Deploy) ModelInferenceToK8s ¶
func (*Deploy) WithDockerfile ¶
func (*Deploy) WithGpuProductName ¶
func (*Deploy) WithHardware ¶ added in v0.4.6
func (*Deploy) WithModelSettingFile ¶
func (*Deploy) WithSpaceInfo ¶
func (*Deploy) WithSpacePath ¶
func (*Deploy) WithYamlInfo ¶
type DockerService ¶
type DockerService struct {
// contains filtered or unexported fields
}
func NewDockerService ¶
func NewDockerService() *DockerService
func (*DockerService) BuildImage ¶
func (ds *DockerService) BuildImage(buildPath, imageName string) error
func (*DockerService) CheckRunningContainer ¶ added in v0.5.0
func (ds *DockerService) CheckRunningContainer(containerName string) (bool, error)
func (*DockerService) CleanResource ¶
func (ds *DockerService) CleanResource()
func (*DockerService) ContainerCreateAndStart ¶ added in v0.4.6
func (ds *DockerService) ContainerCreateAndStart(config *container.Config, hostConfig *container.HostConfig, containerName string) error
func (*DockerService) ContainerLogs ¶ added in v0.4.6
func (ds *DockerService) ContainerLogs(containerName string) (string, error)
func (*DockerService) GetContainerLogStream ¶ added in v0.4.8
func (ds *DockerService) GetContainerLogStream(containerName string) (io.ReadCloser, error)
func (*DockerService) PullImage ¶ added in v0.4.6
func (ds *DockerService) PullImage(imageName string) error
func (*DockerService) PushImage ¶
func (ds *DockerService) PushImage(imagesName string) error
func (*DockerService) RemoveContainerByName ¶ added in v0.5.0
func (ds *DockerService) RemoveContainerByName(containerName string) error
func (*DockerService) RemoveImage ¶
func (ds *DockerService) RemoveImage(imageId string) error
type JobService ¶ added in v0.5.0
func NewJobService ¶ added in v0.5.0
func NewJobService() JobService
func (JobService) DeleteJobEntityBySpaceUuId ¶ added in v0.5.0
func (jobServ JobService) DeleteJobEntityBySpaceUuId(spaceUuid string) error
func (JobService) DeleteJobs ¶ added in v0.5.0
func (jobServ JobService) DeleteJobs(spaceIds []string) (err error)
func (JobService) GetJobEntityByJobUuid ¶ added in v0.5.0
func (jobServ JobService) GetJobEntityByJobUuid(jobUuid string) (models.JobEntity, error)
func (JobService) GetJobEntityBySpaceUuid ¶ added in v0.5.0
func (jobServ JobService) GetJobEntityBySpaceUuid(spaceUuid string) (models.JobEntity, error)
func (JobService) GetJobEntityByTaskUuid ¶ added in v0.5.0
func (jobServ JobService) GetJobEntityByTaskUuid(taskUuid string) (models.JobEntity, error)
func (JobService) GetJobList ¶ added in v0.5.0
func (jobServ JobService) GetJobList() (list []*models.JobEntity, err error)
func (JobService) SaveJobEntity ¶ added in v0.5.0
func (jobServ JobService) SaveJobEntity(job *models.JobEntity) (err error)
func (JobService) UpdateJobEntityByJobUuid ¶ added in v0.5.0
func (jobServ JobService) UpdateJobEntityByJobUuid(job *models.JobEntity) (err error)
func (JobService) UpdateJobEntityBySpaceUuid ¶ added in v0.5.0
func (jobServ JobService) UpdateJobEntityBySpaceUuid(job *models.JobEntity) (err error)
func (JobService) UpdateJobResultUrlByJobUuid ¶ added in v0.5.0
func (jobServ JobService) UpdateJobResultUrlByJobUuid(jobUuid string, resultUrl string) (err error)
type K8sService ¶
type K8sService struct {
Version string
// contains filtered or unexported fields
}
func NewK8sService ¶
func NewK8sService() *K8sService
func (*K8sService) AddNodeLabel ¶
func (s *K8sService) AddNodeLabel(nodeName, key string) error
func (*K8sService) CreateConfigMap ¶
func (*K8sService) CreateDeployment ¶
func (s *K8sService) CreateDeployment(ctx context.Context, nameSpace string, deploy *appV1.Deployment) (result *appV1.Deployment, err error)
func (*K8sService) CreateIngress ¶
func (s *K8sService) CreateIngress(ctx context.Context, k8sNameSpace, spaceUuid, hostName string, port int32) (*networkingv1.Ingress, error)
func (*K8sService) CreateNameSpace ¶
func (s *K8sService) CreateNameSpace(ctx context.Context, nameSpace *coreV1.Namespace, opts metaV1.CreateOptions) (result *coreV1.Namespace, err error)
func (*K8sService) CreateNetworkPolicy ¶
func (s *K8sService) CreateNetworkPolicy(ctx context.Context, namespace string) (*networkingv1.NetworkPolicy, error)
func (*K8sService) CreateService ¶
func (*K8sService) CreateServiceByNodePort ¶ added in v0.4.6
func (*K8sService) DeleteDeployRs ¶
func (s *K8sService) DeleteDeployRs(ctx context.Context, namespace, spaceUuid string) error
func (*K8sService) DeleteDeployment ¶
func (s *K8sService) DeleteDeployment(ctx context.Context, namespace, deploymentName string) error
func (*K8sService) DeleteIngress ¶
func (s *K8sService) DeleteIngress(ctx context.Context, nameSpace, ingressName string) error
func (*K8sService) DeleteNameSpace ¶
func (s *K8sService) DeleteNameSpace(ctx context.Context, nameSpace string) error
func (*K8sService) DeletePod ¶
func (s *K8sService) DeletePod(ctx context.Context, namespace, spaceUuid string) error
func (*K8sService) DeleteService ¶
func (s *K8sService) DeleteService(ctx context.Context, namespace, serviceName string) error
func (*K8sService) GetAPIServerEndpoint ¶
func (s *K8sService) GetAPIServerEndpoint() string
func (*K8sService) GetAllActivePod ¶
func (*K8sService) GetDeploymentActiveCount ¶
func (s *K8sService) GetDeploymentActiveCount() (int, error)
func (*K8sService) GetDeploymentImages ¶
func (*K8sService) GetDeploymentStatus ¶
func (s *K8sService) GetDeploymentStatus(namespace, spaceUuid string) (string, error)
func (*K8sService) GetNameSpace ¶
func (s *K8sService) GetNameSpace(ctx context.Context, nameSpace string, opts metaV1.GetOptions) (result *coreV1.Namespace, err error)
func (*K8sService) GetNodeGpuSummary ¶
func (*K8sService) GetPodLogByPodName ¶ added in v0.4.5
func (s *K8sService) GetPodLogByPodName(namespace, podName string, podLogOptions *coreV1.PodLogOptions) (string, error)
func (*K8sService) GetPods ¶
func (s *K8sService) GetPods(namespace, spaceUuid string) (bool, error)
func (*K8sService) GetResourceExporterPodLog ¶
func (s *K8sService) GetResourceExporterPodLog(ctx context.Context) (map[string]models.CollectNodeInfo, error)
func (*K8sService) GetServiceByName ¶
func (s *K8sService) GetServiceByName(ctx context.Context, namespace, serviceName string, opts metaV1.GetOptions) (result *coreV1.Service, err error)
func (*K8sService) ListNamespace ¶
func (s *K8sService) ListNamespace(ctx context.Context) ([]string, error)
func (*K8sService) ListUsedImage ¶
func (*K8sService) PodDoCommand ¶
func (s *K8sService) PodDoCommand(namespace, podName, containerName string, podCmd []string) error
func (*K8sService) StatisticalSources ¶
func (s *K8sService) StatisticalSources(ctx context.Context) ([]*models.NodeResource, error)
func (*K8sService) WaitForPodRunningByHttp ¶ added in v0.4.6
func (s *K8sService) WaitForPodRunningByHttp(namespace, spaceUuid, serviceIp string) (string, error)
func (*K8sService) WaitForPodRunningByTcp ¶ added in v0.4.6
func (s *K8sService) WaitForPodRunningByTcp(namespace, taskUuid string) (string, error)
type StorageService ¶
type StorageService struct {
McsApiKey string `json:"mcs_api_key"`
McsAccessToken string `json:"mcs_access_token"`
NetWork string `json:"net_work"`
BucketName string `json:"bucket_name"`
// contains filtered or unexported fields
}
func NewStorageService ¶
func NewStorageService() *StorageService
func (*StorageService) CreateBucket ¶
func (storage *StorageService) CreateBucket(bucketName string)
func (*StorageService) CreateFolder ¶
func (storage *StorageService) CreateFolder(folderName string)
func (*StorageService) DeleteBucket ¶
func (storage *StorageService) DeleteBucket(bucketName string) error
func (*StorageService) GetGatewayUrl ¶
func (storage *StorageService) GetGatewayUrl() (*string, error)
func (*StorageService) UploadFileToBucket ¶
type TaskService ¶ added in v0.5.0
func NewTaskService ¶ added in v0.5.0
func NewTaskService() TaskService
func (TaskService) GetAllTask ¶ added in v0.5.0
func (taskServ TaskService) GetAllTask(tailNum int) (list []*models.TaskEntity, err error)
func (TaskService) GetTaskEntity ¶ added in v0.5.0
func (taskServ TaskService) GetTaskEntity(taskId int64) (*models.TaskEntity, error)
func (TaskService) GetTaskList ¶ added in v0.5.0
func (taskServ TaskService) GetTaskList(taskStatus, tailNum int) (list []*models.TaskEntity, err error)
func (TaskService) GetTaskListNoReward ¶ added in v0.5.0
func (taskServ TaskService) GetTaskListNoReward() (list []*models.TaskEntity, err error)
func (TaskService) SaveTaskEntity ¶ added in v0.5.0
func (taskServ TaskService) SaveTaskEntity(task *models.TaskEntity) (err error)
Click to show internal directories.
Click to hide internal directories.