Browse Source

提交模型管理代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.21.12.1^2
zouap 3 years ago
parent
commit
5e45cef686
6 changed files with 3 additions and 126 deletions
  1. +0
    -19
      modules/storage/obs.go
  2. +0
    -35
      routers/home.go
  3. +0
    -5
      routers/repo/http.go
  4. +0
    -2
      routers/routes/routes.go
  5. +0
    -59
      templates/repo/modelmanage/download.tmpl
  6. +3
    -6
      templates/repo/view_list.tmpl

+ 0
- 19
modules/storage/obs.go View File

@@ -484,26 +484,7 @@ func GetObsCreateSignedUrlByBucketAndKey(bucket, key string) (string, error) {
}

func GetObsCreateSignedUrl(jobName, parentDir, fileName string) (string, error) {
// input := &obs.CreateSignedUrlInput{}
// input.Bucket = setting.Bucket
// input.Key = strings.TrimPrefix(path.Join(setting.TrainJobModelPath, jobName, setting.OutPutPath, parentDir, fileName), "/")

return GetObsCreateSignedUrlByBucketAndKey(setting.Bucket, strings.TrimPrefix(path.Join(setting.TrainJobModelPath, jobName, setting.OutPutPath, parentDir, fileName), "/"))

// input.Expires = 60 * 60
// input.Method = obs.HttpMethodGet

// reqParams := make(map[string]string)
// reqParams["response-content-disposition"] = "attachment; filename=\"" + fileName + "\""
// input.QueryParams = reqParams
// output, err := ObsCli.CreateSignedUrl(input)
// if err != nil {
// log.Error("CreateSignedUrl failed:", err.Error())
// return "", err
// }

// return output.SignedUrl, nil

}

func ObsGetPreSignedUrl(uuid, fileName string) (string, error) {


+ 0
- 35
routers/home.go View File

@@ -7,8 +7,6 @@ package routers

import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"strings"

@@ -513,36 +511,3 @@ func NotFound(ctx *context.Context) {
ctx.Data["Title"] = "Page Not Found"
ctx.NotFound("home.NotFound", nil)
}

func RecommendOrgFromPromote(ctx *context.Context) {
url := setting.RecommentRepoAddr + "organizations"
recommendFromPromote(ctx, url)
}

func recommendFromPromote(ctx *context.Context, url string) {
resp, err := http.Get(url)
if err != nil {
log.Info("Get organizations url error=" + err.Error())
ctx.ServerError("QueryTrainJobList:", err)
return
}
bytes, err := ioutil.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
log.Info("Get organizations url error=" + err.Error())
ctx.ServerError("QueryTrainJobList:", err)
return
}

allLineStr := string(bytes)
lines := strings.Split(allLineStr, "\n")
for i, line := range lines {
log.Info("i=" + fmt.Sprint(i) + " line=" + line)
}
ctx.JSON(http.StatusOK, lines)
}

func RecommendRepoFromPromote(ctx *context.Context) {
url := setting.RecommentRepoAddr + "projects"
recommendFromPromote(ctx, url)
}

+ 0
- 5
routers/repo/http.go View File

