| @@ -1070,6 +1070,12 @@ type CreateInferenceJobParams struct { | |||
| InfConfig InfConfig `json:"config"` | |||
| WorkspaceID string `json:"workspace_id"` | |||
| } | |||
| type CreateInfUserImageParams struct { | |||
| JobName string `json:"job_name"` | |||
| Description string `json:"job_desc"` | |||
| Config InfUserImageConfig `json:"config"` | |||
| WorkspaceID string `json:"workspace_id"` | |||
| } | |||
| type InfConfig struct { | |||
| WorkServerNum int `json:"worker_server_num"` | |||
| @@ -1084,6 +1090,21 @@ type InfConfig struct { | |||
| PoolID string `json:"pool_id"` | |||
| } | |||
| type InfUserImageConfig struct { | |||
| WorkServerNum int `json:"worker_server_num"` | |||
| AppUrl string `json:"app_url"` //训练作业的代码目录 | |||
| BootFileUrl string `json:"boot_file_url"` //训练作业的代码启动文件,需要在代码目录下 | |||
| Parameter []Parameter `json:"parameter"` | |||
| DataUrl string `json:"data_url"` //训练作业需要的数据集OBS路径URL | |||
| EngineID int64 `json:"engine_id"` | |||
| LogUrl string `json:"log_url"` | |||
| CreateVersion bool `json:"create_version"` | |||
| Flavor Flavor `json:"flavor"` | |||
| PoolID string `json:"pool_id"` | |||
| UserImageUrl string `json:"user_image_url"` | |||
| UserCommand string `json:"user_command"` | |||
| } | |||
| type CreateTrainJobVersionParams struct { | |||
| Description string `json:"job_desc"` | |||
| Config TrainJobVersionConfig `json:"config"` | |||
| @@ -2024,7 +2045,7 @@ func GetCloudbrainRunCountByRepoID(repoID int64) (int, error) { | |||
| } | |||
| func GetModelSafetyCountByUserID(userID int64) (int, error) { | |||
| count, err := x.In("status", JobWaiting, JobRunning,ModelArtsTrainJobInit,ModelArtsTrainJobImageCreating,ModelArtsTrainJobSubmitTrying,ModelArtsTrainJobScaling,ModelArtsTrainJobCheckInit,ModelArtsTrainJobCheckRunning,ModelArtsTrainJobCheckRunningCompleted).And("job_type = ? and user_id = ?", string(JobTypeModelSafety), userID).Count(new(Cloudbrain)) | |||
| count, err := x.In("status", JobWaiting, JobRunning, ModelArtsTrainJobInit, ModelArtsTrainJobImageCreating, ModelArtsTrainJobSubmitTrying, ModelArtsTrainJobScaling, ModelArtsTrainJobCheckInit, ModelArtsTrainJobCheckRunning, ModelArtsTrainJobCheckRunningCompleted).And("job_type = ? and user_id = ?", string(JobTypeModelSafety), userID).Count(new(Cloudbrain)) | |||
| return int(count), err | |||
| } | |||
| @@ -2260,9 +2281,9 @@ func CloudbrainAllStatic(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, er | |||
| } | |||
| sess.Limit(opts.PageSize, start) | |||
| } | |||
| sess.OrderBy("cloudbrain.created_unix DESC") | |||
| // sess.OrderBy("cloudbrain.created_unix DESC") | |||
| cloudbrains := make([]*CloudbrainInfo, 0, setting.UI.IssuePagingNum) | |||
| if err := sess.Table(&Cloudbrain{}).Unscoped().Where(cond). | |||
| if err := sess.Cols("status", "type", "job_type", "train_job_duration", "duration", "compute_resource", "created_unix", "start_time", "end_time", "work_server_number").Table(&Cloudbrain{}).Unscoped().Where(cond). | |||
| Find(&cloudbrains); err != nil { | |||
| return nil, 0, fmt.Errorf("Find: %v", err) | |||
| } | |||
| @@ -9,7 +9,7 @@ type CloudbrainSpec struct { | |||
| SpecId int64 `xorm:"index"` | |||
| SourceSpecId string | |||
| AccCardsNum int | |||
| AccCardType string | |||
| AccCardType string `xorm:"index"` | |||
| CpuCores int | |||
| MemGiB float32 | |||
| GPUMemGiB float32 | |||
| @@ -19,7 +19,7 @@ type CloudbrainSpec struct { | |||
| QueueId int64 | |||
| QueueCode string | |||
| Cluster string | |||
| AiCenterCode string | |||
| AiCenterCode string `xorm:"index"` | |||
| AiCenterName string | |||
| IsExclusive bool | |||
| ExclusiveOrg string | |||
| @@ -1,6 +1,7 @@ | |||
| package models | |||
| import ( | |||
| "fmt" | |||
| "strconv" | |||
| "time" | |||
| @@ -38,6 +39,60 @@ type TaskDetail struct { | |||
| Spec *Specification `json:"Spec"` | |||
| } | |||
| type CloudbrainDurationStatistic struct { | |||
| ID int64 `xorm:"pk autoincr"` | |||
| Cluster string | |||
| AiCenterCode string | |||
| AiCenterName string | |||
| ComputeResource string | |||
| AccCardType string | |||
| DateTime string | |||
| DayTime string | |||
| HourTime int | |||
| CardsUseDuration int | |||
| CardsTotalDuration int | |||
| CardsTotalNum int | |||
| DeletedUnix timeutil.TimeStamp `xorm:"deleted"` | |||
| CreatedUnix timeutil.TimeStamp `xorm:"created"` | |||
| UpdatedUnix timeutil.TimeStamp `xorm:"updated"` | |||
| } | |||
| type DurationStatisticOptions struct { | |||
| BeginTime time.Time | |||
| EndTime time.Time | |||
| AiCenterCode string | |||
| } | |||
| type DurationRateStatistic struct { | |||
| AiCenterTotalDurationStat map[string]int `json:"aiCenterTotalDurationStat"` | |||
| AiCenterUsageDurationStat map[string]int `json:"aiCenterUsageDurationStat"` | |||
| UsageRate map[string]float64 `json:"UsageRate"` | |||
| } | |||
| type ResourceDetail struct { | |||
| QueueCode string | |||
| Cluster string `xorm:"notnull"` | |||
| AiCenterCode string | |||
| AiCenterName string | |||
| ComputeResource string | |||
| AccCardType string | |||
| CardsTotalNum int | |||
| IsAutomaticSync bool | |||
| } | |||
| type DateUsageStatistic struct { | |||
| Date string `json:"date"` | |||
| UsageDuration int `json:"usageDuration"` | |||
| TotalDuration int `json:"totalDuration"` | |||
| UsageRate float64 `json:"usageRate"` | |||
| } | |||
| type HourTimeStatistic struct { | |||
| HourTimeUsageDuration map[string]int `json:"hourTimeUsageDuration"` | |||
| HourTimeTotalDuration map[string]int `json:"hourTimeTotalDuration"` | |||
| HourTimeUsageRate map[string]float64 `json:"hourTimeUsageRate"` | |||
| } | |||
| func GetTodayCreatorCount(beginTime time.Time, endTime time.Time) (int64, error) { | |||
| countSql := "SELECT count(distinct user_id) FROM " + | |||
| "public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) + | |||
| @@ -199,3 +254,121 @@ func GetRunHourPeriodCount(dateBeginTime string, dateEndTime string) (map[string | |||
| } | |||
| return dateHourMap, nil | |||
| } | |||
| func GetCloudbrainRunning() ([]*CloudbrainInfo, error) { | |||
| sess := x.NewSession() | |||
| defer sess.Close() | |||
| var cond = builder.NewCond() | |||
| cond = cond.And( | |||
| builder.Eq{"cloudbrain.status": string(JobRunning)}, | |||
| ) | |||
| sess.OrderBy("cloudbrain.created_unix ASC") | |||
| cloudbrains := make([]*CloudbrainInfo, 0, 10) | |||
| if err := sess.Table(&Cloudbrain{}).Where(cond). | |||
| Find(&cloudbrains); err != nil { | |||
| log.Info("find error.") | |||
| } | |||
| return cloudbrains, nil | |||
| } | |||
| func GetCloudbrainByTime(beginTime int64, endTime int64) ([]*CloudbrainInfo, error) { | |||
| sess := x.NewSession() | |||
| defer sess.Close() | |||
| var cond = builder.NewCond() | |||
| cond = cond.And( | |||
| builder.And(builder.Gte{"cloudbrain.end_time": beginTime}, builder.Lte{"cloudbrain.end_time": endTime}), | |||
| ) | |||
| cond = cond.Or( | |||
| builder.Eq{"cloudbrain.status": string(JobRunning)}, | |||
| ) | |||
| sess.OrderBy("cloudbrain.created_unix ASC") | |||
| cloudbrains := make([]*CloudbrainInfo, 0, 10) | |||
| if err := sess.Table(&Cloudbrain{}).Unscoped().Where(cond). | |||
| Find(&cloudbrains); err != nil { | |||
| log.Info("find error.") | |||
| } | |||
| return cloudbrains, nil | |||
| } | |||
| func GetSpecByAiCenterCodeAndType(aiCenterCode string, accCardType string) ([]*CloudbrainSpec, error) { | |||
| sess := x.NewSession() | |||
| defer sess.Close() | |||
| var cond = builder.NewCond() | |||
| cond = cond.And( | |||
| builder.And(builder.Eq{"cloudbrain_spec.ai_center_code": aiCenterCode}, builder.Eq{"cloudbrain_spec.acc_card_type": accCardType}), | |||
| ) | |||
| cloudbrainSpecs := make([]*CloudbrainSpec, 0, 10) | |||
| if err := sess.Table(&CloudbrainSpec{}).Where(cond). | |||
| Find(&cloudbrainSpecs); err != nil { | |||
| log.Info("find error.") | |||
| } | |||
| return cloudbrainSpecs, nil | |||
| } | |||
| func InsertCloudbrainDurationStatistic(cloudbrainDurationStatistic *CloudbrainDurationStatistic) (int64, error) { | |||
| return xStatistic.Insert(cloudbrainDurationStatistic) | |||
| } | |||
| func DeleteCloudbrainDurationStatisticHour(date string, hour int, aiCenterCode string, accCardType string) error { | |||
| sess := xStatistic.NewSession() | |||
| defer sess.Close() | |||
| if err := sess.Begin(); err != nil { | |||
| return fmt.Errorf("Begin: %v", err) | |||
| } | |||
| if _, err := sess.Where("day_time = ? AND hour_time = ? AND ai_center_code = ? AND acc_card_type = ?", date, hour, aiCenterCode, accCardType).Delete(&CloudbrainDurationStatistic{}); err != nil { | |||
| return fmt.Errorf("Delete: %v", err) | |||
| } | |||
| if err := sess.Commit(); err != nil { | |||
| sess.Close() | |||
| return fmt.Errorf("Commit: %v", err) | |||
| } | |||
| sess.Close() | |||
| return nil | |||
| } | |||
| func GetCanUseCardInfo() ([]*ResourceQueue, error) { | |||
| sess := x.NewSession() | |||
| defer sess.Close() | |||
| sess.OrderBy("resource_queue.id ASC") | |||
| ResourceQueues := make([]*ResourceQueue, 0, 10) | |||
| if err := sess.Table(&ResourceQueue{}).Find(&ResourceQueues); err != nil { | |||
| log.Info("find error.") | |||
| } | |||
| return ResourceQueues, nil | |||
| } | |||
| func GetCardDurationStatistics(opts *DurationStatisticOptions) ([]*CloudbrainDurationStatistic, error) { | |||
| sess := xStatistic.NewSession() | |||
| defer sess.Close() | |||
| var cond = builder.NewCond() | |||
| if opts.BeginTime.Unix() > 0 && opts.EndTime.Unix() > 0 { | |||
| cond = cond.And( | |||
| builder.And(builder.Gte{"cloudbrain_duration_statistic.created_unix": opts.BeginTime.Unix()}, builder.Lte{"cloudbrain_duration_statistic.created_unix": opts.EndTime.Unix()}), | |||
| ) | |||
| } | |||
| if opts.AiCenterCode != "" { | |||
| cond = cond.And( | |||
| builder.Eq{"cloudbrain_duration_statistic.ai_center_code": opts.AiCenterCode}, | |||
| ) | |||
| } | |||
| CloudbrainDurationStatistics := make([]*CloudbrainDurationStatistic, 0, 10) | |||
| if err := sess.Table(&CloudbrainDurationStatistic{}).Where(cond). | |||
| Find(&CloudbrainDurationStatistics); err != nil { | |||
| log.Info("find error.") | |||
| } | |||
| return CloudbrainDurationStatistics, nil | |||
| } | |||
| func GetDurationRecordBeginTime() ([]*CloudbrainDurationStatistic, error) { | |||
| sess := xStatistic.NewSession() | |||
| defer sess.Close() | |||
| sess.OrderBy("cloudbrain_duration_statistic.id ASC limit 1") | |||
| CloudbrainDurationStatistics := make([]*CloudbrainDurationStatistic, 0) | |||
| if err := sess.Table(&CloudbrainDurationStatistic{}).Find(&CloudbrainDurationStatistics); err != nil { | |||
| log.Info("find error.") | |||
| } | |||
| return CloudbrainDurationStatistics, nil | |||
| } | |||
| @@ -183,6 +183,7 @@ func init() { | |||
| new(UserMetrics), | |||
| new(UserAnalysisPara), | |||
| new(Invitation), | |||
| new(CloudbrainDurationStatistic), | |||
| ) | |||
| gonicNames := []string{"SSL", "UID"} | |||
| @@ -10,6 +10,7 @@ import ( | |||
| "strings" | |||
| "code.gitea.io/gitea/modules/log" | |||
| "code.gitea.io/gitea/modules/setting" | |||
| "github.com/go-resty/resty/v2" | |||
| ) | |||
| @@ -71,8 +72,8 @@ func checkSetting() { | |||
| } | |||
| func loginCloudbrain() error { | |||
| HOST = "http://221.122.70.196:8081/atp-api" | |||
| KEY = "1" | |||
| HOST = setting.ModelSafetyTest.HOST | |||
| KEY = setting.ModelSafetyTest.KEY | |||
| return nil | |||
| } | |||
| @@ -266,6 +266,17 @@ func registerSyncModelArtsTempJobs() { | |||
| }) | |||
| } | |||
| func registerHandleCloudbrainDurationStatistic() { | |||
| RegisterTaskFatal("handle_cloudbrain_duration_statistic", &BaseConfig{ | |||
| Enabled: true, | |||
| RunAtStart: false, | |||
| Schedule: "1 0 * * * ?", | |||
| }, func(ctx context.Context, _ *models.User, _ Config) error { | |||
| repo.CloudbrainDurationStatisticHour() | |||
| return nil | |||
| }) | |||
| } | |||
| func initBasicTasks() { | |||
| registerUpdateMirrorTask() | |||
| registerRepoHealthCheck() | |||
| @@ -293,4 +304,5 @@ func initBasicTasks() { | |||
| registerCloudbrainPointDeductTask() | |||
| registerHandleModelSafetyTask() | |||
| registerHandleCloudbrainDurationStatistic() | |||
| } | |||
| @@ -143,6 +143,8 @@ type GenerateInferenceJobReq struct { | |||
| Spec *models.Specification | |||
| DatasetName string | |||
| JobType string | |||
| UserImageUrl string | |||
| UserCommand string | |||
| } | |||
| type VersionInfo struct { | |||
| @@ -682,26 +684,51 @@ func GetOutputPathByCount(TotalVersionCount int) (VersionOutputPath string) { | |||
| func GenerateInferenceJob(ctx *context.Context, req *GenerateInferenceJobReq) (err error) { | |||
| createTime := timeutil.TimeStampNow() | |||
| jobResult, err := createInferenceJob(models.CreateInferenceJobParams{ | |||
| JobName: req.JobName, | |||
| Description: req.Description, | |||
| InfConfig: models.InfConfig{ | |||
| WorkServerNum: req.WorkServerNumber, | |||
| AppUrl: req.CodeObsPath, | |||
| BootFileUrl: req.BootFileUrl, | |||
| DataUrl: req.DataUrl, | |||
| EngineID: req.EngineID, | |||
| // TrainUrl: req.TrainUrl, | |||
| LogUrl: req.LogUrl, | |||
| PoolID: req.PoolID, | |||
| CreateVersion: true, | |||
| Flavor: models.Flavor{ | |||
| Code: req.Spec.SourceSpecId, | |||
| var jobResult *models.CreateTrainJobResult | |||
| var createErr error | |||
| if req.EngineID < 0 { | |||
| jobResult, createErr = createInferenceJobUserImage(models.CreateInfUserImageParams{ | |||
| JobName: req.JobName, | |||
| Description: req.Description, | |||
| Config: models.InfUserImageConfig{ | |||
| WorkServerNum: req.WorkServerNumber, | |||
| AppUrl: req.CodeObsPath, | |||
| BootFileUrl: req.BootFileUrl, | |||
| DataUrl: req.DataUrl, | |||
| // TrainUrl: req.TrainUrl, | |||
| LogUrl: req.LogUrl, | |||
| PoolID: req.PoolID, | |||
| CreateVersion: true, | |||
| Flavor: models.Flavor{ | |||
| Code: req.Spec.SourceSpecId, | |||
| }, | |||
| Parameter: req.Parameters, | |||
| UserImageUrl: req.UserImageUrl, | |||
| UserCommand: req.UserCommand, | |||
| }, | |||
| Parameter: req.Parameters, | |||
| }, | |||
| }) | |||
| if err != nil { | |||
| }) | |||
| } else { | |||
| jobResult, createErr = createInferenceJob(models.CreateInferenceJobParams{ | |||
| JobName: req.JobName, | |||
| Description: req.Description, | |||
| InfConfig: models.InfConfig{ | |||
| WorkServerNum: req.WorkServerNumber, | |||
| AppUrl: req.CodeObsPath, | |||
| BootFileUrl: req.BootFileUrl, | |||
| DataUrl: req.DataUrl, | |||
| EngineID: req.EngineID, | |||
| // TrainUrl: req.TrainUrl, | |||
| LogUrl: req.LogUrl, | |||
| PoolID: req.PoolID, | |||
| CreateVersion: true, | |||
| Flavor: models.Flavor{ | |||
| Code: req.Spec.SourceSpecId, | |||
| }, | |||
| Parameter: req.Parameters, | |||
| }, | |||
| }) | |||
| } | |||
| if createErr != nil { | |||
| log.Error("createInferenceJob failed: %v", err.Error()) | |||
| if strings.HasPrefix(err.Error(), UnknownErrorPrefix) { | |||
| log.Info("(%s)unknown error, set temp status", req.DisplayJobName) | |||
| @@ -1197,6 +1197,66 @@ sendjob: | |||
| return &result, nil | |||
| } | |||
| func createInferenceJobUserImage(createJobParams models.CreateInfUserImageParams) (*models.CreateTrainJobResult, error) { | |||
| checkSetting() | |||
| client := getRestyClient() | |||
| var result models.CreateTrainJobResult | |||
| retry := 0 | |||
| sendjob: | |||
| res, err := client.R(). | |||
| SetHeader("Content-Type", "application/json"). | |||
| SetAuthToken(TOKEN). | |||
| SetBody(createJobParams). | |||
| SetResult(&result). | |||
| Post(HOST + "/v1/" + setting.ProjectID + urlTrainJob) | |||
| if err != nil { | |||
| return nil, fmt.Errorf("resty create train-job: %s", err) | |||
| } | |||
| req, _ := json.Marshal(createJobParams) | |||
| log.Info("%s", req) | |||
| if res.StatusCode() == http.StatusUnauthorized && retry < 1 { | |||
| retry++ | |||
| _ = getToken() | |||
| goto sendjob | |||
| } | |||
| if res.StatusCode() != http.StatusOK { | |||
| var temp models.ErrorResult | |||
| if err = json.Unmarshal([]byte(res.String()), &temp); err != nil { | |||
| log.Error("json.Unmarshal failed(%s): %v", res.String(), err.Error()) | |||
| return &result, fmt.Errorf("json.Unmarshal failed(%s): %v", res.String(), err.Error()) | |||
| } | |||
| log.Error("createInferenceJobUserImage failed(%d):%s(%s)", res.StatusCode(), temp.ErrorCode, temp.ErrorMsg) | |||
| bootFileErrorMsg := "Invalid OBS path '" + createJobParams.Config.BootFileUrl + "'." | |||
| dataSetErrorMsg := "Invalid OBS path '" + createJobParams.Config.DataUrl + "'." | |||
| if temp.ErrorMsg == bootFileErrorMsg { | |||
| log.Error("启动文件错误!createInferenceJobUserImage failed(%d):%s(%s)", res.StatusCode(), temp.ErrorCode, temp.ErrorMsg) | |||
| return &result, fmt.Errorf("启动文件错误!") | |||
| } | |||
| if temp.ErrorMsg == dataSetErrorMsg { | |||
| log.Error("数据集错误!createInferenceJobUserImage failed(%d):%s(%s)", res.StatusCode(), temp.ErrorCode, temp.ErrorMsg) | |||
| return &result, fmt.Errorf("数据集错误!") | |||
| } | |||
| if res.StatusCode() == http.StatusBadGateway { | |||
| return &result, fmt.Errorf(UnknownErrorPrefix+"createInferenceJobUserImage failed(%d):%s(%s)", res.StatusCode(), temp.ErrorCode, temp.ErrorMsg) | |||
| } else { | |||
| return &result, fmt.Errorf("createInferenceJobUserImage failed(%d):%s(%s)", res.StatusCode(), temp.ErrorCode, temp.ErrorMsg) | |||
| } | |||
| } | |||
| if !result.IsSuccess { | |||
| log.Error("createInferenceJobUserImage failed(%s): %s", result.ErrorCode, result.ErrorMsg) | |||
| return &result, fmt.Errorf("createInferenceJobUserImage failed(%s): %s", result.ErrorCode, result.ErrorMsg) | |||
| } | |||
| return &result, nil | |||
| } | |||
| func createNotebook2(createJobParams models.CreateNotebook2Params) (*models.CreateNotebookResult, error) { | |||
| checkSetting() | |||
| client := getRestyClient() | |||
| @@ -597,6 +597,7 @@ var ( | |||
| }{} | |||
| C2NetInfos *C2NetSqInfos | |||
| C2NetMapInfo map[string]*C2NetSequenceInfo | |||
| //elk config | |||
| ElkUrl string | |||
| @@ -729,6 +730,9 @@ var ( | |||
| GPUBaseDataSetUUID string | |||
| GPUCombatDataSetName string | |||
| GPUCombatDataSetUUID string | |||
| HOST string | |||
| KEY string | |||
| }{} | |||
| ModelApp = struct { | |||
| @@ -1576,6 +1580,8 @@ func getModelSafetyConfig() { | |||
| ModelSafetyTest.NPUBaseDataSetUUID = sec.Key("NPUBaseDataSetUUID").MustString("") | |||
| ModelSafetyTest.NPUCombatDataSetName = sec.Key("NPUCombatDataSetName").MustString("") | |||
| ModelSafetyTest.NPUCombatDataSetUUID = sec.Key("NPUCombatDataSetUUID").MustString("") | |||
| ModelSafetyTest.HOST = sec.Key("HOST").MustString("") | |||
| ModelSafetyTest.KEY = sec.Key("KEY").MustString("") | |||
| } | |||
| func getModelConvertConfig() { | |||
| @@ -1635,6 +1641,10 @@ func getGrampusConfig() { | |||
| if err := json.Unmarshal([]byte(Grampus.C2NetSequence), &C2NetInfos); err != nil { | |||
| log.Error("Unmarshal(C2NetSequence) failed:%v", err) | |||
| } | |||
| C2NetMapInfo=make(map[string]*C2NetSequenceInfo) | |||
| for _,value :=range C2NetInfos.C2NetSqInfo{ | |||
| C2NetMapInfo[value.Name]=value | |||
| } | |||
| } | |||
| Grampus.SyncScriptProject = sec.Key("SYNC_SCRIPT_PROJECT").MustString("script_for_grampus") | |||
| @@ -265,8 +265,8 @@ page_dev_yunlao_desc3=China computing power network (C²NET) phase I can realize | |||
| page_dev_yunlao_desc4=Developers can freely select the corresponding computing resources according to the use needs, and can test the adaptability, performance, stability, etc. of the model in different hardware environments. | |||
| page_dev_yunlao_desc5=If your model requires more computing resources, you can also apply for it separately. | |||
| page_dev_yunlao_apply=Apply Separately | |||
| c2net_title=China Computing Network | |||
| c2net_desc=The artificial intelligence computing power network promotion alliance has access to 11 intelligent computing centers, with a total scale of 1924p. | |||
| c2net_title=China Computing NET(C²NET) | |||
| c2net_desc=Extensive access to intelligent computing centers and supercomputing centers across the country to provide users with free computing resources. | |||
| c2net_center=Center | |||
| search=Search | |||
| search_repo=Repository | |||
| @@ -289,6 +289,7 @@ provide_resoure = Computing resources of CPU/GPU/NPU are provided freely for var | |||
| activity = Activity | |||
| no_events = There are no events related | |||
| or_t = or | |||
| powerdby=Powered_by Pengcheng CloudBrain、China Computing NET(C²NET)、 | |||
| [explore] | |||
| repos = Repositories | |||
| @@ -1216,7 +1217,8 @@ cloudbrain.benchmark.evaluate_train=Train Script | |||
| cloudbrain.benchmark.evaluate_test=Test Script | |||
| cloudbrain.benchmark.types={"type":[{"id":1,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=detection","first":"Target detection","second":[{"id":1,"value":"None","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"yangzhx","repo_name":"detection_benchmark_script"}]},{"id":2,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=reid","first":"Target re-identification","second":[{"id":1,"value":"Vehicle re-identification","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"},{"id":2,"value":"Image-based person re-identification","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"}]},{"id":3,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=tracking","first":"Multi-target tracking","second":[{"id":1,"value":"None","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"lix07","repo_name":"MOT_benchmark_script"}]}]} | |||
| cloudbrain.morethanonejob=You already have a running or waiting task, create it after that task is over. | |||
| cloudbrain.morethanonejob1=You have created a <span style="color:rgba(242, 113, 28, 1);"> similar task </span> that is waiting or running, please wait for the task to finish before creating it. | |||
| cloudbrain.morethanonejob2=You can view all your Cloud Brain tasks in <a href="/cloudbrains" > Personal Center > Cloud Brain Tasks </a>. | |||
| modelarts.infer_job_model = Model | |||
| modelarts.infer_job_model_file = Model File | |||
| @@ -267,8 +267,8 @@ page_dev_yunlao_desc3=中国算力网(C²NET)一期可实现不同人工智 | |||
| page_dev_yunlao_desc4=开发者可以根据使用需求,自由选择相应计算资源,可以测试模型在不同硬件环境下的适配能力、性能、稳定性等。 | |||
| page_dev_yunlao_desc5=如果您的模型需要更多的计算资源,也可以单独申请。 | |||
| page_dev_yunlao_apply=单独申请 | |||
| c2net_title=智算网络 | |||
| c2net_desc=人工智能算力网络推进联盟已接入11家智算中心,算力总规模1924P | |||
| c2net_title=中国算力网(C²NET) | |||
| c2net_desc=广泛接入全国各地智算中心、超算中心,为用户提供免费算力资源 | |||
| c2net_center=中心 | |||
| search=搜索 | |||
| search_repo=项目 | |||
| @@ -292,6 +292,7 @@ create_pro = 创建项目 | |||
| activity = 活动 | |||
| no_events = 还没有与您相关的活动 | |||
| or_t = 或 | |||
| powerdby=Powered_by 鹏城实验室云脑、中国算力网(C²NET)、 | |||
| [explore] | |||
| @@ -1230,6 +1231,8 @@ cloudbrain.benchmark.evaluate_test=测试程序 | |||
| cloudbrain.benchmark.types={"type":[{"id":1,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=detection","first":"目标检测","second":[{"id":1,"value":"无","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"yangzhx","repo_name":"detection_benchmark_script"}]},{"id":2,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=reid","first":"目标重识别","second":[{"id":1,"value":"车辆重识别","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"},{"id":2,"value":"基于图像的行人重识别","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"}]},{"id":3,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=tracking","first":"多目标跟踪","second":[{"id":1,"value":"无","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"lix07","repo_name":"MOT_benchmark_script"}]}]} | |||
| cloudbrain.benchmark.model.types={"type":[{"id":1,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=detection","first":"目标检测","second":[{"id":1,"value":"无","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"yangzhx","repo_name":"detection_benchmark_script"}]},{"id":2,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=reid","first":"目标重识别","second":[{"id":1,"value":"车辆重识别","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"},{"id":2,"value":"基于图像的行人重识别","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"}]},{"id":3,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=tracking","first":"多目标跟踪","second":[{"id":1,"value":"无","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"lix07","repo_name":"MOT_benchmark_script"}]}]} | |||
| cloudbrain.morethanonejob=您已经创建了一个正在等待或运行中的同类任务,请等待任务结束再创建。 | |||
| cloudbrain.morethanonejob1=您已经有 <span style="color:rgba(242, 113, 28, 1);">同类任务</span> 正在等待或运行中,请等待任务结束再创建; | |||
| cloudbrain.morethanonejob2=可以在 “<a href="/cloudbrains" >个人中心 > 云脑任务</a>” 查看您所有的云脑任务。 | |||
| modelarts.infer_job_model = 模型名称 | |||
| modelarts.infer_job_model_file = 模型文件 | |||
| @@ -599,6 +599,11 @@ func RegisterRoutes(m *macaron.Macaron) { | |||
| m.Get("/hours_data", repo.GetCloudbrainsCreateHoursData) | |||
| m.Get("/waitting_top_data", repo.GetWaittingTop) | |||
| m.Get("/running_top_data", repo.GetRunningTop) | |||
| m.Get("/overview_resource", repo.GetCloudbrainResourceOverview) | |||
| m.Get("/resource_usage_statistic", repo.GetDurationRateStatistic) | |||
| m.Get("/resource_usage_rate_detail", repo.GetCloudbrainResourceUsageDetail) | |||
| m.Get("/apitest_for_statistic", repo.CloudbrainDurationStatisticForTest) | |||
| }) | |||
| }, operationReq) | |||
| @@ -572,6 +572,11 @@ func CloudbrainGetLog(ctx *context.APIContext) { | |||
| startLine = 0 | |||
| } | |||
| } | |||
| } else { | |||
| if startLine > 0 { | |||
| startLine += 1 | |||
| endLine += 1 | |||
| } | |||
| } | |||
| result = getLogFromModelDir(job.JobName, startLine, endLine, resultPath) | |||
| if result == nil { | |||
| @@ -723,6 +728,7 @@ func getLogFromModelDir(jobName string, startLine int, endLine int, resultPath s | |||
| re = re + line | |||
| count++ | |||
| } | |||
| fileEndLine = i + 1 | |||
| log.Info("read file completed.") | |||
| break | |||
| } | |||
| @@ -732,13 +738,12 @@ func getLogFromModelDir(jobName string, startLine int, endLine int, resultPath s | |||
| } | |||
| if error == nil { | |||
| if i >= startLine { | |||
| fileEndLine = i | |||
| fileEndLine = i + 1 | |||
| re = re + line | |||
| count++ | |||
| } | |||
| } | |||
| } | |||
| fileEndLine = fileEndLine + 1 | |||
| } else { | |||
| log.Info("error:" + err.Error()) | |||
| } | |||
| @@ -4,6 +4,7 @@ import ( | |||
| "fmt" | |||
| "net/http" | |||
| "net/url" | |||
| "strconv" | |||
| "strings" | |||
| "time" | |||
| @@ -120,9 +121,6 @@ func GetOverviewDuration(ctx *context.Context) { | |||
| recordBeginTime := recordCloudbrain[0].Cloudbrain.CreatedUnix | |||
| now := time.Now() | |||
| endTime := now | |||
| page := 1 | |||
| pagesize := 1000 | |||
| count := pagesize | |||
| worker_server_num := 1 | |||
| cardNum := 1 | |||
| durationAllSum := int64(0) | |||
| @@ -138,54 +136,46 @@ func GetOverviewDuration(ctx *context.Context) { | |||
| c2NetDuration := int64(0) | |||
| cDCenterDuration := int64(0) | |||
| for count == pagesize && count != 0 { | |||
| cloudbrains, _, err := models.CloudbrainAllStatic(&models.CloudbrainsOptions{ | |||
| ListOptions: models.ListOptions{ | |||
| Page: page, | |||
| PageSize: pagesize, | |||
| }, | |||
| Type: models.TypeCloudBrainAll, | |||
| BeginTimeUnix: int64(recordBeginTime), | |||
| EndTimeUnix: endTime.Unix(), | |||
| }) | |||
| if err != nil { | |||
| ctx.ServerError("Get cloudbrains failed:", err) | |||
| return | |||
| } | |||
| models.LoadSpecs4CloudbrainInfo(cloudbrains) | |||
| for _, cloudbrain := range cloudbrains { | |||
| if cloudbrain.Cloudbrain.WorkServerNumber >= 1 { | |||
| worker_server_num = cloudbrain.Cloudbrain.WorkServerNumber | |||
| } else { | |||
| worker_server_num = 1 | |||
| } | |||
| if cloudbrain.Cloudbrain.Spec == nil { | |||
| cardNum = 1 | |||
| } else { | |||
| cardNum = cloudbrain.Cloudbrain.Spec.AccCardsNum | |||
| } | |||
| duration := cloudbrain.Duration | |||
| durationSum := cloudbrain.Duration * int64(worker_server_num) * int64(cardNum) | |||
| if cloudbrain.Cloudbrain.Type == models.TypeCloudBrainOne { | |||
| cloudBrainOneDuration += duration | |||
| cloudBrainOneCardDuSum += durationSum | |||
| } else if cloudbrain.Cloudbrain.Type == models.TypeCloudBrainTwo { | |||
| cloudBrainTwoDuration += duration | |||
| cloudBrainTwoCardDuSum += durationSum | |||
| } else if cloudbrain.Cloudbrain.Type == models.TypeC2Net { | |||
| c2NetDuration += duration | |||
| c2NetCardDuSum += durationSum | |||
| } else if cloudbrain.Cloudbrain.Type == models.TypeCDCenter { | |||
| cDCenterDuration += duration | |||
| cDNetCardDuSum += durationSum | |||
| } | |||
| cloudbrains, _, err := models.CloudbrainAllStatic(&models.CloudbrainsOptions{ | |||
| Type: models.TypeCloudBrainAll, | |||
| BeginTimeUnix: int64(recordBeginTime), | |||
| EndTimeUnix: endTime.Unix(), | |||
| }) | |||
| if err != nil { | |||
| ctx.ServerError("Get cloudbrains failed:", err) | |||
| return | |||
| } | |||
| models.LoadSpecs4CloudbrainInfo(cloudbrains) | |||
| durationAllSum += duration | |||
| cardDuSum += durationSum | |||
| count = len(cloudbrains) | |||
| page += 1 | |||
| for _, cloudbrain := range cloudbrains { | |||
| if cloudbrain.Cloudbrain.WorkServerNumber >= 1 { | |||
| worker_server_num = cloudbrain.Cloudbrain.WorkServerNumber | |||
| } else { | |||
| worker_server_num = 1 | |||
| } | |||
| if cloudbrain.Cloudbrain.Spec == nil { | |||
| cardNum = 1 | |||
| } else { | |||
| cardNum = cloudbrain.Cloudbrain.Spec.AccCardsNum | |||
| } | |||
| duration := cloudbrain.Duration | |||
| durationSum := cloudbrain.Duration * int64(worker_server_num) * int64(cardNum) | |||
| if cloudbrain.Cloudbrain.Type == models.TypeCloudBrainOne { | |||
| cloudBrainOneDuration += duration | |||
| cloudBrainOneCardDuSum += durationSum | |||
| } else if cloudbrain.Cloudbrain.Type == models.TypeCloudBrainTwo { | |||
| cloudBrainTwoDuration += duration | |||
| cloudBrainTwoCardDuSum += durationSum | |||
| } else if cloudbrain.Cloudbrain.Type == models.TypeC2Net { | |||
| c2NetDuration += duration | |||
| c2NetCardDuSum += durationSum | |||
| } else if cloudbrain.Cloudbrain.Type == models.TypeCDCenter { | |||
| cDCenterDuration += duration | |||
| cDNetCardDuSum += durationSum | |||
| } | |||
| durationAllSum += duration | |||
| cardDuSum += durationSum | |||
| } | |||
| ctx.JSON(http.StatusOK, map[string]interface{}{ | |||
| "cloudBrainOneCardDuSum": cloudBrainOneCardDuSum, | |||
| @@ -532,6 +522,21 @@ func getPageDateCloudbrainInfo(dateCloudbrainInfo []DateCloudbrainInfo, page int | |||
| } | |||
| func getPageDateCloudbrainDuration(dateUsageStatistic []models.DateUsageStatistic, page int, pagesize int) []models.DateUsageStatistic { | |||
| begin := (page - 1) * pagesize | |||
| end := (page) * pagesize | |||
| if begin > len(dateUsageStatistic)-1 { | |||
| return nil | |||
| } | |||
| if end > len(dateUsageStatistic)-1 { | |||
| return dateUsageStatistic[begin:] | |||
| } else { | |||
| return dateUsageStatistic[begin:end] | |||
| } | |||
| } | |||
| func GetAllCloudbrainsPeriodDistribution(ctx *context.Context) { | |||
| queryType := ctx.QueryTrim("type") | |||
| beginTimeStr := ctx.QueryTrim("beginTime") | |||
| @@ -545,7 +550,7 @@ func GetAllCloudbrainsPeriodDistribution(ctx *context.Context) { | |||
| recordBeginTime := time.Unix(int64(recordCloudbrain[0].Cloudbrain.CreatedUnix), 0) | |||
| beginTime, endTime, err := getCloudbrainTimePeroid(ctx, recordBeginTime) | |||
| if err != nil { | |||
| log.Error("Parameter is wrong", err) | |||
| log.Error("getCloudbrainTimePeroid error:", err) | |||
| ctx.Error(http.StatusBadRequest, ctx.Tr("repo.parameter_is_wrong")) | |||
| return | |||
| } | |||
| @@ -1403,3 +1408,424 @@ func getCloudbrainTimePeroid(ctx *context.Context, recordBeginTime time.Time) (t | |||
| return beginTime, endTime, nil | |||
| } | |||
| func GetCloudbrainResourceOverview(ctx *context.Context) { | |||
| recordCloudbrainDuration, err := models.GetDurationRecordBeginTime() | |||
| if err != nil { | |||
| log.Error("Can not get GetDurationRecordBeginTime", err) | |||
| return | |||
| } | |||
| recordBeginTime := recordCloudbrainDuration[0].CreatedUnix | |||
| recordUpdateTime := time.Now().Unix() | |||
| resourceQueues, err := models.GetCanUseCardInfo() | |||
| if err != nil { | |||
| log.Info("GetCanUseCardInfo err: %v", err) | |||
| return | |||
| } | |||
| OpenIResourceDetail := []models.ResourceDetail{} | |||
| C2NetResourceDetail := []models.ResourceDetail{} | |||
| for _, resourceQueue := range resourceQueues { | |||
| if resourceQueue.Cluster == models.OpenICluster { | |||
| var resourceDetail models.ResourceDetail | |||
| resourceDetail.QueueCode = resourceQueue.QueueCode | |||
| resourceDetail.Cluster = resourceQueue.Cluster | |||
| resourceDetail.AiCenterCode = resourceQueue.AiCenterCode | |||
| resourceDetail.AiCenterName = resourceQueue.AiCenterName + "/" + resourceQueue.AiCenterCode | |||
| resourceDetail.ComputeResource = resourceQueue.ComputeResource | |||
| resourceDetail.AccCardType = resourceQueue.AccCardType + "(" + resourceQueue.ComputeResource + ")" | |||
| resourceDetail.CardsTotalNum = resourceQueue.CardsTotalNum | |||
| resourceDetail.IsAutomaticSync = resourceQueue.IsAutomaticSync | |||
| OpenIResourceDetail = append(OpenIResourceDetail, resourceDetail) | |||
| } | |||
| if resourceQueue.Cluster == models.C2NetCluster { | |||
| var resourceDetail models.ResourceDetail | |||
| resourceDetail.QueueCode = resourceQueue.QueueCode | |||
| resourceDetail.Cluster = resourceQueue.Cluster | |||
| resourceDetail.AiCenterCode = resourceQueue.AiCenterCode | |||
| resourceDetail.AiCenterName = resourceQueue.AiCenterName + "/" + resourceQueue.AiCenterCode | |||
| resourceDetail.ComputeResource = resourceQueue.ComputeResource | |||
| resourceDetail.AccCardType = resourceQueue.AccCardType + "(" + resourceQueue.ComputeResource + ")" | |||
| resourceDetail.CardsTotalNum = resourceQueue.CardsTotalNum | |||
| resourceDetail.IsAutomaticSync = resourceQueue.IsAutomaticSync | |||
| C2NetResourceDetail = append(C2NetResourceDetail, resourceDetail) | |||
| } | |||
| } | |||
| openIResourceNum := make(map[string]map[string]int) | |||
| for _, openIResourceDetail := range OpenIResourceDetail { | |||
| if _, ok := openIResourceNum[openIResourceDetail.AiCenterName]; !ok { | |||
| openIResourceNum[openIResourceDetail.AiCenterName] = make(map[string]int) | |||
| } | |||
| if _, ok := openIResourceNum[openIResourceDetail.AiCenterName][openIResourceDetail.AccCardType]; !ok { | |||
| openIResourceNum[openIResourceDetail.AiCenterName][openIResourceDetail.AccCardType] = openIResourceDetail.CardsTotalNum | |||
| } else { | |||
| openIResourceNum[openIResourceDetail.AiCenterName][openIResourceDetail.AccCardType] += openIResourceDetail.CardsTotalNum | |||
| } | |||
| } | |||
| c2NetResourceNum := make(map[string]map[string]int) | |||
| for _, c2NetResourceDetail := range C2NetResourceDetail { | |||
| if _, ok := c2NetResourceNum[c2NetResourceDetail.AiCenterName]; !ok { | |||
| c2NetResourceNum[c2NetResourceDetail.AiCenterName] = make(map[string]int) | |||
| } | |||
| if _, ok := c2NetResourceNum[c2NetResourceDetail.AiCenterName][c2NetResourceDetail.AccCardType]; !ok { | |||
| c2NetResourceNum[c2NetResourceDetail.AiCenterName][c2NetResourceDetail.AccCardType] = c2NetResourceDetail.CardsTotalNum | |||
| } else { | |||
| c2NetResourceNum[c2NetResourceDetail.AiCenterName][c2NetResourceDetail.AccCardType] += c2NetResourceDetail.CardsTotalNum | |||
| } | |||
| } | |||
| ctx.JSON(http.StatusOK, map[string]interface{}{ | |||
| "openI": openIResourceNum, | |||
| "c2Net": c2NetResourceNum, | |||
| "recordUpdateTime": recordUpdateTime, | |||
| "recordBeginTime": recordBeginTime, | |||
| }) | |||
| } | |||
| func GetCloudbrainResourceUsageDetail(ctx *context.Context) { | |||
| aiCenterCode := ctx.QueryTrim("aiCenterCode") | |||
| if aiCenterCode == "" { | |||
| aiCenterCode = models.AICenterOfCloudBrainOne | |||
| } | |||
| beginTime, endTime := getBeginAndEndTime(ctx) | |||
| dayCloudbrainDuration, count, err := getDayCloudbrainDuration(beginTime, endTime, aiCenterCode) | |||
| if err != nil { | |||
| log.Error("Can not query dayCloudbrainDuration.", err) | |||
| return | |||
| } | |||
| hourCloudbrainDuration, err := getHourCloudbrainDuration(beginTime, endTime, aiCenterCode) | |||
| if err != nil { | |||
| log.Error("Can not query hourCloudbrainDuration.", err) | |||
| return | |||
| } | |||
| page := ctx.QueryInt("page") | |||
| if page <= 0 { | |||
| page = 1 | |||
| } | |||
| pagesize := ctx.QueryInt("pagesize") | |||
| if pagesize <= 0 { | |||
| pagesize = 36500 | |||
| } | |||
| pageDateCloudbrainDuration := getPageDateCloudbrainDuration(dayCloudbrainDuration, page, pagesize) | |||
| ctx.JSON(http.StatusOK, map[string]interface{}{ | |||
| "totalCount": count, | |||
| "pageDateCloudbrainDuration": pageDateCloudbrainDuration, | |||
| "hourCloudbrainDuration": hourCloudbrainDuration, | |||
| }) | |||
| } | |||
| func GetDurationRateStatistic(ctx *context.Context) { | |||
| beginTime, endTime := getBeginAndEndTime(ctx) | |||
| OpenIDurationRate, C2NetDurationRate, totalUsageRate := getDurationStatistic(beginTime, endTime) | |||
| ctx.JSON(http.StatusOK, map[string]interface{}{ | |||
| "openIDurationRate": OpenIDurationRate, | |||
| "c2NetDurationRate": C2NetDurationRate, | |||
| "totalUsageRate": totalUsageRate, | |||
| }) | |||
| } | |||
| func CloudbrainDurationStatisticForTest(ctx *context.Context) { | |||
| repo.CloudbrainDurationStatisticHour() | |||
| ctx.JSON(http.StatusOK, map[string]interface{}{ | |||
| "message": 0, | |||
| }) | |||
| } | |||
| func getBeginAndEndTime(ctx *context.Context) (time.Time, time.Time) { | |||
| queryType := ctx.QueryTrim("type") | |||
| now := time.Now() | |||
| beginTimeStr := ctx.QueryTrim("beginTime") | |||
| endTimeStr := ctx.QueryTrim("endTime") | |||
| var beginTime time.Time | |||
| var endTime time.Time | |||
| var err error | |||
| if queryType != "" { | |||
| if queryType == "all" { | |||
| recordCloudbrainDuration, err := models.GetDurationRecordBeginTime() | |||
| if err != nil { | |||
| log.Error("Can not get GetDurationRecordBeginTime", err) | |||
| ctx.Error(http.StatusBadRequest, ctx.Tr("repo.record_begintime_get_err")) | |||
| return beginTime, endTime | |||
| } | |||
| brainRecordBeginTime := recordCloudbrainDuration[0].CreatedUnix.AsTime() | |||
| beginTime = brainRecordBeginTime | |||
| endTime = now | |||
| } else if queryType == "today" { | |||
| beginTime = now.AddDate(0, 0, 0) | |||
| beginTime = time.Date(beginTime.Year(), beginTime.Month(), beginTime.Day(), 0, 0, 0, 0, now.Location()) | |||
| endTime = now | |||
| } else if queryType == "yesterday" { | |||
| beginTime = now.AddDate(0, 0, -1) | |||
| beginTime = time.Date(beginTime.Year(), beginTime.Month(), beginTime.Day(), 0, 0, 0, 0, now.Location()) | |||
| endTime = time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location()) | |||
| } else if queryType == "last_7day" { | |||
| beginTime = now.AddDate(0, 0, -6) | |||
| beginTime = time.Date(beginTime.Year(), beginTime.Month(), beginTime.Day(), 0, 0, 0, 0, now.Location()) | |||
| endTime = now | |||
| } else if queryType == "last_30day" { | |||
| beginTime = now.AddDate(0, 0, -29) | |||
| beginTime = time.Date(beginTime.Year(), beginTime.Month(), beginTime.Day(), 0, 0, 0, 0, now.Location()) | |||
| endTime = now | |||
| } else if queryType == "current_month" { | |||
| endTime = now | |||
| beginTime = time.Date(endTime.Year(), endTime.Month(), 1, 0, 0, 0, 0, now.Location()) | |||
| } else if queryType == "current_year" { | |||
| endTime = now | |||
| beginTime = time.Date(endTime.Year(), 1, 1, 0, 0, 0, 0, now.Location()) | |||
| } else if queryType == "last_month" { | |||
| lastMonthTime := now.AddDate(0, -1, 0) | |||
| beginTime = time.Date(lastMonthTime.Year(), lastMonthTime.Month(), 1, 0, 0, 0, 0, now.Location()) | |||
| endTime = time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location()) | |||
| } | |||
| } else { | |||
| if beginTimeStr == "" || endTimeStr == "" { | |||
| //如果查询类型和开始时间结束时间都未设置,按queryType=all处理 | |||
| recordCloudbrainDuration, err := models.GetDurationRecordBeginTime() | |||
| if err != nil { | |||
| log.Error("Can not get recordCloudbrain", err) | |||
| ctx.Error(http.StatusBadRequest, ctx.Tr("repo.record_begintime_get_err")) | |||
| return beginTime, endTime | |||
| } | |||
| brainRecordBeginTime := recordCloudbrainDuration[0].CreatedUnix.AsTime() | |||
| beginTime = brainRecordBeginTime | |||
| endTime = now | |||
| } else { | |||
| beginTime, err = time.ParseInLocation("2006-01-02", beginTimeStr, time.Local) | |||
| if err != nil { | |||
| log.Error("Can not ParseInLocation.", err) | |||
| ctx.Error(http.StatusBadRequest, ctx.Tr("ParseInLocation_get_error")) | |||
| return beginTime, endTime | |||
| } | |||
| endTime, err = time.ParseInLocation("2006-01-02", endTimeStr, time.Local) | |||
| if err != nil { | |||
| log.Error("Can not ParseInLocation.", err) | |||
| ctx.Error(http.StatusBadRequest, ctx.Tr("ParseInLocation_get_error")) | |||
| return beginTime, endTime | |||
| } | |||
| if endTime.After(time.Now()) { | |||
| endTime = time.Now() | |||
| } | |||
| } | |||
| } | |||
| return beginTime, endTime | |||
| } | |||
| func getAiCenterUsageDuration(beginTime time.Time, endTime time.Time, cloudbrainStatistics []*models.CloudbrainDurationStatistic) (int, int, float64) { | |||
| totalDuration := int(0) | |||
| usageDuration := int(0) | |||
| usageRate := float64(0) | |||
| for _, cloudbrainStatistic := range cloudbrainStatistics { | |||
| if int64(cloudbrainStatistic.CreatedUnix) >= beginTime.Unix() && int64(cloudbrainStatistic.CreatedUnix) < endTime.Unix() { | |||
| totalDuration += cloudbrainStatistic.CardsTotalDuration | |||
| usageDuration += cloudbrainStatistic.CardsUseDuration | |||
| } | |||
| } | |||
| if totalDuration == 0 || usageDuration == 0 { | |||
| usageRate = 0 | |||
| } else { | |||
| usageRate = float64(usageDuration) / float64(totalDuration) | |||
| } | |||
| return totalDuration, usageDuration, usageRate | |||
| } | |||
| func getDurationStatistic(beginTime time.Time, endTime time.Time) (models.DurationRateStatistic, models.DurationRateStatistic, float64) { | |||
| OpenITotalDuration := make(map[string]int) | |||
| OpenIUsageDuration := make(map[string]int) | |||
| OpenIUsageRate := make(map[string]float64) | |||
| C2NetTotalDuration := make(map[string]int) | |||
| C2NetUsageDuration := make(map[string]int) | |||
| OpenIDurationRate := models.DurationRateStatistic{} | |||
| C2NetDurationRate := models.DurationRateStatistic{} | |||
| cardDurationStatistics, err := models.GetCardDurationStatistics(&models.DurationStatisticOptions{ | |||
| BeginTime: beginTime, | |||
| EndTime: endTime, | |||
| }) | |||
| if err != nil { | |||
| log.Error("GetCardDurationStatistics error:", err) | |||
| return OpenIDurationRate, C2NetDurationRate, 0 | |||
| } | |||
| for _, cloudbrainStatistic := range cardDurationStatistics { | |||
| if cloudbrainStatistic.Cluster == models.OpenICluster { | |||
| if _, ok := OpenITotalDuration[cloudbrainStatistic.AiCenterName]; !ok { | |||
| OpenITotalDuration[cloudbrainStatistic.AiCenterName] = cloudbrainStatistic.CardsTotalDuration | |||
| } else { | |||
| OpenITotalDuration[cloudbrainStatistic.AiCenterName] += cloudbrainStatistic.CardsTotalDuration | |||
| } | |||
| if _, ok := OpenIUsageDuration[cloudbrainStatistic.AiCenterName]; !ok { | |||
| OpenIUsageDuration[cloudbrainStatistic.AiCenterName] = cloudbrainStatistic.CardsUseDuration | |||
| } else { | |||
| OpenIUsageDuration[cloudbrainStatistic.AiCenterName] += cloudbrainStatistic.CardsUseDuration | |||
| } | |||
| } | |||
| if cloudbrainStatistic.Cluster == models.C2NetCluster { | |||
| if _, ok := C2NetTotalDuration[cloudbrainStatistic.AiCenterName]; !ok { | |||
| C2NetTotalDuration[cloudbrainStatistic.AiCenterName] = cloudbrainStatistic.CardsTotalDuration | |||
| } else { | |||
| C2NetTotalDuration[cloudbrainStatistic.AiCenterName] += cloudbrainStatistic.CardsTotalDuration | |||
| } | |||
| if _, ok := C2NetUsageDuration[cloudbrainStatistic.AiCenterName]; !ok { | |||
| C2NetUsageDuration[cloudbrainStatistic.AiCenterName] = cloudbrainStatistic.CardsUseDuration | |||
| } else { | |||
| C2NetUsageDuration[cloudbrainStatistic.AiCenterName] += cloudbrainStatistic.CardsUseDuration | |||
| } | |||
| } | |||
| } | |||
| ResourceAiCenterRes, err := models.GetResourceAiCenters() | |||
| if err != nil { | |||
| log.Error("Can not get ResourceAiCenterRes.", err) | |||
| return OpenIDurationRate, C2NetDurationRate, 0 | |||
| } | |||
| for _, v := range ResourceAiCenterRes { | |||
| if cutString(v.AiCenterCode, 4) == cutString(models.AICenterOfCloudBrainOne, 4) { | |||
| if _, ok := OpenIUsageDuration[v.AiCenterName]; !ok { | |||
| OpenIUsageDuration[v.AiCenterName] = 0 | |||
| } | |||
| if _, ok := OpenITotalDuration[v.AiCenterName]; !ok { | |||
| OpenITotalDuration[v.AiCenterName] = 0 | |||
| } | |||
| } else { | |||
| if _, ok := C2NetUsageDuration[v.AiCenterName]; !ok { | |||
| C2NetUsageDuration[v.AiCenterName] = 0 | |||
| } | |||
| } | |||
| } | |||
| totalCanUse := float64(0) | |||
| totalUse := float64(0) | |||
| totalUsageRate := float64(0) | |||
| for k, v := range OpenITotalDuration { | |||
| for i, j := range OpenIUsageDuration { | |||
| if k == i { | |||
| OpenIUsageRate[k] = float64(j) / float64(v) | |||
| } | |||
| } | |||
| } | |||
| for _, v := range OpenITotalDuration { | |||
| totalCanUse += float64(v) | |||
| } | |||
| for _, v := range OpenIUsageRate { | |||
| totalUse += float64(v) | |||
| } | |||
| if totalCanUse == 0 || totalUse == 0 { | |||
| totalUsageRate = 0 | |||
| } else { | |||
| totalUsageRate = totalUse / totalCanUse | |||
| } | |||
| OpenIDurationRate.AiCenterTotalDurationStat = OpenITotalDuration | |||
| OpenIDurationRate.AiCenterUsageDurationStat = OpenIUsageDuration | |||
| OpenIDurationRate.UsageRate = OpenIUsageRate | |||
| C2NetDurationRate.AiCenterTotalDurationStat = C2NetTotalDuration | |||
| C2NetDurationRate.AiCenterUsageDurationStat = C2NetUsageDuration | |||
| return OpenIDurationRate, C2NetDurationRate, totalUsageRate | |||
| } | |||
| func cutString(str string, lens int) string { | |||
| if len(str) < lens { | |||
| return str | |||
| } | |||
| return str[:lens] | |||
| } | |||
| func getDayCloudbrainDuration(beginTime time.Time, endTime time.Time, aiCenterCode string) ([]models.DateUsageStatistic, int, error) { | |||
| now := time.Now() | |||
| endTimeTemp := time.Date(endTime.Year(), endTime.Month(), endTime.Day(), 0, 0, 0, 0, now.Location()) | |||
| if endTimeTemp.Equal(endTime) { | |||
| endTimeTemp = endTimeTemp.AddDate(0, 0, -1) | |||
| } | |||
| cardDurationStatistics, err := models.GetCardDurationStatistics(&models.DurationStatisticOptions{ | |||
| BeginTime: beginTime, | |||
| EndTime: endTime, | |||
| AiCenterCode: aiCenterCode, | |||
| }) | |||
| if err != nil { | |||
| log.Error("GetCardDurationStatistics error:", err) | |||
| return nil, 0, err | |||
| } | |||
| dayCloudbrainInfo := make([]models.DateUsageStatistic, 0) | |||
| count := 0 | |||
| for beginTime.Before(endTimeTemp) || beginTime.Equal(endTimeTemp) { | |||
| TotalDuration, UsageDuration, UsageRate := getAiCenterUsageDuration(endTimeTemp, endTime, cardDurationStatistics) | |||
| dayCloudbrainInfo = append(dayCloudbrainInfo, models.DateUsageStatistic{ | |||
| Date: endTimeTemp.Format("2006/01/02"), | |||
| UsageDuration: UsageDuration, | |||
| TotalDuration: TotalDuration, | |||
| UsageRate: UsageRate, | |||
| }) | |||
| endTime = endTimeTemp | |||
| endTimeTemp = endTimeTemp.AddDate(0, 0, -1) | |||
| if endTimeTemp.Before(beginTime) && beginTime.Before(endTime) { | |||
| endTimeTemp = beginTime | |||
| } | |||
| count += 1 | |||
| } | |||
| return dayCloudbrainInfo, count, nil | |||
| } | |||
| func getHourCloudbrainDuration(beginTime time.Time, endTime time.Time, aiCenterCode string) (models.HourTimeStatistic, error) { | |||
| hourTimeTotalDuration := make(map[string]int) | |||
| hourTimeUsageDuration := make(map[string]int) | |||
| hourTimeUsageRate := make(map[string]float64) | |||
| hourTimeStatistic := models.HourTimeStatistic{} | |||
| cardDurationStatistics, err := models.GetCardDurationStatistics(&models.DurationStatisticOptions{ | |||
| BeginTime: beginTime, | |||
| EndTime: endTime, | |||
| }) | |||
| if err != nil { | |||
| log.Error("GetCardDurationStatistics error:", err) | |||
| return hourTimeStatistic, err | |||
| } | |||
| for _, cloudbrainStatistic := range cardDurationStatistics { | |||
| if cloudbrainStatistic.AiCenterCode == aiCenterCode { | |||
| if _, ok := hourTimeTotalDuration[strconv.Itoa(cloudbrainStatistic.HourTime)]; !ok { | |||
| hourTimeTotalDuration[strconv.Itoa(cloudbrainStatistic.HourTime)] = cloudbrainStatistic.CardsTotalDuration | |||
| } else { | |||
| hourTimeTotalDuration[strconv.Itoa(cloudbrainStatistic.HourTime)] += cloudbrainStatistic.CardsTotalDuration | |||
| } | |||
| if _, ok := hourTimeUsageDuration[strconv.Itoa(cloudbrainStatistic.HourTime)]; !ok { | |||
| hourTimeUsageDuration[strconv.Itoa(cloudbrainStatistic.HourTime)] = cloudbrainStatistic.CardsUseDuration | |||
| } else { | |||
| hourTimeUsageDuration[strconv.Itoa(cloudbrainStatistic.HourTime)] += cloudbrainStatistic.CardsUseDuration | |||
| } | |||
| } | |||
| } | |||
| hourTimeList := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"} | |||
| for _, v := range hourTimeList { | |||
| if _, ok := hourTimeUsageDuration[v]; !ok { | |||
| hourTimeUsageDuration[v] = 0 | |||
| } | |||
| if _, ok := hourTimeTotalDuration[v]; !ok { | |||
| hourTimeTotalDuration[v] = 0 | |||
| } | |||
| } | |||
| for k, v := range hourTimeTotalDuration { | |||
| for i, j := range hourTimeUsageDuration { | |||
| if k == i { | |||
| if v == 0 || j == 0 { | |||
| hourTimeUsageRate[k] = 0 | |||
| } else { | |||
| hourTimeUsageRate[k] = float64(j) / float64(v) | |||
| } | |||
| } | |||
| } | |||
| } | |||
| hourTimeStatistic.HourTimeTotalDuration = hourTimeTotalDuration | |||
| hourTimeStatistic.HourTimeUsageDuration = hourTimeUsageDuration | |||
| hourTimeStatistic.HourTimeUsageRate = hourTimeUsageRate | |||
| return hourTimeStatistic, nil | |||
| } | |||
| @@ -17,6 +17,7 @@ import ( | |||
| "code.gitea.io/gitea/modules/notification" | |||
| "code.gitea.io/gitea/modules/setting" | |||
| "code.gitea.io/gitea/modules/storage" | |||
| "code.gitea.io/gitea/services/cloudbrain/resource" | |||
| uuid "github.com/satori/go.uuid" | |||
| ) | |||
| @@ -69,13 +70,10 @@ func saveModelByParameters(jobId string, versionName string, name string, versio | |||
| cloudType = models.TypeCloudBrainTwo | |||
| } else if aiTask.ComputeResource == models.GPUResource { | |||
| cloudType = models.TypeCloudBrainOne | |||
| var ResourceSpecs *models.ResourceSpecs | |||
| json.Unmarshal([]byte(setting.ResourceSpecs), &ResourceSpecs) | |||
| for _, tmp := range ResourceSpecs.ResourceSpec { | |||
| if tmp.Id == aiTask.ResourceSpecId { | |||
| flaverName := ctx.Tr("cloudbrain.gpu_num") + ": " + fmt.Sprint(tmp.GpuNum) + " " + ctx.Tr("cloudbrain.cpu_num") + ": " + fmt.Sprint(tmp.CpuNum) + " " + ctx.Tr("cloudbrain.memory") + "(MB): " + fmt.Sprint(tmp.MemMiB) + " " + ctx.Tr("cloudbrain.shared_memory") + "(MB): " + fmt.Sprint(tmp.ShareMemMiB) | |||
| aiTask.FlavorName = flaverName | |||
| } | |||
| spec, err := resource.GetCloudbrainSpec(aiTask.ID) | |||
| if err == nil { | |||
| flaverName := "GPU: " + fmt.Sprint(spec.AccCardsNum) + "*" + spec.AccCardType + ",CPU: " + fmt.Sprint(spec.CpuCores) + "," + ctx.Tr("cloudbrain.memory") + ": " + fmt.Sprint(spec.MemGiB) + "GB," + ctx.Tr("cloudbrain.shared_memory") + ": " + fmt.Sprint(spec.ShareMemGiB) + "GB" | |||
| aiTask.FlavorName = flaverName | |||
| } | |||
| } | |||
| @@ -26,7 +26,6 @@ import ( | |||
| "code.gitea.io/gitea/modules/util" | |||
| "code.gitea.io/gitea/services/cloudbrain/resource" | |||
| "code.gitea.io/gitea/services/reward/point/account" | |||
| uuid "github.com/satori/go.uuid" | |||
| ) | |||
| const ( | |||
| @@ -37,39 +36,6 @@ const ( | |||
| tplModelSafetyTestShow = "repo/modelsafety/show" | |||
| ) | |||
| func CloudBrainAiSafetyCreateTest(ctx *context.Context) { | |||
| log.Info("start to create CloudBrainAiSafetyCreate") | |||
| uuid := uuid.NewV4() | |||
| id := uuid.String() | |||
| seriaNoParas := ctx.Query("serialNo") | |||
| fileName := ctx.Query("fileName") | |||
| //if jobType == string(models.JobTypeBenchmark) { | |||
| req := aisafety.TaskReq{ | |||
| UnionId: id, | |||
| EvalName: "test1", | |||
| EvalContent: "test1", | |||
| TLPath: "test1", | |||
| Indicators: []string{"ACC", "ASS"}, | |||
| CDName: "CIFAR10_1000_FGSM", | |||
| BDName: "CIFAR10_1000基础数据集", | |||
| } | |||
| aisafety.GetAlgorithmList() | |||
| if seriaNoParas != "" { | |||
| aisafety.GetTaskStatus(seriaNoParas) | |||
| } else { | |||
| jsonStr, err := getJsonContent("http://192.168.207.34:8065/Test_zap1234/openi_aisafety/raw/branch/master/result/" + fileName) | |||
| serialNo, err := aisafety.CreateSafetyTask(req, jsonStr) | |||
| if err == nil { | |||
| log.Info("serialNo=" + serialNo) | |||
| time.Sleep(time.Duration(2) * time.Second) | |||
| aisafety.GetTaskStatus(serialNo) | |||
| } else { | |||
| log.Info("CreateSafetyTask error," + err.Error()) | |||
| } | |||
| } | |||
| } | |||
| func GetAiSafetyTaskByJob(job *models.Cloudbrain) { | |||
| if job == nil { | |||
| log.Error("GetCloudbrainByJobID failed") | |||
| @@ -325,6 +291,7 @@ func queryTaskStatusFromCloudbrain(job *models.Cloudbrain) { | |||
| } else { | |||
| // | |||
| job.Status = string(models.ModelSafetyTesting) | |||
| job.EndTime = 0 | |||
| err = models.UpdateJob(job) | |||
| if err != nil { | |||
| log.Error("UpdateJob failed:", err) | |||
| @@ -341,6 +308,9 @@ func queryTaskStatusFromModelSafetyTestServer(job *models.Cloudbrain) { | |||
| if result.Data.Status == 1 { | |||
| log.Info("The task is running....") | |||
| } else { | |||
| job.EndTime = timeutil.TimeStampNow() | |||
| job.Duration = (job.EndTime.AsTime().Unix() - job.StartTime.AsTime().Unix()) / 1000 | |||
| job.TrainJobDuration = models.ConvertDurationToStr(job.Duration) | |||
| if result.Data.Code == 0 { | |||
| job.ResultJson = result.Data.StandardJson | |||
| job.Status = string(models.JobSucceeded) | |||
| @@ -474,6 +444,9 @@ func updateJobFailed(job *models.Cloudbrain, msg string) { | |||
| //update task failed. | |||
| job.Status = string(models.ModelArtsTrainJobFailed) | |||
| job.ResultJson = msg | |||
| job.EndTime = timeutil.TimeStampNow() | |||
| job.Duration = (job.EndTime.AsTime().Unix() - job.StartTime.AsTime().Unix()) / 1000 | |||
| job.TrainJobDuration = models.ConvertDurationToStr(job.Duration) | |||
| err := models.UpdateJob(job) | |||
| if err != nil { | |||
| log.Error("UpdateJob failed:", err) | |||
| @@ -752,47 +752,48 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| result, err := cloudbrain.GetJob(task.JobID) | |||
| if err != nil { | |||
| log.Info("error:" + err.Error()) | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| prepareSpec4Show(ctx, task) | |||
| if ctx.Written() { | |||
| return | |||
| } | |||
| if task.Status==string(models.JobWaiting) || task.Status==string(models.JobRunning) { | |||
| result, err := cloudbrain.GetJob(task.JobID) | |||
| if err != nil { | |||
| log.Info("error:" + err.Error()) | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| if result != nil { | |||
| jobRes, _ := models.ConvertToJobResultPayload(result.Payload) | |||
| taskRoles := jobRes.TaskRoles | |||
| taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) | |||
| ctx.Data["taskRes"] = taskRes | |||
| ctx.Data["ExitDiagnostics"] = taskRes.TaskStatuses[0].ExitDiagnostics | |||
| oldStatus := task.Status | |||
| task.Status = taskRes.TaskStatuses[0].State | |||
| task.ContainerIp = "" | |||
| task.ContainerID = taskRes.TaskStatuses[0].ContainerID | |||
| models.ParseAndSetDurationFromCloudBrainOne(jobRes, task) | |||
| if task.DeletedAt.IsZero() { //normal record | |||
| if oldStatus != task.Status { | |||
| notification.NotifyChangeCloudbrainStatus(task, oldStatus) | |||
| } | |||
| err = models.UpdateJob(task) | |||
| if err != nil { | |||
| ctx.Data["error"] = err.Error() | |||
| return | |||
| } | |||
| } else { //deleted record | |||
| if result != nil { | |||
| jobRes, _ := models.ConvertToJobResultPayload(result.Payload) | |||
| taskRoles := jobRes.TaskRoles | |||
| taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) | |||
| ctx.Data["taskRes"] = taskRes | |||
| ctx.Data["ExitDiagnostics"] = taskRes.TaskStatuses[0].ExitDiagnostics | |||
| oldStatus := task.Status | |||
| task.Status = taskRes.TaskStatuses[0].State | |||
| task.ContainerIp = "" | |||
| task.ContainerID = taskRes.TaskStatuses[0].ContainerID | |||
| models.ParseAndSetDurationFromCloudBrainOne(jobRes, task) | |||
| if task.DeletedAt.IsZero() { //normal record | |||
| if oldStatus != task.Status { | |||
| notification.NotifyChangeCloudbrainStatus(task, oldStatus) | |||
| } | |||
| err = models.UpdateJob(task) | |||
| if err != nil { | |||
| ctx.Data["error"] = err.Error() | |||
| return | |||
| } | |||
| } else { //deleted record | |||
| ctx.Data["result"] = jobRes | |||
| } else { | |||
| log.Info("error:" + err.Error()) | |||
| return | |||
| } | |||
| ctx.Data["result"] = jobRes | |||
| } else { | |||
| log.Info("error:" + err.Error()) | |||
| return | |||
| } | |||
| user, err := models.GetUserByID(task.UserID) | |||
| @@ -0,0 +1,169 @@ | |||
| package repo | |||
| import ( | |||
| "strings" | |||
| "time" | |||
| "code.gitea.io/gitea/models" | |||
| "code.gitea.io/gitea/modules/log" | |||
| "code.gitea.io/gitea/modules/timeutil" | |||
| ) | |||
| func CloudbrainDurationStatisticHour() { | |||
| dateTime := time.Now().Format("2006-01-02 15:04:05") | |||
| dayTime := time.Now().Format("2006-01-02") | |||
| now := time.Now() | |||
| currentTime := time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), 0, 0, 0, now.Location()) | |||
| m, _ := time.ParseDuration("-1h") | |||
| beginTime := currentTime.Add(m).Unix() | |||
| endTime := currentTime.Unix() | |||
| hourTime := currentTime.Add(m).Hour() | |||
| ciTasks, err := models.GetCloudbrainByTime(beginTime, endTime) | |||
| if err != nil { | |||
| log.Info("GetCloudbrainByTime err: %v", err) | |||
| return | |||
| } | |||
| specMap := make(map[string]*models.Specification) | |||
| models.LoadSpecs4CloudbrainInfo(ciTasks) | |||
| for _, cloudbrain := range ciTasks { | |||
| if _, ok := specMap[cloudbrain.Cloudbrain.Spec.AiCenterCode+"/"+cloudbrain.Cloudbrain.Spec.AccCardType]; !ok { | |||
| if cloudbrain.Cloudbrain.Spec != nil { | |||
| specMap[cloudbrain.Cloudbrain.Spec.AiCenterCode+"/"+cloudbrain.Cloudbrain.Spec.AccCardType] = cloudbrain.Cloudbrain.Spec | |||
| } | |||
| } | |||
| } | |||
| cloudBrainCenterCodeAndCardTypeInfo := getcloudBrainCenterCodeAndCardTypeInfo(ciTasks, beginTime, endTime) | |||
| resourceQueues, err := models.GetCanUseCardInfo() | |||
| if err != nil { | |||
| log.Info("GetCanUseCardInfo err: %v", err) | |||
| return | |||
| } | |||
| cardsTotalDurationMap := make(map[string]int) | |||
| for _, resourceQueue := range resourceQueues { | |||
| cardsTotalDurationMap[resourceQueue.Cluster+"/"+resourceQueue.AiCenterName+"/"+resourceQueue.AiCenterCode+"/"+resourceQueue.AccCardType+"/"+resourceQueue.ComputeResource] = resourceQueue.CardsTotalNum * 1 * 60 * 60 | |||
| } | |||
| for centerCode, CardTypeInfo := range cloudBrainCenterCodeAndCardTypeInfo { | |||
| for cardType, cardDuration := range CardTypeInfo { | |||
| spec := specMap[centerCode+"/"+cardType] | |||
| if spec != nil { | |||
| if err := models.DeleteCloudbrainDurationStatisticHour(dayTime, hourTime, centerCode, cardType); err != nil { | |||
| log.Error("DeleteCloudbrainDurationStatisticHour failed: %v", err.Error()) | |||
| return | |||
| } | |||
| if _, ok := cardsTotalDurationMap[spec.Cluster+"/"+spec.AiCenterName+"/"+centerCode+"/"+cardType+"/"+spec.ComputeResource]; !ok { | |||
| cardsTotalDurationMap[spec.Cluster+"/"+spec.AiCenterName+"/"+centerCode+"/"+cardType+"/"+spec.ComputeResource] = 0 | |||
| } | |||
| cloudbrainDurationStat := models.CloudbrainDurationStatistic{ | |||
| DateTime: dateTime, | |||
| DayTime: dayTime, | |||
| HourTime: hourTime, | |||
| Cluster: spec.Cluster, | |||
| AiCenterName: spec.AiCenterName, | |||
| AiCenterCode: centerCode, | |||
| AccCardType: cardType, | |||
| ComputeResource: spec.ComputeResource, | |||
| CardsUseDuration: cardDuration, | |||
| CardsTotalDuration: cardsTotalDurationMap[spec.Cluster+"/"+spec.AiCenterName+"/"+centerCode+"/"+cardType+"/"+spec.ComputeResource], | |||
| CreatedUnix: timeutil.TimeStampNow(), | |||
| } | |||
| if _, err = models.InsertCloudbrainDurationStatistic(&cloudbrainDurationStat); err != nil { | |||
| log.Error("Insert cloudbrainDurationStat failed: %v", err.Error()) | |||
| } | |||
| delete(cardsTotalDurationMap, spec.Cluster+"/"+spec.AiCenterName+"/"+centerCode+"/"+cardType+"/"+spec.ComputeResource) | |||
| } | |||
| } | |||
| } | |||
| for key, cardsTotalDuration := range cardsTotalDurationMap { | |||
| if err := models.DeleteCloudbrainDurationStatisticHour(dayTime, hourTime, strings.Split(key, "/")[2], strings.Split(key, "/")[3]); err != nil { | |||
| log.Error("DeleteCloudbrainDurationStatisticHour failed: %v", err.Error()) | |||
| return | |||
| } | |||
| cloudbrainDurationStat := models.CloudbrainDurationStatistic{ | |||
| DateTime: dateTime, | |||
| DayTime: dayTime, | |||
| HourTime: hourTime, | |||
| Cluster: strings.Split(key, "/")[0], | |||
| AiCenterName: strings.Split(key, "/")[1], | |||
| AiCenterCode: strings.Split(key, "/")[2], | |||
| AccCardType: strings.Split(key, "/")[3], | |||
| ComputeResource: strings.Split(key, "/")[4], | |||
| CardsUseDuration: 0, | |||
| CardsTotalDuration: cardsTotalDuration, | |||
| CreatedUnix: timeutil.TimeStampNow(), | |||
| } | |||
| if _, err = models.InsertCloudbrainDurationStatistic(&cloudbrainDurationStat); err != nil { | |||
| log.Error("Insert cloudbrainDurationStat failed: %v", err.Error()) | |||
| } | |||
| } | |||
| log.Info("finish summary cloudbrainDurationStat") | |||
| } | |||
| func getcloudBrainCenterCodeAndCardTypeInfo(ciTasks []*models.CloudbrainInfo, beginTime int64, endTime int64) map[string]map[string]int { | |||
| var WorkServerNumber int | |||
| var AccCardsNum int | |||
| cloudBrainCenterCodeAndCardType := make(map[string]map[string]int) | |||
| for _, cloudbrain := range ciTasks { | |||
| if cloudbrain.Cloudbrain.StartTime == 0 { | |||
| cloudbrain.Cloudbrain.StartTime = cloudbrain.Cloudbrain.CreatedUnix | |||
| } | |||
| if cloudbrain.Cloudbrain.EndTime == 0 { | |||
| cloudbrain.Cloudbrain.EndTime = cloudbrain.Cloudbrain.UpdatedUnix | |||
| } | |||
| if cloudbrain.Cloudbrain.WorkServerNumber >= 1 { | |||
| WorkServerNumber = cloudbrain.Cloudbrain.WorkServerNumber | |||
| } else { | |||
| WorkServerNumber = 1 | |||
| } | |||
| if cloudbrain.Cloudbrain.Spec == nil { | |||
| AccCardsNum = 1 | |||
| } else { | |||
| AccCardsNum = cloudbrain.Cloudbrain.Spec.AccCardsNum | |||
| } | |||
| if _, ok := cloudBrainCenterCodeAndCardType[cloudbrain.Cloudbrain.Spec.AiCenterCode]; !ok { | |||
| cloudBrainCenterCodeAndCardType[cloudbrain.Cloudbrain.Spec.AiCenterCode] = make(map[string]int) | |||
| } | |||
| if cloudbrain.Cloudbrain.Status == string(models.ModelArtsRunning) { | |||
| if _, ok := cloudBrainCenterCodeAndCardType[cloudbrain.Cloudbrain.Spec.AiCenterCode][cloudbrain.Cloudbrain.Spec.AccCardType]; !ok { | |||
| if int64(cloudbrain.Cloudbrain.StartTime) < beginTime { | |||
| cloudBrainCenterCodeAndCardType[cloudbrain.Cloudbrain.Spec.AiCenterCode][cloudbrain.Cloudbrain.Spec.AccCardType] = AccCardsNum * WorkServerNumber * (int(endTime) - int(beginTime)) | |||
| } else { | |||
| cloudBrainCenterCodeAndCardType[cloudbrain.Cloudbrain.Spec.AiCenterCode][cloudbrain.Cloudbrain.Spec.AccCardType] = AccCardsNum * WorkServerNumber * (int(endTime) - int(cloudbrain.Cloudbrain.StartTime)) | |||
| } | |||
| } else { | |||
| if int64(cloudbrain.Cloudbrain.StartTime) < beginTime { | |||
| cloudBrainCenterCodeAndCardType[cloudbrain.Cloudbrain.Spec.AiCenterCode][cloudbrain.Cloudbrain.Spec.AccCardType] += AccCardsNum * WorkServerNumber * (int(endTime) - int(beginTime)) | |||
| } else { | |||
| cloudBrainCenterCodeAndCardType[cloudbrain.Cloudbrain.Spec.AiCenterCode][cloudbrain.Cloudbrain.Spec.AccCardType] += AccCardsNum * WorkServerNumber * (int(endTime) - int(cloudbrain.Cloudbrain.StartTime)) | |||
| } | |||
| } | |||
| } else { | |||
| if _, ok := cloudBrainCenterCodeAndCardType[cloudbrain.Cloudbrain.Spec.AiCenterCode][cloudbrain.Cloudbrain.Spec.AccCardType]; !ok { | |||
| if int64(cloudbrain.Cloudbrain.StartTime) < beginTime { | |||
| cloudBrainCenterCodeAndCardType[cloudbrain.Cloudbrain.Spec.AiCenterCode][cloudbrain.Cloudbrain.Spec.AccCardType] = AccCardsNum * WorkServerNumber * (int(cloudbrain.Cloudbrain.EndTime) - int(beginTime)) | |||
| } else { | |||
| cloudBrainCenterCodeAndCardType[cloudbrain.Cloudbrain.Spec.AiCenterCode][cloudbrain.Cloudbrain.Spec.AccCardType] = AccCardsNum * WorkServerNumber * (int(cloudbrain.Cloudbrain.EndTime) - int(cloudbrain.Cloudbrain.StartTime)) | |||
| } | |||
| } else { | |||
| if int64(cloudbrain.Cloudbrain.StartTime) < beginTime { | |||
| cloudBrainCenterCodeAndCardType[cloudbrain.Cloudbrain.Spec.AiCenterCode][cloudbrain.Cloudbrain.Spec.AccCardType] += AccCardsNum * WorkServerNumber * (int(cloudbrain.Cloudbrain.EndTime) - int(beginTime)) | |||
| } else { | |||
| cloudBrainCenterCodeAndCardType[cloudbrain.Cloudbrain.Spec.AiCenterCode][cloudbrain.Cloudbrain.Spec.AccCardType] += AccCardsNum * WorkServerNumber * (int(cloudbrain.Cloudbrain.EndTime) - int(cloudbrain.Cloudbrain.StartTime)) | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return cloudBrainCenterCodeAndCardType | |||
| } | |||
| @@ -523,6 +523,7 @@ func ReferenceDatasetAvailable(ctx *context.Context) { | |||
| PublicOnly: true, | |||
| NeedAttachment: false, | |||
| CloudBrainType: models.TypeCloudBrainAll, | |||
| SearchOrderBy: models.SearchOrderByDefault, | |||
| } | |||
| dataset, _ := models.GetDatasetByRepo(&models.Repository{ID: ctx.Repo.Repository.ID}) | |||
| if dataset != nil { | |||
| @@ -538,6 +539,7 @@ func PublicDatasetMultiple(ctx *context.Context) { | |||
| PublicOnly: true, | |||
| NeedAttachment: true, | |||
| CloudBrainType: ctx.QueryInt("type"), | |||
| SearchOrderBy: models.SearchOrderByDefault, | |||
| } | |||
| datasetMultiple(ctx, opts) | |||
| @@ -37,6 +37,7 @@ import ( | |||
| "code.gitea.io/gitea/modules/context" | |||
| "code.gitea.io/gitea/modules/log" | |||
| "code.gitea.io/gitea/modules/setting" | |||
| cloudbrainService "code.gitea.io/gitea/services/cloudbrain" | |||
| ) | |||
| const ( | |||
| @@ -915,10 +916,7 @@ func GrampusTrainJobShow(ctx *context.Context) { | |||
| ctx.Data["canDownload"] = cloudbrain.CanModifyJob(ctx, task) | |||
| ctx.Data["displayJobName"] = task.DisplayJobName | |||
| aiCenterInfo := strings.Split(task.AiCenter, "+") | |||
| if len(aiCenterInfo) == 2 { | |||
| ctx.Data["ai_center"] = aiCenterInfo[1] | |||
| } | |||
| ctx.Data["ai_center"] = cloudbrainService.GetAiCenterShow(task.AiCenter,ctx) | |||
| ctx.HTML(http.StatusOK, tplGrampusTrainJobShow) | |||
| } | |||
| @@ -1312,6 +1312,36 @@ func getUserCommand(engineId int, req *modelarts.GenerateTrainJobReq) (string, s | |||
| return userCommand, userImageUrl | |||
| } | |||
| func getInfJobUserCommand(engineId int, req *modelarts.GenerateInferenceJobReq) (string, string) { | |||
| userImageUrl := "" | |||
| userCommand := "" | |||
| if engineId < 0 { | |||
| tmpCodeObsPath := strings.Trim(req.CodeObsPath, "/") | |||
| tmpCodeObsPaths := strings.Split(tmpCodeObsPath, "/") | |||
| lastCodeDir := "code" | |||
| if len(tmpCodeObsPaths) > 0 { | |||
| lastCodeDir = tmpCodeObsPaths[len(tmpCodeObsPaths)-1] | |||
| } | |||
| userCommand = "/bin/bash /home/work/run_train.sh 's3://" + req.CodeObsPath + "' '" + lastCodeDir + "/" + req.BootFile + "' '/tmp/log/train.log' --'data_url'='s3://" + req.DataUrl + "' --'train_url'='s3://" + req.TrainUrl + "'" | |||
| var versionInfos modelarts.VersionInfo | |||
| if err := json.Unmarshal([]byte(setting.EngineVersions), &versionInfos); err != nil { | |||
| log.Info("json parse err." + err.Error()) | |||
| } else { | |||
| for _, engine := range versionInfos.Version { | |||
| if engine.ID == engineId { | |||
| userImageUrl = engine.Url | |||
| break | |||
| } | |||
| } | |||
| } | |||
| for _, param := range req.Parameters { | |||
| userCommand += " --'" + param.Label + "'='" + param.Value + "'" | |||
| } | |||
| return userCommand, userImageUrl | |||
| } | |||
| return userCommand, userImageUrl | |||
| } | |||
| func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) { | |||
| ctx.Data["PageIsTrainJob"] = true | |||
| var jobID = ctx.Params(":jobid") | |||
| @@ -2171,6 +2201,10 @@ func InferenceJobCreate(ctx *context.Context, form auth.CreateModelArtsInference | |||
| JobType: string(models.JobTypeInference), | |||
| } | |||
| userCommand, userImageUrl := getInfJobUserCommand(engineID, req) | |||
| req.UserCommand = userCommand | |||
| req.UserImageUrl = userImageUrl | |||
| err = modelarts.GenerateInferenceJob(ctx, req) | |||
| if err != nil { | |||
| log.Error("GenerateTrainJob failed:%v", err.Error()) | |||
| @@ -6,17 +6,18 @@ package routes | |||
| import ( | |||
| "bytes" | |||
| "code.gitea.io/gitea/routers/badge" | |||
| "code.gitea.io/gitea/routers/reward/point" | |||
| "code.gitea.io/gitea/routers/task" | |||
| badge_service "code.gitea.io/gitea/services/badge" | |||
| "code.gitea.io/gitea/services/reward" | |||
| "encoding/gob" | |||
| "net/http" | |||
| "path" | |||
| "text/template" | |||
| "time" | |||
| "code.gitea.io/gitea/routers/badge" | |||
| "code.gitea.io/gitea/routers/reward/point" | |||
| "code.gitea.io/gitea/routers/task" | |||
| badge_service "code.gitea.io/gitea/services/badge" | |||
| "code.gitea.io/gitea/services/reward" | |||
| "code.gitea.io/gitea/routers/modelapp" | |||
| "code.gitea.io/gitea/modules/slideimage" | |||
| @@ -0,0 +1,33 @@ | |||
| package cloudbrain | |||
| import ( | |||
| "code.gitea.io/gitea/modules/context" | |||
| "code.gitea.io/gitea/modules/setting" | |||
| "strings" | |||
| ) | |||
| func GetAiCenterShow(aiCenter string,ctx *context.Context) string{ | |||
| aiCenterInfo := strings.Split(aiCenter, "+") | |||
| if len(aiCenterInfo) == 2{ | |||
| if setting.C2NetMapInfo!=nil { | |||
| if info,ok:=setting.C2NetMapInfo[aiCenterInfo[0]];ok { | |||
| if ctx.Language() == "zh-CN" { | |||
| return info.Content | |||
| } else { | |||
| return info.ContentEN | |||
| } | |||
| }else{ | |||
| return aiCenterInfo[1] | |||
| } | |||
| }else{ | |||
| return aiCenterInfo[1] | |||
| } | |||
| } | |||
| return "" | |||
| } | |||
| @@ -45,7 +45,7 @@ | |||
| <div class="sixteen wide mobile eight wide tablet eight wide computer column" style=" margin:2.0rem 0"> | |||
| {{.i18n.Tr "custom.foot.copyright"}} <a href="http://beian.miit.gov.cn/" target="_blank">京ICP备18004880号</a> | |||
| <br> | |||
| {{.i18n.Tr "Powered_by 鹏城实验室云脑、"}}<a href="https://www.trustie.net/" target="_blank">Trustie确实</a>{{.i18n.Tr "、gitea"}} | |||
| {{.i18n.Tr "home.powerdby"}}<a href="https://www.trustie.net/" target="_blank">Trustie确实</a>{{.i18n.Tr "、Gitea"}} | |||
| <br> | |||
| </div> | |||
| </div> | |||
| @@ -1,11 +1,10 @@ | |||
| {{if .NotStopTaskCount}} | |||
| <div class="ui message" style="background-color: rgba(242, 113, 28, 0.05);border: 1px solid rgba(242, 113, 28, 1);border-radius: 5px;"> | |||
| <i class="close icon"></i> | |||
| <div class="ui message" style="background-color: rgba(242, 113, 28, 0.05);border: 1px solid rgba(242, 113, 28, 1);border-radius: 5px;"> | |||
| <div style="display: flex;align-items: center;"> | |||
| <i class="ri-information-line" style="font-size: 35px;color: rgba(242, 113, 28, 1);;"></i> | |||
| <div style="text-align: left;margin-left: 1rem;"> | |||
| <div style="font-weight: 600;line-height: 2;">您已经有 <span style="color:rgba(242, 113, 28, 1);">同类任务</span> 正在等待或运行中,请等待任务结束再创建</div> | |||
| <div style="color:#939393">可以在 “<a href="/cloudbrains" >个人中心 > 云脑任务</a>” 查看您所有的云脑任务</div> | |||
| <div style="font-weight: 600;line-height: 2;">{{.i18n.Tr "repo.cloudbrain.morethanonejob1" | Safe }}</div> | |||
| <div style="color:#939393">{{.i18n.Tr "repo.cloudbrain.morethanonejob2" | Safe}}</div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| @@ -1,7 +1,7 @@ | |||
| <div class="badge-achive"> | |||
| {{range .AllBadges }} | |||
| <div class="bagde-section"> | |||
| <div class="badge-section-title">{{.CategoryName}} (已点亮{{.LightedNum}}个)</div> | |||
| <div class="badge-section-title">{{.CategoryName}} (已点亮 {{.LightedNum}} 个)</div> | |||
| <div class="badge-section-children"> | |||
| <div class="badge-honor-badge"> | |||
| <div class="badge-honor-badge-basic"> | |||
| @@ -32,7 +32,9 @@ | |||
| <div class="repository"> | |||
| {{template "repo/header" .}} | |||
| <div class="ui container"> | |||
| {{template "base/alert" .}} | |||
| {{if eq .NotStopTaskCount 0}} | |||
| {{template "base/alert" .}} | |||
| {{end}} | |||
| {{template "custom/alert_cb" .}} | |||
| <h4 class="ui top attached header"> | |||
| {{.i18n.Tr "repo.modelarts.evaluate_job.new_job"}} | |||
| @@ -151,7 +153,7 @@ | |||
| </div> | |||
| <div class="inline min_title field"> | |||
| <label class="label-fix-width" style="font-weight: normal;"></label> | |||
| <button class="ui create_train_job green button"> | |||
| <button class="ui create_train_job green button {{if eq .NotStopTaskCount 1}}disabled{{end}}"> | |||
| {{.i18n.Tr "repo.cloudbrain.new"}} | |||
| </button> | |||
| <a class="ui button" href="/">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a> | |||
| @@ -283,7 +285,7 @@ | |||
| <div class="inline unite min_title field"> | |||
| <label class="label-fix-width" style="font-weight: normal;"></label> | |||
| <button class="ui create_train_job green button"> | |||
| <button class="ui create_train_job green button {{if eq .NotStopTaskCount 1}}disabled{{end}}"> | |||
| {{.i18n.Tr "repo.cloudbrain.new"}} | |||
| </button> | |||
| <a class="ui button" href="/">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a> | |||
| @@ -354,7 +356,7 @@ | |||
| <div class="inline unite min_title field"> | |||
| <label class="label-fix-width" style="font-weight: normal;"></label> | |||
| <button class="ui create_train_job green button"> | |||
| <button class="ui create_train_job green button {{if eq .NotStopTaskCount 1}}disabled{{end}}"> | |||
| {{.i18n.Tr "repo.cloudbrain.new"}} | |||
| </button> | |||
| <a class="ui button" href="/">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a> | |||
| @@ -40,7 +40,9 @@ | |||
| <div class="repository"> | |||
| {{template "repo/header" .}} | |||
| <div class="ui container"> | |||
| {{template "base/alert" .}} | |||
| {{if eq .NotStopTaskCount 0}} | |||
| {{template "base/alert" .}} | |||
| {{end}} | |||
| {{template "custom/alert_cb" .}} | |||
| <div class="cloudbrain-type" style="display: none;" data-cloudbrain-type="{{.datasetType}}" data-repo-link="{{.RepoLink}}" data-queue="{{.QueuesDetail}}" data-queue-start="{{.i18n.Tr "repo.wait_count_start"}}" data-queue-end="{{.i18n.Tr "repo.wait_count_end"}}"></div> | |||
| <h4 class="ui top attached header"> | |||
| @@ -272,7 +274,7 @@ | |||
| <!-- 表单操作 --> | |||
| <div class="inline min_title field"> | |||
| <label class="label-fix-width" style="font-weight: normal;"></label> | |||
| <button class="ui create_train_job green button"> | |||
| <button class="ui create_train_job green button {{if eq .NotStopTaskCount 1}}disabled{{end}}"> | |||
| {{.i18n.Tr "repo.cloudbrain.new"}} | |||
| </button> | |||
| <a class="ui button" href="{{.RepoLink}}/modelarts/inference-job">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a> | |||
| @@ -24,7 +24,9 @@ | |||
| <div class="repository new repo ui middle very relaxed page grid"> | |||
| <div class="column"> | |||
| <div class="cloudbrain-type" style="display: none;" data-cloudbrain-type="{{.datasetType}}" data-repo-link="{{.RepoLink}}" data-queue="{{.QueuesDetail}}" data-queue-start="{{.i18n.Tr "repo.wait_count_start"}}" data-queue-end="{{.i18n.Tr "repo.wait_count_end"}}"></div> | |||
| {{template "base/alert" .}} | |||
| {{if eq .NotStopTaskCount 0}} | |||
| {{template "base/alert" .}} | |||
| {{end}} | |||
| <div class="ui negative message" id="messageInfo" style="display:none;"> | |||
| <p></p> | |||
| </div> | |||
| @@ -200,7 +202,7 @@ | |||
| <div class="inline field"> | |||
| <label></label> | |||
| <button class="ui green button"> | |||
| <button class="ui green button {{if eq .NotStopTaskCount 1}}disabled{{end}}"> | |||
| {{.i18n.Tr "repo.cloudbrain.new"}} | |||
| </button> | |||
| <a class="ui button cancel" | |||
| @@ -71,7 +71,9 @@ | |||
| {{template "repo/header" .}} | |||
| <div class="ui container"> | |||
| <div class="cloudbrain-type" style="display: none;" data-cloudbrain-type="{{.datasetType}}" data-repo-link="{{.RepoLink}}" data-flag-model="true" data-dataset-uuid="{{.attachment}}" data-dataset-name="{{.dataset_name}}" data-queue="{{.QueuesDetail}}" data-queue-start="{{.i18n.Tr "repo.wait_count_start"}}" data-queue-end="{{.i18n.Tr "repo.wait_count_end"}}"></div> | |||
| {{template "base/alert" .}} | |||
| {{if eq .NotStopTaskCount 0}} | |||
| {{template "base/alert" .}} | |||
| {{end}} | |||
| {{template "custom/alert_cb" .}} | |||
| <h4 class="ui top attached header"> | |||
| {{.i18n.Tr "repo.modelarts.train_job.new"}} | |||
| @@ -232,7 +234,7 @@ | |||
| <div class="inline field" style="padding: 1rem 0;"> | |||
| <label class="label-fix-width"></label> | |||
| <button class="ui create_train_job green button"> | |||
| <button class="ui create_train_job green button {{if eq .NotStopTaskCount 1}}disabled{{end}}"> | |||
| {{.i18n.Tr "repo.cloudbrain.new"}} | |||
| </button> | |||
| <a class="ui button __btn-cancel-back__" | |||
| @@ -63,7 +63,9 @@ | |||
| {{template "repo/header" .}} | |||
| <div class="ui container"> | |||
| <div class="cloudbrain-type" style="display: none;" data-cloudbrain-type="{{.datasetType}}" data-repo-link="{{.RepoLink}}" data-flag-model="true" data-dataset-uuid="{{.attachment}}" data-dataset-name="{{.dataset_name}}"></div> | |||
| {{template "base/alert" .}} | |||
| {{if eq .NotStopTaskCount 0}} | |||
| {{template "base/alert" .}} | |||
| {{end}} | |||
| {{template "custom/alert_cb" .}} | |||
| <h4 class="ui top attached header"> | |||
| {{.i18n.Tr "repo.modelarts.train_job.new"}} | |||
| @@ -205,7 +207,7 @@ | |||
| <div class="inline min_title field"> | |||
| <label class="label-fix-width"></label> | |||
| <button class="ui create_train_job green button"> | |||
| <button class="ui create_train_job green button {{if eq .NotStopTaskCount 1}}disabled{{end}}"> | |||
| {{.i18n.Tr "repo.cloudbrain.new"}} | |||
| </button> | |||
| <a class="ui button __btn-cancel-back__" href="{{.RepoLink}}/modelarts/train-job">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a> | |||
| @@ -58,7 +58,9 @@ | |||
| {{template "repo/header" .}} | |||
| <div class="ui container"> | |||
| <div class="cloudbrain-type" style="display: none;" data-cloudbrain-type="{{.datasetType}}" data-repo-link="{{.RepoLink}}" data-flag-model="true" data-dataset-uuid="{{.attachment}}" data-dataset-name="{{.dataset_name}}"></div> | |||
| {{template "base/alert" .}} | |||
| {{if eq .NotStopTaskCount 0}} | |||
| {{template "base/alert" .}} | |||
| {{end}} | |||
| {{template "custom/alert_cb" .}} | |||
| <h4 class="ui top attached header"> | |||
| {{.i18n.Tr "repo.modelarts.train_job.new"}} | |||
| @@ -229,7 +231,7 @@ | |||
| <div class="inline min_title field"> | |||
| <label class="label-fix-width"></label> | |||
| <button class="ui create_train_job green button"> | |||
| <button class="ui create_train_job green button {{if eq .NotStopTaskCount 1}}disabled{{end}}"> | |||
| {{.i18n.Tr "repo.cloudbrain.new"}} | |||
| </button> | |||
| <a class="ui button __btn-cancel-back__" href="{{.RepoLink}}/modelarts/train-job">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a> | |||
| @@ -39,7 +39,9 @@ | |||
| <div class="repository"> | |||
| {{template "repo/header" .}} | |||
| <div class="ui container"> | |||
| {{template "base/alert" .}} | |||
| {{if eq .NotStopTaskCount 0}} | |||
| {{template "base/alert" .}} | |||
| {{end}} | |||
| {{template "custom/alert_cb" .}} | |||
| <div class="cloudbrain-type" style="display: none;" data-cloudbrain-type="1" data-repo-link="{{.RepoLink}}"></div> | |||
| <h4 class="ui top attached header"> | |||
| @@ -300,7 +302,7 @@ | |||
| <!-- 表单操作 --> | |||
| <div class="inline min_title field"> | |||
| <label class="label-fix-width" style="font-weight: normal;"></label> | |||
| <button class="ui create_train_job green button"> | |||
| <button class="ui create_train_job green button {{if eq .NotStopTaskCount 1}}disabled{{end}}"> | |||
| {{.i18n.Tr "repo.cloudbrain.new"}} | |||
| </button> | |||
| <a class="ui button" href="/">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a> | |||
| @@ -11,11 +11,12 @@ | |||
| <div class="repository new repo ui middle very relaxed page grid"> | |||
| <div class="column"> | |||
| <div class="cloudbrain-type" style="display: none;" data-cloudbrain-type="{{.datasetType}}" data-repo-link="{{.RepoLink}}"></div> | |||
| {{template "base/alert" .}} | |||
| <div class="ui negative message" id="messageInfo"> | |||
| {{if eq .NotStopTaskCount 0}} | |||
| {{template "base/alert" .}} | |||
| {{end}} | |||
| <div class="ui negative message" id="messageInfo" style="display: none;"> | |||
| <p></p> | |||
| </div> | |||
| {{template "custom/alert_cb" .}} | |||
| <form class="ui form" id="form_id" action="{{.Link}}" method="post"> | |||
| {{.CsrfTokenHtml}} | |||
| @@ -106,7 +107,7 @@ | |||
| </div> | |||
| <div class="inline field"> | |||
| <label></label> | |||
| <button class="ui green button"> | |||
| <button class="ui green button {{if eq .NotStopTaskCount 1}}disabled{{end}}"> | |||
| {{.i18n.Tr "repo.cloudbrain.new"}} | |||
| </button> | |||
| <a class="ui button cancel" href="{{.RepoLink}}/debugjob?debugListType=all">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a> | |||
| @@ -63,7 +63,9 @@ | |||
| {{template "repo/header" .}} | |||
| <div class="ui container"> | |||
| <div class="cloudbrain-type" style="display: none;" data-cloudbrain-type="{{.datasetType}}" data-repo-link="{{.RepoLink}}" data-flag-model="true" data-dataset-uuid="{{.attachment}}" data-dataset-name="{{.dataset_name}}"></div> | |||
| {{template "base/alert" .}} | |||
| {{if eq .NotStopTaskCount 0}} | |||
| {{template "base/alert" .}} | |||
| {{end}} | |||
| {{template "custom/alert_cb" .}} | |||
| <h4 class="ui top attached header"> | |||
| {{.i18n.Tr "repo.modelarts.train_job.new"}} | |||
| @@ -291,7 +293,7 @@ | |||
| <div class="inline field" style="padding: 1rem 0;"> | |||
| <label class="label-fix-width"></label> | |||
| <button class="ui create_train_job green button"> | |||
| <button class="ui create_train_job green button {{if eq .NotStopTaskCount 1}}disabled{{end}}"> | |||
| {{.i18n.Tr "repo.cloudbrain.new"}} | |||
| </button> | |||
| <a class="ui button" href="{{.RepoLink}}/modelarts/train-job">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a> | |||
| @@ -565,4 +565,5 @@ | |||
| $("#choice_Engine").removeClass('disabled'); | |||
| } | |||
| } | |||
| </script> | |||
| @@ -285,7 +285,7 @@ function transObj(data){ | |||
| DatasetName:TrainTaskInfo.DatasetName || '--', | |||
| Parameters:TrainTaskInfo.Parameters || '--', | |||
| FlavorName:TrainTaskInfo.FlavorName || '--', | |||
| WorkServerNumber:TrainTaskInfo.WorkServerNumber || '--', | |||
| WorkServerNumber:TrainTaskInfo.WorkServerNumber || '1', | |||
| Parameters:Parameters, | |||
| EngineName:EngineName, | |||
| DisplayJobName:TrainTaskInfo.DisplayJobName || '--', | |||
| @@ -55,7 +55,9 @@ | |||
| <div class="ui container"> | |||
| {{$Grampus := (or (eq (index (SubJumpablePath .Link) 1) "create_grampus_gpu") (eq (index (SubJumpablePath .Link) 1) "create_grampus_npu"))}} | |||
| <div class="cloudbrain-type" style="display: none;" data-grampus="{{$Grampus}}" data-cloudbrain-type="{{.datasetType}}" data-repo-link="{{.RepoLink}}" data-flag-model="true" data-dataset-uuid="{{.attachment}}" data-dataset-name="{{.dataset_name}}" data-queue="{{.QueuesDetail}}" data-queue-start="{{.i18n.Tr "repo.wait_count_start"}}" data-queue-end="{{.i18n.Tr "repo.wait_count_end"}}"></div> | |||
| {{template "base/alert" .}} | |||
| {{if eq .NotStopTaskCount 0}} | |||
| {{template "base/alert" .}} | |||
| {{end}} | |||
| {{template "custom/alert_cb" .}} | |||
| <h4 class="ui top attached header"> | |||
| {{.i18n.Tr "repo.modelarts.evaluate_job.new_job"}} | |||
| @@ -314,7 +316,7 @@ | |||
| </div> | |||
| <div class="inline unite min_title field"> | |||
| <label class="label-fix-width" style="font-weight: normal;"></label> | |||
| <button class="ui create_train_job green button"> | |||
| <button class="ui create_train_job green button {{if eq .NotStopTaskCount 1}}disabled{{end}}"> | |||
| {{.i18n.Tr "repo.cloudbrain.new"}} | |||
| </button> | |||
| <a class="ui button" href="{{.RepoLink}}/cloudbrain/benchmark">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a> | |||
| @@ -65,7 +65,7 @@ | |||
| <td> | |||
| ${el.dockerDir} | |||
| </td> | |||
| <td><a> ${el.example_repo}</a></td> | |||
| <td><a href="${el.example_repo}">${el.example_repo}</a></td> | |||
| <td>${el.note}</td></tr>`; | |||
| }); | |||
| html2 = html2.replace( | |||
| @@ -21,7 +21,7 @@ | |||
| <div class="badge-wrap"> | |||
| {{range $k,$v :=.RecentBadges}} | |||
| {{if le $k 3}} | |||
| <div class="badge-img-avatar" title="{{.Name}}"><img style="width: 100%;height: 100%;" src="{{.LightedIcon}}" class="ui poping up" data-content="{{.Name}}" data-position="top center" data-variation="tiny inverted"></div> | |||
| <div class="badge-img-avatar"><img style="width: 100%;height: 100%;" src="{{.LightedIcon}}" class="ui poping up" data-content="{{.Name}}" data-position="top center" data-variation="tiny inverted"></div> | |||
| {{else}} | |||
| <a class="badge-more-icon" href="{{$.Owner.HomeLink}}?tab=badge"><i class="ri-more-fill"></i></a> | |||
| {{end}} | |||
| @@ -55,7 +55,7 @@ | |||
| if (!this.dom) return; | |||
| var self = this; | |||
| var clientX = 0, oLeft = 0, imgHideTimer = null; | |||
| this.dom.find('.slide-bar-bg').on('mouseenter', function (e) { | |||
| this.dom.find('.slide-bar-bg').on('mouseenter touchstart', function (e) { | |||
| if (self.verifySucess) return; | |||
| imgHideTimer && clearTimeout(imgHideTimer); | |||
| self.dom.find('.slide-image-big').slideDown(); | |||
| @@ -233,14 +233,4 @@ | |||
| -webkit-line-clamp: 2; | |||
| -webkit-box-orient: vertical; | |||
| } | |||
| .badge-section-title:before { | |||
| content: ""; | |||
| position: absolute; | |||
| top: 50%; | |||
| left: 0; | |||
| transform: translateY(-50%); | |||
| width: 3px; | |||
| height: 1em; | |||
| background-color: #000; | |||
| } | |||
| } | |||