Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d1a9ef8
feat(di-trainer/di-jobmonitor/di-lcm/di-cli):
renzhe-li Apr 6, 2022
7ef0b56
feat(appconns/dss-mlflow-appconn): Add MLFlow Appconn
James23Wang Apr 6, 2022
5898faf
"feat(appconns/dss-mlss-appconn): Add MLSS Appconn
hexudong111 Apr 6, 2022
cc5aa2a
feat(mf): Add Model Factory Module
bleachzk Apr 6, 2022
4ebbe3d
feat(isntall): Update install file
alexzyWu Apr 6, 2022
3e9746c
feat(isntall): Update install file
alexzyWu Apr 6, 2022
bd8b620
Merge pull request #46 from alexzyWu/master
alexzyWu Apr 6, 2022
c0b7652
docs(docs): Update docs module
alexzyWu Apr 6, 2022
444d2ce
feat(mllabis): Add resource modification and release
alexzyWu Apr 6, 2022
d691742
1.add
uuarttt Apr 6, 2022
e07d105
Merge pull request #48 from hanwutian/master
alexzyWu Apr 6, 2022
33b87f6
Merge pull request #47 from alexzyWu/mllabis-resource-control-feature
alexzyWu Apr 6, 2022
268f286
Merge pull request #45 from bleachzk/master
alexzyWu Apr 6, 2022
3119e8c
Merge pull request #44 from hexudong111/master
alexzyWu Apr 6, 2022
d42fd7e
Merge pull request #42 from James23Wang/dev
alexzyWu Apr 6, 2022
d0f5db6
Merge pull request #43 from renzhe-li/dev
alexzyWu Apr 6, 2022
f8ef67e
Merge branch 'WeBankFinTech:dev-0.3.0' into dev-0.3.0
alexzyWu Apr 7, 2022
a218e8c
fix(mllabis): Remove parameter limit in notebook creation
alexzyWu Apr 7, 2022
191b003
Merge pull request #50 from alexzyWu/mllabis-parameter-limit
alexzyWu Apr 7, 2022
f61b3e8
fix(ui): update ui
alexzyWu Apr 7, 2022
9263079
fix(ui): Remove output in UI
alexzyWu Apr 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions di/cli/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ var (
authType string
username string
password string
appid string
appts string
appToken string
)

