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
21 changes: 19 additions & 2 deletions di/commons/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ import (
"github.com/alecthomas/units"
"google.golang.org/grpc/grpclog"

"runtime"

log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
v1core "k8s.io/api/core/v1"
"runtime"
)

const (
Expand Down Expand Up @@ -147,6 +146,12 @@ const (
// learner pods should not be cleaned up
NoCleanup = "nocleanup"

MongoAddressKey = "MONGO_ADDRESS"
MongoDatabaseKey = "MONGO_DATABASE"
MongoUsernameKey = "MONGO_USERNAME"
MongoPasswordKey = "MONGO_PASSWORD"
MongoAuthenticationDatabase = "MONGO_Authentication_Database"

DlaasResourceLimit = "resource.limit"
DlaasResourceLimitQuerySize = "resource.limit.query.size"

Expand Down Expand Up @@ -195,6 +200,7 @@ func InitViper() {
// FfDL Change:Most likely be "standard" in Minikube and "ibmc-s3fs-standard" in DIND, (other value is "default" or "")
viper.SetDefault(SharedVolumeStorageClassKey, "")


// enable ENV vars and defaults
viper.AutomaticEnv()
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_", ".", "_"))
Expand All @@ -203,6 +209,11 @@ func InitViper() {
setLogLevel()
viper.SetDefault(PortKey, 8080)

viper.SetDefault(MongoAddressKey,os.Getenv(MongoAddressKey))
viper.SetDefault(MongoDatabaseKey,os.Getenv(MongoDatabaseKey))
viper.SetDefault(MongoUsernameKey,os.Getenv(MongoUsernameKey))
viper.SetDefault(MongoPasswordKey,os.Getenv(MongoPasswordKey))
viper.SetDefault(MongoAuthenticationDatabase,os.Getenv(MongoAuthenticationDatabase))
viper.SetDefault(ServicesTagKey, "prod") // or "latest" as the default?

viper.SetDefault(LearnerTagKey, "prod")
Expand Down Expand Up @@ -463,6 +474,11 @@ func GetDataStoreConfig() map[string]string {
if val != "" {
m[RegionKey] = val
}
// FfDL Change: This was in the older PR, supposing not needed?
//val = viper.GetString("objectstore." + UsernameKey)
//if val != "" {
// m[UsernameKey] = val
//}

val = viper.GetString("objectstore." + ProjectKey)
if val != "" {
Expand All @@ -473,6 +489,7 @@ func GetDataStoreConfig() map[string]string {
m[StorageType] = val
}


return m
}

Expand Down
25 changes: 14 additions & 11 deletions di/commons/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ const (

const TFOS = "tfos"

// const BDAPSAFE_SS = "bdapsafe-ss"
// const BDAP_SS = "bdap-ss"
// const BDP_SS = "bdp-ss"
const BDAPSAFE_SS = "bdapsafe-ss"
const BDAP_SS = "bdap-ss"
const BDP_SS = "bdp-ss"

// const BDAP = "bdap"
// const BDP = "bdp"
// const SAFE = "safe"
const BDAP = "bdap"
const BDP = "bdp"
const SAFE = "safe"

const ENVIR = "envir"

Expand All @@ -79,11 +79,14 @@ const FLUENT_BIT_LOG_PATH string = "FLUENT_BIT_LOG_PATH"

const JOBTYPE string = "jobType"
const SINGLE string = "single"

const MongoAddressKey = "mongo.address"
const MongoDatabaseKey = "mongo.database"
const MongoUsernameKey = "mongo.username"
const MongoPasswordKey = "mongo.password"
const DI_START_NODEPORT string = "DI_START_NODEPORT"
const DI_END_NODEPORT string = "DI_END_NODEPORT"

const MongoAddressKey = "MONGO_ADDRESS"
const MongoDatabaseKey = "MONGO_DATABASE"
const MongoUsernameKey = "MONGO_USERNAME"
const MongoPasswordKey = "MONGO_PASSWORD"
const MongoAuthenticationDatabase = "MONGO_Authentication_Database"

const (
LOG_STORING_KEY = "store_status"
Expand Down
128 changes: 126 additions & 2 deletions di/commons/controlcenter/client/cc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ type UserResponse struct {
Token string `json:"token,omitempty"`
}

type ProxyUserResponse struct {
Name string `json:"name"`
GID int `json:"gid"`
UID int `json:"uid"`
Token string `json:"token,omitempty"`
UserId int `json:"user_id,omitempty"`
Path string `json:"path,omitempty"`
}

type ProxyUserCheckResponse struct {
Code string `json:"code"`
Message int `json:"message"`
Result bool `json:"result"`
}

const CcAuthToken = "MLSS-Token"

// FIXME MLSS Change: get models filter by username and namespace
Expand Down Expand Up @@ -137,6 +152,50 @@ func (cc *CcClient) UserNamespaceCheck(token string, userName string, namespace
return nil
}

func (cc *CcClient) GetProxyUserFromCC(token string, proxyUserId string, userId string) (*ProxyUserResponse, error) {
apiUrl := cc.ccUrl + fmt.Sprintf("/cc/v1/proxyUser/%v/user/%v", proxyUserId, userId)
body, err := cc.accessCheckFromCc(token, apiUrl)
if err != nil {
return nil, err
}
var u = new(ProxyUserResponse)
//json.Unmarshal(body, &u)
err = models.GetResultData(body, &u)
if err != nil {
return nil, errors.New("GetResultData failed" + err.Error())
}
log.Debugf("response=%+v, GID=%v, UID=%v", u, u.GID, u.UID)
if (u.GID == 0 || u.UID == 0) {
return nil, errors.New("error GUIDCheck is on and GID or UID is 0")
}
//gid := strconv.Itoa(u.GID)
//uid := strconv.Itoa(u.UID)

return u, nil
}

func (cc *CcClient) GetGUIDFromProxyUserId(token string, proxyUserId string) (*string, *string, error) {
apiUrl := cc.ccUrl + fmt.Sprintf("/cc/v1/proxyUser/%v", proxyUserId)
body, err := cc.accessCheckFromCc(token, apiUrl)
if err != nil {
return nil, nil, err
}
var u = new(UserResponse)
//json.Unmarshal(body, &u)
err = models.GetResultData(body, &u)
if err != nil {
return nil, nil, errors.New("GetResultData failed")
}
log.Debugf("response=%+v, GID=%v, UID=%v", u, u.GID, u.UID)
if u.GUIDCheck && (u.GID == 0 || u.UID == 0) {
return nil, nil, errors.New("error GUIDCheck is on and GID or UID is 0")
}
gid := strconv.Itoa(u.GID)
uid := strconv.Itoa(u.UID)

return &gid, &uid, nil
}

func (cc *CcClient) GetGUIDFromUserId(token string, userId string) (*string, *string, error) {
apiUrl := cc.ccUrl + fmt.Sprintf("/cc/v1/users/name/%v", userId)
body, err := cc.accessCheckFromCc(token, apiUrl)
Expand All @@ -159,6 +218,7 @@ func (cc *CcClient) GetGUIDFromUserId(token string, userId string) (*string, *st
return &gid, &uid, nil
}


func (cc *CcClient) GetUserByName(token string, userId string) (*UserResponse, error) {
apiUrl := cc.ccUrl + fmt.Sprintf("/cc/v1/users/name/%v", userId)
body, err := cc.accessCheckFromCc(token, apiUrl)
Expand All @@ -176,6 +236,24 @@ func (cc *CcClient) GetUserByName(token string, userId string) (*UserResponse, e
return u, nil
}

func (cc *CcClient) ProxyUserCheck(token string, userId string, proxyUser string) (bool, error) {
apiUrl := cc.ccUrl + fmt.Sprintf("/cc/v1/proxyUserCheck/%v/%v", proxyUser, userId)
body, err := cc.accessCheckFromCc(token, apiUrl)
if err != nil {
return false, err
}
var auth bool
//json.Unmarshal(body, &u)
err = models.GetResultData(body, &auth)

if err != nil {
log.Error("Unmarshal Error", err)
return false, errors.New("Check Proxy User failed")
}

return auth, nil
}

func (cc *CcClient) AdminUserCheck(token string, adminUserId string, userId string) error {
apiUrl := cc.ccUrl + fmt.Sprintf("/cc/v1/auth/access/users/%v/users/%v", adminUserId, userId)
_, err := cc.accessCheckFromCc(token, apiUrl)
Expand Down Expand Up @@ -303,8 +381,8 @@ func (cc *CcClient) CheckNamespaceUser(token string, namespace string, user stri
return nil
}

func (cc *CcClient) GetCurrentUserNamespaceWithRole(token string, roleId string, clusterName string) ([]byte, error) {
apiUrl := cc.ccUrl + fmt.Sprintf("/cc/v1/groups/users/roles/%v/namespaces/clusterName/%v", roleId, clusterName)
func (cc *CcClient) GetCurrentUserNamespaceWithRole(token string, roleId string) ([]byte, error) {
apiUrl := cc.ccUrl + fmt.Sprintf("/cc/v1/groups/users/roles/%v/namespaces", roleId)
log.Debugf("get apiUrl: %v", apiUrl)
req, err := http.NewRequest("GET", apiUrl, strings.NewReader(""))
if err != nil {
Expand All @@ -330,3 +408,49 @@ func (cc *CcClient) GetCurrentUserNamespaceWithRole(token string, roleId string,
defer resp.Body.Close()
return body, nil
}


type GetGroupFromUserRequest struct {

}

type GetGroupFromUserResponse struct {
ID int64 `gorm:"column:id; PRIMARY_KEY" json:"id"`
Name string `json:"name"`
EnableFlag int8 `json:"enable_flag"`
UserId int64 `json:"user_id"`
RoleId int64 `json:"role_id"`
GroupId int64 `json:"group_id"`
Remarks string `json:"remarks"`
}



func (cc *CcClient) GetGroupFromUser(username string) (*GetGroupFromUserResponse,error){
apiUrl := cc.ccUrl + fmt.Sprintf("/cc/v1/group/username/%v", username)

req,err := http.NewRequest("GET",apiUrl,nil)
if err != nil {
return nil,err
}

res,err := cc.httpClient.Do(req)
if err != nil {
return nil, err
}

resByte, err := ioutil.ReadAll(res.Body)
if err != nil {
return nil, err
}

group := GetGroupFromUserResponse{}
err = json.Unmarshal(resByte,&group)
if err != nil {
return nil, err
}

return &group,nil


}
29 changes: 15 additions & 14 deletions di/commons/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const (
LogkeyRestAPIService = "rest-api"
LogkeyStorageService = "storage-service"
LogkeyTrainerService = "trainer-service"
LogkeyStorerService = "storer-service"
LogkeyVolumeManagerService = "volume-manager-service"

LogkeyJobMonitor = "jobmonitor"
Expand Down Expand Up @@ -225,23 +226,23 @@ func Config() {

loggingType := viper.GetString(config.LoggingType)
switch loggingType {
case config.LoggingTypeJson:
log.SetFormatter(&log.JSONFormatter{})
case config.LoggingTypeText:
log.SetFormatter(&log.TextFormatter{})
default: // any other env will use local settings (assuming outside SL)
env := viper.GetString(config.EnvKey)

switch env {
case config.DevelopmentEnv:
log.SetFormatter(&log.JSONFormatter{})
case config.StagingEnv:
log.SetFormatter(&log.JSONFormatter{})
case config.ProductionEnv:
case config.LoggingTypeJson:
log.SetFormatter(&log.JSONFormatter{})
case config.LoggingTypeText:
log.SetFormatter(&log.TextFormatter{})
default: // any other env will use local settings (assuming outside SL)
//env := viper.GetString(config.EnvKey)
log.SetFormatter(&log.JSONFormatter{})
}
//switch env {
// case config.DevelopmentEnv:
// log.SetFormatter(&log.JSONFormatter{})
// case config.StagingEnv:
// log.SetFormatter(&log.JSONFormatter{})
// case config.ProductionEnv:
// log.SetFormatter(&log.JSONFormatter{})
// default: // any other env will use local settings (assuming outside SL)
// log.SetFormatter(&log.JSONFormatter{})
// }
}

viper.SetDefault(LogCategoryGetTrainingLogStream, LogCategoryGetTrainingLogStreamDefaultValue)
Expand Down
2 changes: 2 additions & 0 deletions di/commons/models/experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type Experiment struct {
BaseModel
ExpDesc *string `json:"exp_desc"`
ExpName *string `json:"exp_name"`
GroupName string `json:"group_name"`
MlflowExpID *string `json:"mlflow_exp_id" gorm:"column:mlflow_exp_id"`
DssProjectID int64 `json:"dss_project_id"`
DssProjectVersionID int64 `json:"dss_project_version"`
DssWorkspaceID int64 `json:"dss_workspace_id"`
Expand Down
2 changes: 1 addition & 1 deletion di/commons/service/client/lcm.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func NewLcm(lcm service.LifecycleManagerClient) (LcmClient, error) {
if conn == nil{
log.Error("conn is nil")
}
log.Error("conn is not nil")
log.Debugf("conn is not nil")
return &lcmClient{
conn: conn,
client: service.NewLifecycleManagerClient(conn),
Expand Down
Loading