diff --git a/.travis.yml b/.travis.yml index 782e32204a1..3ded96f080e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,6 @@ jobs: language: node_js node_js: "10.13.0" install: - - npm install --global prettier + - npm install --global prettier@1.19.1 script: - make prettier-check diff --git a/cmd/ui/v1alpha3/main.go b/cmd/ui/v1alpha3/main.go index 7479b5b7707..c8798184777 100644 --- a/cmd/ui/v1alpha3/main.go +++ b/cmd/ui/v1alpha3/main.go @@ -42,8 +42,9 @@ func main() { http.HandleFunc("/katib/fetch_nas_job_info/", kuh.FetchNASJobInfo) http.HandleFunc("/katib/fetch_trial_templates/", kuh.FetchTrialTemplates) - http.HandleFunc("/katib/update_template/", kuh.AddEditDeleteTemplate) - + http.HandleFunc("/katib/add_template/", kuh.AddTemplate) + http.HandleFunc("/katib/edit_template/", kuh.EditTemplate) + http.HandleFunc("/katib/delete_template/", kuh.DeleteTemplate) http.HandleFunc("/katib/fetch_namespaces", kuh.FetchNamespaces) log.Printf("Serving at %s:%s", *host, *port) diff --git a/manifests/v1alpha3/katib-controller/trialTemplateConfigmapLabeled.yaml b/manifests/v1alpha3/katib-controller/trialTemplateConfigmapLabeled.yaml new file mode 100644 index 00000000000..841ffd137ca --- /dev/null +++ b/manifests/v1alpha3/katib-controller/trialTemplateConfigmapLabeled.yaml @@ -0,0 +1,95 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: trial-template-labeled + namespace: kubeflow + labels: + app: katib-trial-templates +data: + defaultTrialTemplate.yaml: |- + apiVersion: batch/v1 + kind: Job + metadata: + name: {{.Trial}} + namespace: {{.NameSpace}} + spec: + template: + spec: + containers: + - name: {{.Trial}} + image: docker.io/kubeflowkatib/mxnet-mnist + command: + - "python3" + - "/opt/mxnet-mnist/mnist.py" + - "--batch-size=64" + {{- with .HyperParameters}} + {{- range .}} + - "{{.Name}}={{.Value}}" + {{- end}} + {{- end}} + restartPolicy: Never + nasRLCPUTemplate: |- + apiVersion: batch/v1 + kind: Job + metadata: + name: {{.Trial}} + namespace: {{.NameSpace}} + spec: + template: + spec: + containers: + - name: {{.Trial}} + image: docker.io/kubeflowkatib/nasrl-cifar10-cpu + command: + - "python3.5" + - "-u" + - "RunTrial.py" + {{- with .HyperParameters}} + {{- range .}} + - "--{{.Name}}=\"{{.Value}}\"" + {{- end}} + {{- end}} + - "--num_epochs=1" + restartPolicy: Never + pytorchJobTemplate: |- + apiVersion: "kubeflow.org/v1" + kind: PyTorchJob + metadata: + name: {{.Trial}} + namespace: {{.NameSpace}} + spec: + pytorchReplicaSpecs: + Master: + replicas: 1 + restartPolicy: OnFailure + template: + spec: + containers: + - name: pytorch + image: gcr.io/kubeflow-ci/pytorch-dist-mnist-test:v1.0 + imagePullPolicy: Always + command: + - "python" + - "/var/mnist.py" + {{- with .HyperParameters}} + {{- range .}} + - "{{.Name}}={{.Value}}" + {{- end}} + {{- end}} + Worker: + replicas: 2 + restartPolicy: OnFailure + template: + spec: + containers: + - name: pytorch + image: gcr.io/kubeflow-ci/pytorch-dist-mnist-test:v1.0 + imagePullPolicy: Always + command: + - "python" + - "/var/mnist.py" + {{- with .HyperParameters}} + {{- range .}} + - "{{.Name}}={{.Value}}" + {{- end}} + {{- end}} diff --git a/pkg/controller.v1alpha3/consts/const.go b/pkg/controller.v1alpha3/consts/const.go index ff07bc7cc59..998041a54be 100644 --- a/pkg/controller.v1alpha3/consts/const.go +++ b/pkg/controller.v1alpha3/consts/const.go @@ -114,6 +114,9 @@ const ( // AnnotationIstioSidecarInjectValue is the value of Istio Sidecar annotation AnnotationIstioSidecarInjectValue = "false" + + LabelTrialTemplateConfigMapName = "app" + LabelTrialTemplateConfigMapValue = "katib-trial-templates" ) var ( diff --git a/pkg/mock/v1alpha3/util/katibclient/katibclient.go b/pkg/mock/v1alpha3/util/katibclient/katibclient.go index c4868fce3db..ac6ebfc4f44 100644 --- a/pkg/mock/v1alpha3/util/katibclient/katibclient.go +++ b/pkg/mock/v1alpha3/util/katibclient/katibclient.go @@ -224,14 +224,14 @@ func (mr *MockClientMockRecorder) GetTrialList(arg0 interface{}, arg1 ...interfa } // GetTrialTemplates mocks base method -func (m *MockClient) GetTrialTemplates(arg0 ...string) (map[string]string, error) { +func (m *MockClient) GetTrialTemplates(arg0 ...string) (*v1.ConfigMapList, error) { m.ctrl.T.Helper() varargs := []interface{}{} for _, a := range arg0 { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "GetTrialTemplates", varargs...) - ret0, _ := ret[0].(map[string]string) + ret0, _ := ret[0].(*v1.ConfigMapList) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -254,40 +254,35 @@ func (mr *MockClientMockRecorder) InjectClient(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InjectClient", reflect.TypeOf((*MockClient)(nil).InjectClient), arg0) } -// UpdateExperiment mocks base method -func (m *MockClient) UpdateExperiment(arg0 *v1alpha3.Experiment, arg1 ...string) error { +// UpdateConfigMap mocks base method +func (m *MockClient) UpdateConfigMap(arg0 *v1.ConfigMap) error { m.ctrl.T.Helper() - varargs := []interface{}{arg0} - for _, a := range arg1 { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "UpdateExperiment", varargs...) + ret := m.ctrl.Call(m, "UpdateConfigMap", arg0) ret0, _ := ret[0].(error) return ret0 } -// UpdateExperiment indicates an expected call of UpdateExperiment -func (mr *MockClientMockRecorder) UpdateExperiment(arg0 interface{}, arg1 ...interface{}) *gomock.Call { +// UpdateConfigMap indicates an expected call of UpdateConfigMap +func (mr *MockClientMockRecorder) UpdateConfigMap(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0}, arg1...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateExperiment", reflect.TypeOf((*MockClient)(nil).UpdateExperiment), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateConfigMap", reflect.TypeOf((*MockClient)(nil).UpdateConfigMap), arg0) } -// UpdateTrialTemplates mocks base method -func (m *MockClient) UpdateTrialTemplates(arg0 map[string]string, arg1 ...string) error { +// UpdateExperiment mocks base method +func (m *MockClient) UpdateExperiment(arg0 *v1alpha3.Experiment, arg1 ...string) error { m.ctrl.T.Helper() varargs := []interface{}{arg0} for _, a := range arg1 { varargs = append(varargs, a) } - ret := m.ctrl.Call(m, "UpdateTrialTemplates", varargs...) + ret := m.ctrl.Call(m, "UpdateExperiment", varargs...) ret0, _ := ret[0].(error) return ret0 } -// UpdateTrialTemplates indicates an expected call of UpdateTrialTemplates -func (mr *MockClientMockRecorder) UpdateTrialTemplates(arg0 interface{}, arg1 ...interface{}) *gomock.Call { +// UpdateExperiment indicates an expected call of UpdateExperiment +func (mr *MockClientMockRecorder) UpdateExperiment(arg0 interface{}, arg1 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{arg0}, arg1...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateTrialTemplates", reflect.TypeOf((*MockClient)(nil).UpdateTrialTemplates), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateExperiment", reflect.TypeOf((*MockClient)(nil).UpdateExperiment), varargs...) } diff --git a/pkg/ui/v1alpha3/backend.go b/pkg/ui/v1alpha3/backend.go index a87361196a4..3d4ef4d9165 100644 --- a/pkg/ui/v1alpha3/backend.go +++ b/pkg/ui/v1alpha3/backend.go @@ -13,7 +13,6 @@ import ( experimentv1alpha3 "github.com/kubeflow/katib/pkg/apis/controller/experiments/v1alpha3" api_pb_v1alpha3 "github.com/kubeflow/katib/pkg/apis/manager/v1alpha3" common_v1alpha3 "github.com/kubeflow/katib/pkg/common/v1alpha3" - "github.com/kubeflow/katib/pkg/controller.v1alpha3/consts" "github.com/kubeflow/katib/pkg/util/v1alpha3/katibclient" ) @@ -116,21 +115,20 @@ func (k *KatibUIHandler) DeleteExperiment(w http.ResponseWriter, r *http.Request } } -// FetchTrialTemplates gets the trial templates for the given namespace. +// FetchTrialTemplates gets all trial templates in all namespaces func (k *KatibUIHandler) FetchTrialTemplates(w http.ResponseWriter, r *http.Request) { - //enableCors(&w) - namespace := r.URL.Query()["namespace"][0] - if namespace == "" { - namespace = consts.DefaultKatibNamespace - } - trialTemplates, err := k.katibClient.GetTrialTemplates(namespace) + + trialTemplatesViewList, err := k.getTrialTemplatesViewList() if err != nil { - log.Printf("GetTrialTemplate failed: %v", err) + log.Printf("getTrialTemplatesViewList failed: %v", err) http.Error(w, err.Error(), http.StatusInternalServerError) return } - response, err := json.Marshal(getTemplatesView(trialTemplates)) + TrialTemplatesResponse := TrialTemplatesResponse{ + Data: trialTemplatesViewList, + } + response, err := json.Marshal(TrialTemplatesResponse) if err != nil { log.Printf("Marshal templates failed: %v", err) http.Error(w, err.Error(), http.StatusInternalServerError) @@ -139,29 +137,91 @@ func (k *KatibUIHandler) FetchTrialTemplates(w http.ResponseWriter, r *http.Requ w.Write(response) } -func (k *KatibUIHandler) AddEditDeleteTemplate(w http.ResponseWriter, r *http.Request) { - //enableCors(&w) - //TODO: need to delete? - if r.Method == "OPTIONS" { +//AddTemplate adds template to ConfigMap +//TODO: Add functionality to create new ConfigMap +func (k *KatibUIHandler) AddTemplate(w http.ResponseWriter, r *http.Request) { + var data map[string]interface{} + json.NewDecoder(r.Body).Decode(&data) + + edittedNamespace := data["edittedNamespace"].(string) + edittedConfigMapName := data["edittedConfigMapName"].(string) + edittedName := data["edittedName"].(string) + edittedYaml := data["edittedYaml"].(string) + + newTemplates, err := k.updateTrialTemplates(edittedNamespace, edittedConfigMapName, edittedName, edittedYaml, "", ActionTypeAdd) + if err != nil { + log.Printf("updateTrialTemplates failed: %v", err) + http.Error(w, err.Error(), http.StatusInternalServerError) return } - var data map[string]interface{} - var err error - var templateResponse TemplateResponse + TrialTemplatesResponse := TrialTemplatesResponse{ + Data: newTemplates, + } + response, err := json.Marshal(TrialTemplatesResponse) + if err != nil { + log.Printf("Marhal failed: %v", err) + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + w.Write(response) + +} + +// EditTemplate edits template in ConfigMap +func (k *KatibUIHandler) EditTemplate(w http.ResponseWriter, r *http.Request) { + + var data map[string]interface{} json.NewDecoder(r.Body).Decode(&data) - if data["action"].(string) == "delete" { - templateResponse, err = k.updateTemplates(data, true) - } else { - templateResponse, err = k.updateTemplates(data, false) + + edittedNamespace := data["edittedNamespace"].(string) + edittedConfigMapName := data["edittedConfigMapName"].(string) + edittedName := data["edittedName"].(string) + edittedYaml := data["edittedYaml"].(string) + currentName := data["currentName"].(string) + + newTemplates, err := k.updateTrialTemplates(edittedNamespace, edittedConfigMapName, edittedName, edittedYaml, currentName, ActionTypeEdit) + if err != nil { + log.Printf("updateTrialTemplates failed: %v", err) + http.Error(w, err.Error(), http.StatusInternalServerError) + return } + + TrialTemplatesResponse := TrialTemplatesResponse{ + Data: newTemplates, + } + response, err := json.Marshal(TrialTemplatesResponse) if err != nil { - log.Printf("updateTemplates failed: %v", err) + log.Printf("Marhal failed: %v", err) http.Error(w, err.Error(), http.StatusInternalServerError) return } + w.Write(response) +} + +// DeleteTemplate delete template in ConfigMap +// TODO: Add functionality to delete configMap if there is no templates +func (k *KatibUIHandler) DeleteTemplate(w http.ResponseWriter, r *http.Request) { + + var data map[string]interface{} + json.NewDecoder(r.Body).Decode(&data) + + edittedNamespace := data["edittedNamespace"].(string) + edittedConfigMapName := data["edittedConfigMapName"].(string) + edittedName := data["edittedName"].(string) + + newTemplates, err := k.updateTrialTemplates(edittedNamespace, edittedConfigMapName, edittedName, "", "", ActionTypeDelete) + if err != nil { + log.Printf("updateTrialTemplates failed: %v", err) + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + TrialTemplatesResponse := TrialTemplatesResponse{ + Data: newTemplates, + } - response, err := json.Marshal(templateResponse) + response, err := json.Marshal(TrialTemplatesResponse) if err != nil { log.Printf("Marhal failed: %v", err) http.Error(w, err.Error(), http.StatusInternalServerError) diff --git a/pkg/ui/v1alpha3/frontend/src/actions/generalActions.js b/pkg/ui/v1alpha3/frontend/src/actions/generalActions.js index 5d3422f7813..04b8c989213 100644 --- a/pkg/ui/v1alpha3/frontend/src/actions/generalActions.js +++ b/pkg/ui/v1alpha3/frontend/src/actions/generalActions.js @@ -75,6 +75,21 @@ export const closeDialogExperiment = () => ({ type: CLOSE_DIALOG_EXPERIMENT, }); +export const FILTER_TEMPLATES_EXPERIMENT = 'FILTER_TEMPLATES_EXPERIMENT'; + +export const filterTemplatesExperiment = (trialNamespace, trialConfigMapName) => ({ + type: FILTER_TEMPLATES_EXPERIMENT, + trialNamespace, + trialConfigMapName, +}); + +export const CHANGE_TEMPLATE_NAME = 'CHANGE_TEMPLATE_NAME'; + +export const changeTemplateName = templateName => ({ + type: CHANGE_TEMPLATE_NAME, + templateName, +}); + export const VALIDATION_ERROR = 'VALIDATION_ERROR'; export const validationError = message => ({ diff --git a/pkg/ui/v1alpha3/frontend/src/actions/hpCreateActions.js b/pkg/ui/v1alpha3/frontend/src/actions/hpCreateActions.js index 49446b2b413..bd1b1260323 100644 --- a/pkg/ui/v1alpha3/frontend/src/actions/hpCreateActions.js +++ b/pkg/ui/v1alpha3/frontend/src/actions/hpCreateActions.js @@ -124,20 +124,6 @@ export const deleteListParameter = (paramIndex, index) => ({ index, }); -export const CHANGE_TRIAL_HP = 'CHANGE_TRIAL_HP'; - -export const changeTrial = trial => ({ - type: CHANGE_TRIAL_HP, - trial, -}); - -export const CHANGE_TRIAL_NAMESPACE_HP = 'CHANGE_TRIAL_NAMESPACE_HP'; - -export const changeTrialNamespace = namespace => ({ - type: CHANGE_TRIAL_NAMESPACE_HP, - namespace, -}); - export const SUBMIT_HP_JOB_REQUEST = 'SUBMIT_HP_JOB_REQUEST'; export const SUBMIT_HP_JOB_SUCCESS = 'SUBMIT_HP_JOB_SUCCESS'; export const SUBMIT_HP_JOB_FAILURE = 'SUBMIT_HP_JOB_FAILURE'; diff --git a/pkg/ui/v1alpha3/frontend/src/actions/nasCreateActions.js b/pkg/ui/v1alpha3/frontend/src/actions/nasCreateActions.js index 08dc6d9e45e..3ac2429645e 100644 --- a/pkg/ui/v1alpha3/frontend/src/actions/nasCreateActions.js +++ b/pkg/ui/v1alpha3/frontend/src/actions/nasCreateActions.js @@ -183,20 +183,6 @@ export const deleteListParameter = (opIndex, paramIndex, listIndex) => ({ listIndex, }); -export const CHANGE_TRIAL_NAS = 'CHANGE_TRIAL_NAS'; - -export const changeTrial = trial => ({ - type: CHANGE_TRIAL_NAS, - trial, -}); - -export const CHANGE_TRIAL_NAMESPACE_NAS = 'CHANGE_TRIAL_NAMESPACE_NAS'; - -export const changeTrialNamespace = namespace => ({ - type: CHANGE_TRIAL_NAMESPACE_NAS, - namespace, -}); - export const SUBMIT_NAS_JOB_REQUEST = 'SUBMIT_NAS_JOB_REQUEST'; export const SUBMIT_NAS_JOB_SUCCESS = 'SUBMIT_NAS_JOB_SUCCESS'; export const SUBMIT_NAS_JOB_FAILURE = 'SUBMIT_NAS_JOB_FAILURE'; diff --git a/pkg/ui/v1alpha3/frontend/src/actions/templateActions.js b/pkg/ui/v1alpha3/frontend/src/actions/templateActions.js index bd45cd53c9b..bbbd8a99b9e 100644 --- a/pkg/ui/v1alpha3/frontend/src/actions/templateActions.js +++ b/pkg/ui/v1alpha3/frontend/src/actions/templateActions.js @@ -1,67 +1,97 @@ export const CLOSE_DIALOG = 'CLOSE_DIALOG'; -export const closeDialog = dialogType => ({ +export const closeDialog = () => ({ type: CLOSE_DIALOG, - dialogType, }); export const OPEN_DIALOG = 'OPEN_DIALOG'; -export const openDialog = (dialogType, index = -1, templateType = -1) => ({ +export const openDialog = ( + dialogType, + namespace = '', + configMapName = '', + templateName = '', + templateYaml = '', +) => ({ type: OPEN_DIALOG, dialogType, - index, - templateType, -}); - -export const CHANGE_TEMPLATE = 'CHANGE_TEMPLATE'; - -export const changeTemplate = (field, value) => ({ - type: CHANGE_TEMPLATE, - field, - value, + namespace, + configMapName, + templateName, + templateYaml, }); export const FETCH_TRIAL_TEMPLATES_REQUEST = 'FETCH_TRIAL_TEMPLATES_REQUEST'; export const FETCH_TRIAL_TEMPLATES_SUCCESS = 'FETCH_TRIAL_TEMPLATES_SUCCESS'; export const FETCH_TRIAL_TEMPLATES_FAILURE = 'FETCH_TRIAL_TEMPLATES_FAILURE'; -export const fetchTrialTemplates = namespace => ({ +export const fetchTrialTemplates = () => ({ type: FETCH_TRIAL_TEMPLATES_REQUEST, - namespace, }); export const ADD_TEMPLATE_REQUEST = 'ADD_TEMPLATE_REQUEST'; export const ADD_TEMPLATE_SUCCESS = 'ADD_TEMPLATE_SUCCESS'; export const ADD_TEMPLATE_FAILURE = 'ADD_TEMPLATE_FAILURE'; -export const addTemplate = (name, yaml, kind, action) => ({ +export const addTemplate = (edittedNamespace, edittedConfigMapName, edittedName, edittedYaml) => ({ type: ADD_TEMPLATE_REQUEST, - name, - yaml, - kind, - action, + edittedNamespace, + edittedConfigMapName, + edittedName, + edittedYaml, }); export const EDIT_TEMPLATE_REQUEST = 'EDIT_TEMPLATE_REQUEST'; export const EDIT_TEMPLATE_SUCCESS = 'EDIT_TEMPLATE_SUCCESS'; export const EDIT_TEMPLATE_FAILURE = 'EDIT_TEMPLATE_FAILURE'; -export const editTemplate = (name, yaml, kind, action) => ({ +export const editTemplate = ( + edittedNamespace, + edittedConfigMapName, + currentName, + edittedName, + edittedYaml, +) => ({ type: EDIT_TEMPLATE_REQUEST, - name, - yaml, - kind, - action, + edittedNamespace, + edittedConfigMapName, + currentName, + edittedName, + edittedYaml, }); export const DELETE_TEMPLATE_REQUEST = 'DELETE_TEMPLATE_REQUEST'; export const DELETE_TEMPLATE_SUCCESS = 'DELETE_TEMPLATE_SUCCESS'; export const DELETE_TEMPLATE_FAILURE = 'DELETE_TEMPLATE_FAILURE'; -export const deleteTemplate = (name, kind, action) => ({ +export const deleteTemplate = (edittedNamespace, edittedConfigMapName, edittedName) => ({ type: DELETE_TEMPLATE_REQUEST, - name, - kind, - action, + edittedNamespace, + edittedConfigMapName, + edittedName, +}); + +export const CHANGE_TEMPLATE = 'CHANGE_TEMPLATE'; + +export const changeTemplate = ( + edittedTemplateNamespace, + edittedTemplateConfigMapName, + edittedTemplateName, + edittedTemplateYaml, + edittedTemplateConfigMapSelectList, +) => ({ + type: CHANGE_TEMPLATE, + edittedTemplateNamespace, + edittedTemplateConfigMapName, + edittedTemplateName, + edittedTemplateYaml, + edittedTemplateConfigMapSelectList, +}); + +export const FILTER_TEMPLATES = 'FILTER_TEMPLATES'; + +export const filterTemplates = (filteredNamespace, filteredConfigMapName) => ({ + type: FILTER_TEMPLATES, + filteredNamespace, + filteredConfigMapName, }); diff --git a/pkg/ui/v1alpha3/frontend/src/components/HP/Create/HPParameters.jsx b/pkg/ui/v1alpha3/frontend/src/components/HP/Create/HPParameters.jsx index 882d14dc5f7..75401ed04dd 100644 --- a/pkg/ui/v1alpha3/frontend/src/components/HP/Create/HPParameters.jsx +++ b/pkg/ui/v1alpha3/frontend/src/components/HP/Create/HPParameters.jsx @@ -14,13 +14,15 @@ import Objective from './Params/Objective'; import TrialSpecParam from './Params/Trial'; import Parameters from './Params/Parameters'; import Algorithm from './Params/Algorithm'; -import MetricsCollectorSpec from '../../Common/Create/Params/MetricsCollector'; import { submitHPJob } from '../../../actions/hpCreateActions'; +import MetricsCollectorSpec from '../../Common/Create/Params/MetricsCollector'; + import { validationError } from '../../../actions/generalActions'; import * as constants from '../../../constants/constants'; const module = 'hpCreate'; +const generalModule = 'general'; const styles = theme => ({ root: { @@ -193,13 +195,12 @@ const HPParameters = props => { data.spec.metricsCollectorSpec = newMCSpec; - //TODO: Add support not only for default ConfigMap for Trial-Templates data.spec.trialTemplate = { goTemplate: { templateSpec: { - configMapName: 'trial-template', - configMapNamespace: props.trialNamespace, - templatePath: props.trial, + configMapName: props.templateConfigMapName, + configMapNamespace: props.templateNamespace, + templatePath: props.templateName, }, }, }; @@ -252,6 +253,9 @@ const mapStateToProps = state => ({ algorithmName: state[module].algorithmName, algorithmSettings: state[module].algorithmSettings, parameters: state[module].parameters, + templateNamespace: state[generalModule].templateNamespace, + templateConfigMapName: state[generalModule].templateConfigMapName, + templateName: state[generalModule].templateName, trial: state[module].trial, trialNamespace: state[module].trialNamespace, mcSpec: state[module].mcSpec, diff --git a/pkg/ui/v1alpha3/frontend/src/components/HP/Create/Params/Trial.jsx b/pkg/ui/v1alpha3/frontend/src/components/HP/Create/Params/Trial.jsx index f43e0e5cdcf..4f038ba4ff0 100644 --- a/pkg/ui/v1alpha3/frontend/src/components/HP/Create/Params/Trial.jsx +++ b/pkg/ui/v1alpha3/frontend/src/components/HP/Create/Params/Trial.jsx @@ -1,4 +1,6 @@ import React from 'react'; +import { connect } from 'react-redux'; + import withStyles from '@material-ui/styles/withStyles'; import Grid from '@material-ui/core/Grid'; import Tooltip from '@material-ui/core/Tooltip'; @@ -9,14 +11,12 @@ import InputLabel from '@material-ui/core/InputLabel'; import MenuItem from '@material-ui/core/MenuItem'; import FormControl from '@material-ui/core/FormControl'; import Select from '@material-ui/core/Select'; -import TextField from '@material-ui/core/TextField'; -import { connect } from 'react-redux'; -import { changeTrial, changeTrialNamespace } from '../../../../actions/hpCreateActions'; +import { filterTemplatesExperiment, changeTemplateName } from '../../../../actions/generalActions'; import { fetchTrialTemplates } from '../../../../actions/templateActions'; const module = 'hpCreate'; -const templateModule = 'template'; +const generalModule = 'general'; const styles = theme => ({ help: { @@ -31,33 +31,37 @@ const styles = theme => ({ padding: 2, marginBottom: 10, }, - formControl: { + trialForm: { margin: 4, width: '100%', }, - selectEmpty: { - marginTop: 10, + selectForm: { + margin: 4, + width: '20%', + }, + selectNS: { + marginRight: 10, }, }); class TrialSpecParam extends React.Component { componentDidMount() { - this.props.fetchTrialTemplates(this.props.trialNamespace); - this.props.changeTrialNamespace(this.props.trialNamespace); + this.props.fetchTrialTemplates(); } onTrialNamespaceChange = event => { - this.props.fetchTrialTemplates(event.target.value); - this.props.changeTrialNamespace(event.target.value); + this.props.filterTemplatesExperiment(event.target.value, ''); }; - onTrialChange = event => { - this.props.changeTrial(event.target.value); + onTrialConfigMapChange = event => { + this.props.filterTemplatesExperiment(this.props.templateNamespace, event.target.value); }; - render() { - const names = this.props.templates.map((template, i) => template.name); + onTrialTemplateChange = event => { + this.props.changeTemplateName(event.target.value); + }; + render() { const { classes } = this.props; return (