const (
//watsonUserInfoHeader = "X-Watson-Userinfo"
CcAuthType = "MLSS-Auth-Type"
CcAuthSSOTicket = "MLSS-Ticket"
CcAuthUser = "MLSS-UserID"
Expand Down Expand Up @@ -111,6 +115,9 @@ func NewDlaaSClient() (*dlaasClient.Dlaas, error) {
authType = os.Getenv("MLSS_AUTH_TYPE")
username = os.Getenv("MLSS_AUTH_USER")
password = os.Getenv("MLSS_AUTH_PASSWD")
appid = os.Getenv("MLSS_APPID")
appts = os.Getenv("MLSS_APPTimestamp")
appToken = os.Getenv("MLSS_APPSignature")
_authType = authType
_username = username
_password = password
Expand All @@ -123,7 +130,6 @@ func NewDlaaSClient() (*dlaasClient.Dlaas, error) {
lflog().Debugf("basicAuth: %+v", BasicAuth)

transport := client.New(u.Host, u.Path, schemes)
// FIXME this should not be there and a bug in go-swagger - without this the zip download fails

transport.Transport = createRoundTripper()
return dlaasClient.New(transport, strfmt.Default), nil
Expand Down Expand Up @@ -180,6 +186,7 @@ type roundTripper struct {

func (r *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
// we set the dummy header if it is not set so we can use the CLI internally too (without going through Datapower)
//lflog().Debugf("X-Watson-Userinfo: %s", req.Header.Get(watsonUserInfoHeader))
if req.Header.Get(CcAuthType) == "" {
lflog().Debugf("Adding %s: %s", CcAuthType, authType)
req.Header.Add(CcAuthType, authType)
Expand All @@ -191,6 +198,9 @@ func (r *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
if req.Header.Get(CcAuthPWD) == "" {
req.Header.Add(CcAuthPWD, password)
}
req.Header.Add(CcAuthAppID, appid)
req.Header.Add(CcAuthAppTS, appts)
req.Header.Add(CcAuthAppToken, appToken)
return http.DefaultTransport.RoundTrip(req)
}

Expand Down Expand Up @@ -222,7 +232,6 @@ func LocationToID(location string) string {

// IsValidManifest returns true if the data is a valid manifest file.
func IsValidManifest(manifest []byte) bool {
// TODO fix this - we should not pull the whole dlaas-platform-apis just for this.
return true
}

Expand Down
173 changes: 173 additions & 0 deletions di/cli/cmd/emetrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/*
* Copyright 2017-2018 IBM Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package cmd

import (
//"encoding/json"
//"fmt"
"github.com/IBM-Bluemix/bluemix-cli-sdk/bluemix/terminal"
"github.com/IBM-Bluemix/bluemix-cli-sdk/plugin"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
//"time"
//dlaasClient "webank/DI/restapi/api_v1/client"
//"webank/DI/restapi/api_v1/client/training_data"
)

// EmetricsCmd represents the instance of this command
type EmetricsCmd struct {
ui terminal.UI
config plugin.PluginConfig
context plugin.PluginContext
}

// NewEmetricsCmd creates a new instance of this command
func NewEmetricsCmd(ui terminal.UI, context plugin.PluginContext) *EmetricsCmd {
return &EmetricsCmd{
ui: ui,
context: context,
}
}

//func printEMetrics(cmd *EmetricsCmd, tdc *dlaasClient.Dlaas, params *training_data.GetEMetricsParams, isJSON bool) (int64, int, error) {
// emetrics, err := tdc.TrainingData.GetEMetrics(params, BasicAuth())
// if err != nil {
// cmd.ui.Failed("Could not read emetrics: %s", err.Error())
// return 0, 0, err
// }
//
// var lastTimestamp int64
// for _, metrics := range emetrics.Payload.Models {
// lastTimestamp = metrics.Meta.Time
// if isJSON {
// jsonBytes, err := json.Marshal(metrics)
// if err != nil {
// cmd.ui.Failed("Could not marshal record to json: %s", err.Error())
// return 0, 0, err
// }
// fmt.Printf("%s\n", string(jsonBytes))
// } else {
// fmt.Printf("time: %d, group-label: %s, training-id: %s\n",
// metrics.Meta.Time, metrics.Grouplabel, metrics.Meta.TrainingID)
//
// //var etimes map[string]*trainingDataClient.Any
// etimes := metrics.Etimes
// fmt.Printf(" etimes: ")
// for k, v := range etimes {
// fmt.Printf("%s: %s, ", k, v)
// }
// fmt.Printf("\n")
//
// fmt.Printf(" values: ")
// //var values map[string]*trainingDataClient.Any
// values := metrics.Values
//
// for k, v := range values {
// fmt.Printf("%s: %s, ", k, v)
// }
// fmt.Printf("\n")
// }
// }
// return lastTimestamp, len(emetrics.Payload.Models), nil
//}

// Run is the handler for the emetrics CLI command.
func (cmd *EmetricsCmd) Run(cliContext *cli.Context) error {
log.SetLevel(log.WarnLevel)
cmd.config = cmd.context.PluginConfig()

args := cliContext.Args()

if len(args) == 0 {
cmd.ui.Failed("Incorrect arguments")
return nil
}
//trainingID := args[0]

//isFollow := cliContext.IsSet("follow")
//isJSON := cliContext.IsSet("json")
//

pagesize := int32(cliContext.Int("pagesize"))
if pagesize == 0 {
pagesize = defaultLogsPageSize
}

//pos := int64(cliContext.Int("pos"))

since := cliContext.String("since")
log.Debugf("since: %s", since)

//tdc, err := NewDlaaSClient()
_, err := NewDlaaSClient()
if err != nil {
cmd.ui.Failed(err.Error())
return nil
}
//
//params := training_data.NewGetEMetricsParamsWithTimeout(defaultOpTimeout)
//
//params.ModelID = trainingID
//
//params.Pagesize = &pagesize
//params.Pos = &pos
//params.SinceTime = &since
//searchType := "TERM"
//params.SearchType = &searchType

//lastTimestamp, nPrinted, err := printEMetrics(cmd, tdc, params, isJSON)
if err != nil {
cmd.ui.Failed("Could not read emetrics: %s", err.Error())
return nil
}
//totalPrinted := int32(nPrinted)
//for totalPrinted < pagesize {
// sinceTimeQuery := fmt.Sprintf("%v", lastTimestamp+1)
// params.SinceTime = &sinceTimeQuery
// log.Debugf("requesting emetrics past %s", sinceTimeQuery)
//
// lastTimestamp, nPrinted, err = printEMetrics(cmd, tdc, params, isJSON)
//
// if err != nil {
// cmd.ui.Failed("Could not read emetrics: %s", err.Error())
// return nil
// }
// if nPrinted == 0 {
// break
// }
// totalPrinted += int32(nPrinted)
//}
//
//if isFollow {
// time.Sleep(defaultLogsFollowSleep)
//
// for {
// sinceTimeQuery := fmt.Sprintf("%v", lastTimestamp+1)
// params.SinceTime = &sinceTimeQuery
// log.Debugf("requesting emetrics past %s (follow)", sinceTimeQuery)
//
// lastTimestamp, _, err = printEMetrics(cmd, tdc, params, isJSON)
//
// if err != nil {
// cmd.ui.Failed("Could not read emetrics: %s", err.Error())
// return nil
// }
// }
//}

return nil
}
36 changes: 36 additions & 0 deletions di/cli/cmd/emetrics_completion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2017-2018 IBM Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package cmd

import (
"fmt"
"github.com/urfave/cli"
)

// EMetricsCompletion provide bash auto completion options
func EMetricsCompletion(c *cli.Context) {
args := c.NArg()
flags := c.NumFlags()

if args == 0 {
ModelIDCompletion(c)
}

if flags == 0 {
fmt.Println("--follow")
}
}
13 changes: 8 additions & 5 deletions di/cli/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ func (cmd *ListCmd) Run(cliContext *cli.Context) error {
params := models.NewListModelsParams().WithTimeout(defaultOpTimeout)
params.Userid = &userid
params.Namespace = &namespace
params.Page = &page
params.Size = &size

if page != "" {
params.Page = &page
}
if size != "" {
params.Size = &size
}
modelz, err := c.Models.ListModels(params, BasicAuth())

if err != nil {
lflog().WithError(err).Debugf("ListModels failed")
var s string
Expand All @@ -84,7 +86,8 @@ func (cmd *ListCmd) Run(cliContext *cli.Context) error {
table.Add(v.ModelID, v.Name, v.Framework.Name+":"+v.Framework.Version, ts.Status, formatTimestamp(ts.Submitted), formatTimestamp(ts.Completed))
}
table.Print()
cmd.ui.Say("\n%d records found.", len(modelz.Payload.Models))
cmd.ui.Say("\n%d records found, current page: %v, page size: %v, total page: %d, total records: %d",
len(modelz.Payload.Models), *params.Page, *params.Size, modelz.Payload.Pages, modelz.Payload.Total)
return nil
}

Expand Down
38 changes: 36 additions & 2 deletions di/cli/cmd/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,22 @@ func (cmd *LogsCmd) Run(cliContext *cli.Context) error {
} else {
wsprotocol = "ws"
}

//var authStr string
//if u.User != nil {
// password, _ := u.User.Password()
// basicAuth = client.BasicAuth(u.User.Username(), password)
// authStr = base64.StdEncoding.EncodeToString([]byte(u.User.Username() + ":" + password))
//} else {
// username := os.Getenv("DLAAS_USERNAME")
// password := os.Getenv("DLAAS_PASSWORD")
// if username == "" || password == "" {
// return errors.New("Username and password not set")
// }
// basicAuth = client.BasicAuth(username, password)
// authStr = base64.StdEncoding.EncodeToString([]byte(username + ":" + password))
//}

var logsOrMetrics string
if isMetrics {
logsOrMetrics = "metrics"
Expand All @@ -141,14 +157,28 @@ func (cmd *LogsCmd) Run(cliContext *cli.Context) error {
var fullpath = fmt.Sprintf("%s/v1/models/%s/%s", u.Path, trainingID, logsOrMetrics)
trainingLogURL := url.URL{Scheme: wsprotocol, Host: streamHost, Path: fullpath, RawQuery: "version=2017-03-17&mlss-token-for-logs=dc4e9956-594c-48f4-af3d-36f2fff1a428&mlss-userid=hduser05"}

//headers := make(http.Header, 2)
//// FIXME MLSS Change: remove watson header
////headers.Set(watsonUserInfoHeader, watsonUserInfo)
//headers.Set("Authorization", "Basic "+authStr)

//FIXME wtss
headers := http.Header{
"Accept-Encoding": []string{"gzip, deflate"},
"Cache-Control": []string{"no-cache"},
//"MLSS-Token": []string{"dc4e9956-594c-48f4-af3d-36f2fff1a428"},
"MLSS-UserID": []string{username},
"MLSS-Passwd": []string{password},
"MLSS-Auth-Type": []string{authType},
"Authorization": []string{"Basic dGVkOndlbGNvbWUx"},
//"X-Watson-Userinfo": []string{"bluemix-instance-id=test-user"},

//"Upgrade": []string{"websocket"}
//"Connection": []string{"Upgrade"},
//"Sec-WebSocket-Key": []string{challengeKey},
//"Sec-WebSocket-Version": []string{"13"},
//"Host": []string{host},
//"Origin": []string{dlaasURL},
}

log.Debugf("call: websocket.Dial: %s\n", trainingLogURL.String())
Expand Down Expand Up @@ -212,7 +242,10 @@ func (cmd *LogsCmd) Run(cliContext *cli.Context) error {
}
fmt.Printf("\n")
}

// fmt.Printf("%+v\n", metricsRecords)
}

} else {
fmt.Printf("line: %v: %s\n", line, msg[:nread])
line++
Expand All @@ -222,8 +255,7 @@ func (cmd *LogsCmd) Run(cliContext *cli.Context) error {

} else {
if isMetrics {
params :=
models.NewGetMetricsParams().WithModelID(trainingID).WithTimeout(10 * time.Hour)
params := models.NewGetMetricsParams().WithModelID(trainingID).WithTimeout(10 * time.Hour)
log.Debugf("debug training-logs: doing http")
r, w := io.Pipe()

Expand Down Expand Up @@ -261,6 +293,8 @@ func (cmd *LogsCmd) Run(cliContext *cli.Context) error {
}
}
}
//cmd.ui.Ok() // don't print OK after as we do with other commands, as it may be interpreted as part
// of the logs
}
return nil
}
2 changes: 1 addition & 1 deletion di/cli/cmd/model_id_completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func ModelIDCompletion(c *cli.Context) {
return
}

params := models.NewListModelsParams().
params := models.NewListModelsParams(). //todo
WithTimeout(defaultOpTimeout)

modelz, err := client.Models.ListModels(params, BasicAuth())
Expand Down
Loading