@@ -9,7 +9,6 @@ import (
"bytes"
"compress/gzip"
gocontext "context"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
@@ -258,7 +257,6 @@ func HTTP(ctx *context.Context) {
models.EnvPusherID + fmt.Sprintf("=%d", authUser.ID),
models.EnvIsDeployKey + "=false",
}
log.Info("username=" + username + ", EnvPusherName=" + authUser.Name + " EnvRepoName=" + reponame)
if !authUser.KeepEmailPrivate {
environ = append(environ, models.EnvPusherEmail+"="+authUser.Email)
}
@@ -561,9 +559,6 @@ func serviceRPC(h serviceHandler, service string) {
cmd.Env = append(os.Environ(), h.environ...)
}

envJson, _ := json.Marshal(cmd.Env)
//log.Info(accuracyJson=” + string(accuracyJson))
log.Info("env=" + string(envJson))
cmd.Stdout = h.w
cmd.Stdin = reqBody
cmd.Stderr = &stderr


+ 0
- 2
routers/routes/routes.go View File

@@ -315,8 +315,6 @@ func RegisterRoutes(m *macaron.Macaron) {
})
m.Get("/", routers.Home)
m.Get("/dashboard", routers.Dashboard)
m.Get("/recommend/org", routers.RecommendOrgFromPromote)
m.Get("/recommend/repo", routers.RecommendRepoFromPromote)
m.Group("/explore", func() {
m.Get("", func(ctx *context.Context) {
ctx.Redirect(setting.AppSubURL + "/explore/repos")


+ 0
- 59
templates/repo/modelmanage/download.tmpl View File

@@ -1,59 +0,0 @@
{{template "base/head" .}}
<div class="repository dataset dir-list view">
{{template "repo/header" .}}
<form class="ui container">
<div class="ui stackable grid {{if .Error}}hide{{end}}" id="dir-content">
<div class="row">
<div class="column sixteen wide">
<p>
{{ range $index, $item := .Path }}<a href='{{$.Link}}/?parentDir={{if gt $index 0}}{{DatasetPathJoin $.Path $index "/"}}{{else}}{{end}}'>{{ $item }}</a><span class="directory-seperator">/</span>{{ end }}
</p>
</div>
</div>
</div>

<div class="ui grid">
<div class="row">
<div class="ui sixteen wide column">
<div class="dir list">
<a class="title" href="{{$.RepoLink}}/modelmanage/downloadall?ID={{.ID}}">
下载所有
</a>
{{if .Dirs}}
<table id="repo-files-table" class="ui single line table">
<tbody>
{{range .Dirs}}
<tr>
<td class="name four wide">
<span class="truncate">
<span class="octicon octicon-file-directory"></span>
<a class="title" href="{{if .IsDir}}{{$.RepoLink}}/modelmanage/{{$.ID}}?parentDir={{.ParenDir}}{{else}}{{$.RepoLink}}/modelmanage/{{$.ID}}/downloadsingle?parentDir={{.ParenDir}}&fileName={{.FileName}}{{end}}">
<span class="fitted">{{if .IsDir}} {{svg "octicon-file-directory" 16}}{{else}}{{svg "octicon-file" 16}}{{end}}</span> {{.FileName}}
</a>
</span>
</td>
<td class="message nine wide">
<span class="truncate has-emoji">
{{.Size | FileSize}}
</span>
</td>
<td class="text right age three wide">
<span class="time-since poping up">{{.ModTime}}</span>
</td>
</tr>
{{end}}
</tbody>
</table>

{{end}}

</div>
</div>
</div>
</div>
</form>
</div>



{{template "base/footer" .}}

+ 3
- 6
templates/repo/view_list.tmpl View File

@@ -5,17 +5,14 @@
{{if .LatestCommitUser}}
<img class="ui avatar image img-12" src="{{.LatestCommitUser.RelAvatarLink}}" />
{{if .LatestCommitUser.FullName}}
<a id="1" href="{{AppSubUrl}}/{{.LatestCommitUser.Name}}"><strong>{{.LatestCommitUser.FullName}}</strong></a>
<strong id="6">{{.LatestCommit.Committer.Name}}</strong>
<a href="{{AppSubUrl}}/{{.LatestCommitUser.Name}}"><strong>{{.LatestCommitUser.FullName}}</strong></a>
{{else}}
<a id="2" href="{{AppSubUrl}}/{{.LatestCommitUser.Name}}"><strong>{{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}}</strong></a>
<strong id="6">{{.LatestCommit.Committer.Name}}</strong>
<a href="{{AppSubUrl}}/{{.LatestCommitUser.Name}}"><strong>{{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}}</strong></a>
{{end}}
{{else}}
{{if .LatestCommit.Author}}
<img class="ui avatar image img-12" src="{{AvatarLink .LatestCommit.Author.Email}}" />
<strong id="3">{{.LatestCommit.Author.Name}}</strong>
<strong id="4">{{.LatestCommit.Committer.Name}}</strong>
<strong>{{.LatestCommit.Author.Name}}</strong>
{{end}}
{{end}}
<a rel="nofollow" class="ui sha label {{if .LatestCommit.Signature}} isSigned {{if .LatestCommitVerification.Verified }} isVerified{{if eq .LatestCommitVerification.TrustStatus "trusted"}}{{else if eq .LatestCommitVerification.TrustStatus "untrusted"}}Untrusted{{else}}Unmatched{{end}}{{else if .LatestCommitVerification.Warning}} isWarning{{end}}{{end}}" href="{{.RepoLink}}/commit/{{.LatestCommit.ID}}">


Loading…
Cancel
Save