|
|
|
@@ -98,15 +98,15 @@ func cutString(str string, lens int) string { |
|
|
|
func jobNamePrefixValid(s string) string { |
|
|
|
lowStr := strings.ToLower(s) |
|
|
|
re := regexp.MustCompile(`[^a-z0-9_\\-]+`) |
|
|
|
|
|
|
|
|
|
|
|
removeSpecial := re.ReplaceAllString(lowStr, "") |
|
|
|
|
|
|
|
|
|
|
|
re = regexp.MustCompile(`^[_\\-]+`) |
|
|
|
return re.ReplaceAllString(removeSpecial, "") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func cloudBrainNewDataPrepare(ctx *context.Context) error{ |
|
|
|
func cloudBrainNewDataPrepare(ctx *context.Context) error { |
|
|
|
ctx.Data["PageIsCloudBrain"] = true |
|
|
|
t := time.Now() |
|
|
|
var jobName = jobNamePrefixValid(cutString(ctx.User.Name, 5)) + t.Format("2006010215") + strconv.Itoa(int(t.Unix()))[5:] |
|
|
|
@@ -556,6 +556,21 @@ func CloudBrainDownloadModel(ctx *context.Context) { |
|
|
|
http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) |
|
|
|
} |
|
|
|
|
|
|
|
func TrainJobloadModel(ctx *context.Context) { |
|
|
|
parentDir := ctx.Query("parentDir") |
|
|
|
fileName := ctx.Query("fileName") |
|
|
|
jobName := ctx.Query("jobName") |
|
|
|
filePath := "jobs/" + jobName + "/model/" + parentDir |
|
|
|
url, err := storage.Attachments.PresignedGetURL(filePath, fileName) |
|
|
|
if err != nil { |
|
|
|
log.Error("PresignedGetURL failed: %v", err.Error(), ctx.Data["msgID"]) |
|
|
|
ctx.ServerError("PresignedGetURL", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) |
|
|
|
} |
|
|
|
|
|
|
|
func GetRate(ctx *context.Context) { |
|
|
|
var jobID = ctx.Params(":jobid") |
|
|
|
job, err := models.GetCloudbrainByJobID(jobID) |
|
|
|
@@ -579,9 +594,9 @@ func downloadCode(repo *models.Repository, codePath string) error { |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
configFile, err := os.OpenFile(codePath + "/.git/config", os.O_RDWR, 0666) |
|
|
|
configFile, err := os.OpenFile(codePath+"/.git/config", os.O_RDWR, 0666) |
|
|
|
if err != nil { |
|
|
|
log.Error("open file(%s) failed:%v", codePath + "/,git/config", err) |
|
|
|
log.Error("open file(%s) failed:%v", codePath+"/,git/config", err) |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
@@ -601,10 +616,10 @@ func downloadCode(repo *models.Repository, codePath string) error { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if strings.Contains(line, "url") && strings.Contains(line, ".git"){ |
|
|
|
if strings.Contains(line, "url") && strings.Contains(line, ".git") { |
|
|
|
originUrl := "\turl = " + repo.CloneLink().HTTPS + "\n" |
|
|
|
if len(line) > len(originUrl) { |
|
|
|
originUrl += strings.Repeat( " ", len(line) - len(originUrl)) |
|
|
|
originUrl += strings.Repeat(" ", len(line)-len(originUrl)) |
|
|
|
} |
|
|
|
bytes := []byte(originUrl) |
|
|
|
_, err := configFile.WriteAt(bytes, pos) |
|
|
|
|