-
Notifications
You must be signed in to change notification settings - Fork 441
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refine API Signed-off-by: YujiOshima <yuji.oshima0x3fd@gmail.com> * add cli Signed-off-by: YujiOshima <yuji.oshima0x3fd@gmail.com> * add gird demo Signed-off-by: YujiOshima <yuji.oshima0x3fd@gmail.com> * fix Signed-off-by: YujiOshima <yuji.oshima0x3fd@gmail.com> * add GKEDemo Signed-off-by: YujiOshima <yuji.oshima0x3fd@gmail.com> * fix test Signed-off-by: YujiOshima <yuji.oshima0x3fd@gmail.com> * add mnist-models.yaml Signed-off-by: YujiOshima <yuji.oshima0x3fd@gmail.com> * fix docs Signed-off-by: YujiOshima <yuji.oshima0x3fd@gmail.com> * improve GKEdemo docs Signed-off-by: YujiOshima <yuji.oshima0x3fd@gmail.com> * add more docs Signed-off-by: YujiOshima <yuji.oshima0x3fd@gmail.com> * fix test Signed-off-by: YujiOshima <yuji.oshima0x3fd@gmail.com> * enable get worker from trialid ana add getParameterList from studyid Signed-off-by: YujiOshima <yuji.oshima0x3fd@gmail.com> * fix doc Signed-off-by: YujiOshima <yuji.oshima0x3fd@gmail.com> * fix test Signed-off-by: YujiOshima <yuji.oshima0x3fd@gmail.com> * fix Signed-off-by: YujiOshima <yuji.oshima0x3fd@gmail.com>
- Loading branch information
1 parent
06d6ea5
commit 0a95175
Showing
125 changed files
with
6,499 additions
and
7,578 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"io/ioutil" | ||
"log" | ||
"os" | ||
"strings" | ||
"unicode/utf8" | ||
|
||
"github.com/kubeflow/katib/pkg/api" | ||
"github.com/spf13/cobra" | ||
"google.golang.org/grpc" | ||
yaml "gopkg.in/yaml.v2" | ||
) | ||
|
||
type pullStudyOpt struct { | ||
outfile string | ||
args []string | ||
} | ||
|
||
//NewCommandPullStudy generate pull studies cmd | ||
func NewCommandPullStudy() *cobra.Command { | ||
var opt pullStudyOpt | ||
cmd := &cobra.Command{ | ||
Use: "studies", | ||
Args: cobra.ExactArgs(1), | ||
Short: "Export a Study and its Models lnfo", | ||
Long: `Export Information of a Study and its Models to yaml format`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
opt.args = args | ||
pullStudy(cmd, &opt) | ||
}, | ||
Aliases: []string{"st"}, | ||
} | ||
cmd.Flags().StringVarP(&opt.outfile, "output", "o", "", "File path to export") | ||
return cmd | ||
} | ||
|
||
func pullStudy(cmd *cobra.Command, opt *pullStudyOpt) { | ||
//check and get persistent flag volume | ||
var pf *PersistentFlags | ||
pf, err := CheckPersistentFlags() | ||
if err != nil { | ||
log.Fatalf("Fail to Check Flags: %v", err) | ||
} | ||
conn, err := grpc.Dial(pf.server, grpc.WithInsecure()) | ||
if err != nil { | ||
log.Fatalf("could not connect: %v", err) | ||
} | ||
defer conn.Close() | ||
|
||
c := api.NewManagerClient(conn) | ||
listreq := &api.GetStudyListRequest{} | ||
listr, err := c.GetStudyList(context.Background(), listreq) | ||
if err != nil { | ||
log.Fatalf("GetStudy failed: %v", err) | ||
return | ||
} | ||
studyId := "" | ||
// Search study by Study ID or name | ||
for _, si := range listr.StudyOverviews { | ||
if utf8.RuneCountInString(opt.args[0]) >= 7 { | ||
if strings.HasPrefix(si.Id, opt.args[0]) { | ||
studyId = si.Id | ||
break | ||
} | ||
} | ||
if si.Name == opt.args[0] { | ||
studyId = si.Id | ||
break | ||
} | ||
} | ||
if studyId == "" { | ||
log.Fatalf("Study %s is not found", opt.args[0]) | ||
} | ||
req := &api.GetStudyRequest{ | ||
StudyId: studyId, | ||
} | ||
r, err := c.GetStudy(context.Background(), req) | ||
if err != nil { | ||
log.Fatalf("GetStudy failed: %v", err) | ||
} | ||
mreq := &api.GetSavedModelsRequest{ | ||
StudyName: r.StudyConfig.Name, | ||
} | ||
mr, err := c.GetSavedModels(context.Background(), mreq) | ||
if err != nil { | ||
log.Fatalf("GetModel failed: %v", err) | ||
} | ||
sd := StudyData{ | ||
StudyConf: r.StudyConfig, | ||
Models: mr.Models, | ||
} | ||
yst, err := yaml.Marshal(sd) | ||
if err != nil { | ||
log.Fatalf("Failed to Marshal: %v", err) | ||
} | ||
if opt.outfile != "" { | ||
ioutil.WriteFile(opt.outfile, yst, os.ModePerm) | ||
} else { | ||
fmt.Println(string(yst)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
//NewCommandPull generate run cmd | ||
func NewCommandPull() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "pull", | ||
Short: "Pull a resource from a file or from stdin.", | ||
Long: `YAML or JSON formats are accepted.`, | ||
} | ||
|
||
cmd.AddCommand(NewCommandPullStudy()) | ||
// cmd.AddCommand(NewCommandPullModel()) | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.