|
- package entity
-
- import (
- "code.gitea.io/gitea/models"
- "code.gitea.io/gitea/modules/structs"
- )
-
- type CreationRequiredInfo struct {
- //排队信息、代码分支信息、查询是否有正在运行的任务、查询镜像列表、查询资源规格(积分余额,开关)
- Specs map[string][]*structs.SpecificationShow `json:"specs"`
- Images []ClusterImage `json:"images"`
- CanUseAllImages bool `json:"can_use_all_images"`
- Branches []string `json:"branches"`
- DefaultBranch string `json:"default_branch"`
- WaitCount int64 `json:"wait_count"`
- NotStopTaskCount int `json:"not_stop_task_count"`
- DisplayJobName string `json:"display_job_name"`
- PointAccount *PointAccountInfo `json:"point_account"`
- PaySwitch bool `json:"pay_switch"`
- Config AITaskCreationConfig `json:"config"`
- AllowedWorkerNum []int `json:"allowed_worker_num"`
- }
-
- type ImageRequiredInfo struct {
- Images []ClusterImage `json:"images"`
- CanUseAllImages bool `json:"can_use_all_images"`
- }
-
- type AITaskCreationConfig struct {
- DatasetMaxSize int `json:"dataset_max_size"`
- }
-
- type SpecificationInfo struct {
- ID int64 `json:"id"`
- SourceSpecId string `json:"source_spec_id"`
- AccCardsNum int `json:"acc_cards_num"`
- AccCardType string `json:"acc_card_type"`
- CpuCores int `json:"cpu_cores"`
- MemGiB float32 `json:"mem_gi_b"`
- GPUMemGiB float32 `json:"gpu_mem_gi_b"`
- ShareMemGiB float32 `json:"share_mem_gi_b"`
- ComputeResource string `json:"compute_resource"`
- UnitPrice int `json:"unit_price"`
- QueueId int64 `json:"queue_id"`
- QueueCode string `json:"queue_code"`
- Cluster string `json:"cluster"`
- AiCenterCode string `json:"ai_center_code"`
- AiCenterName string `json:"ai_center_name"`
- IsExclusive bool `json:"is_exclusive"`
- ExclusiveOrg string `json:"exclusive_org"`
- }
-
- func ParseSpecificationInfo(s *models.Specification) *SpecificationInfo {
- return &SpecificationInfo{
- ID: s.ID,
- SourceSpecId: s.SourceSpecId,
- AccCardsNum: s.AccCardsNum,
- AccCardType: s.AccCardType,
- CpuCores: s.CpuCores,
- MemGiB: s.MemGiB,
- GPUMemGiB: s.GPUMemGiB,
- ShareMemGiB: s.ShareMemGiB,
- ComputeResource: s.ComputeResource,
- UnitPrice: s.UnitPrice,
- QueueId: s.QueueId,
- QueueCode: s.QueueCode,
- Cluster: s.Cluster,
- AiCenterCode: s.AiCenterCode,
- AiCenterName: s.AiCenterName,
- IsExclusive: s.IsExclusive,
- ExclusiveOrg: s.ExclusiveOrg,
- }
- }
-
- type PointAccountInfo struct {
- AccountCode string `json:"account_code"`
- Balance int64 `json:"balance"`
- TotalEarned int64 `json:"total_earned"`
- TotalConsumed int64 `json:"total_consumed"`
- }
-
- func ParsePointAccountInfo(p *models.PointAccount) *PointAccountInfo {
- return &PointAccountInfo{
- AccountCode: p.AccountCode,
- Balance: p.Balance,
- TotalEarned: p.TotalEarned,
- TotalConsumed: p.TotalConsumed,
- }
-
- }
|