Skip to content

Commit

Permalink
UI: Add Trial Parameters to submit experiment page (kubeflow#1224)
Browse files Browse the repository at this point in the history
* Modify trial template editor and trial template configMap in submit Experiment by parameters

* Add trial parameters

* Change trialParam when configMap has been changed

* Remove comment

* Fix submit nas job
  • Loading branch information
andreyvelich authored and sperlingxx committed Jun 29, 2020
1 parent 5cb42c0 commit b819275
Show file tree
Hide file tree
Showing 25 changed files with 939 additions and 816 deletions.
30 changes: 15 additions & 15 deletions pkg/ui/v1beta1/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ 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)
updatedConfigMapNamespace := data["updatedConfigMapNamespace"].(string)
updatedConfigMapName := data["updatedConfigMapName"].(string)
updatedConfigMapPath := data["updatedConfigMapPath"].(string)
updatedTemplateYaml := data["updatedTemplateYaml"].(string)

newTemplates, err := k.updateTrialTemplates(edittedNamespace, edittedConfigMapName, edittedName, edittedYaml, "", ActionTypeAdd)
newTemplates, err := k.updateTrialTemplates(updatedConfigMapNamespace, updatedConfigMapName, "", updatedConfigMapPath, updatedTemplateYaml, ActionTypeAdd)
if err != nil {
log.Printf("updateTrialTemplates failed: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand All @@ -174,13 +174,13 @@ func (k *KatibUIHandler) EditTemplate(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)
currentName := data["currentName"].(string)
updatedConfigMapNamespace := data["updatedConfigMapNamespace"].(string)
updatedConfigMapName := data["updatedConfigMapName"].(string)
configMapPath := data["configMapPath"].(string)
updatedConfigMapPath := data["updatedConfigMapPath"].(string)
updatedTemplateYaml := data["updatedTemplateYaml"].(string)

newTemplates, err := k.updateTrialTemplates(edittedNamespace, edittedConfigMapName, edittedName, edittedYaml, currentName, ActionTypeEdit)
newTemplates, err := k.updateTrialTemplates(updatedConfigMapNamespace, updatedConfigMapName, configMapPath, updatedConfigMapPath, updatedTemplateYaml, ActionTypeEdit)
if err != nil {
log.Printf("updateTrialTemplates failed: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand All @@ -206,11 +206,11 @@ 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)
updatedConfigMapNamespace := data["updatedConfigMapNamespace"].(string)
updatedConfigMapName := data["updatedConfigMapName"].(string)
updatedConfigMapPath := data["updatedConfigMapPath"].(string)

newTemplates, err := k.updateTrialTemplates(edittedNamespace, edittedConfigMapName, edittedName, "", "", ActionTypeDelete)
newTemplates, err := k.updateTrialTemplates(updatedConfigMapNamespace, updatedConfigMapName, "", updatedConfigMapPath, "", ActionTypeDelete)
if err != nil {
log.Printf("updateTrialTemplates failed: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand Down
28 changes: 18 additions & 10 deletions pkg/ui/v1beta1/frontend/src/actions/generalActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,15 @@ export const closeDialogSuggestion = () => ({

export const FILTER_TEMPLATES_EXPERIMENT = 'FILTER_TEMPLATES_EXPERIMENT';

export const filterTemplatesExperiment = (trialNamespace, trialConfigMapName) => ({
export const filterTemplatesExperiment = (
configMapNamespaceIndex,
configMapNameIndex,
configMapPathIndex,
) => ({
type: FILTER_TEMPLATES_EXPERIMENT,
trialNamespace,
trialConfigMapName,
});

export const CHANGE_TEMPLATE_NAME = 'CHANGE_TEMPLATE_NAME';

export const changeTemplateName = templateName => ({
type: CHANGE_TEMPLATE_NAME,
templateName,
configMapNamespaceIndex,
configMapNameIndex,
configMapPathIndex,
});

export const VALIDATION_ERROR = 'VALIDATION_ERROR';
Expand All @@ -112,3 +110,13 @@ export const validationError = message => ({
type: VALIDATION_ERROR,
message,
});

export const EDIT_TRIAL_PARAMETERS = 'EDIT_TRIAL_PARAMETERS';

export const editTrialParameters = (index, name, reference, description) => ({
type: EDIT_TRIAL_PARAMETERS,
index,
name,
reference,
description,
});
77 changes: 42 additions & 35 deletions pkg/ui/v1beta1/frontend/src/actions/templateActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ export const OPEN_DIALOG = 'OPEN_DIALOG';

export const openDialog = (
dialogType,
namespace = '',
configMapNamespace = '',
configMapName = '',
templateName = '',
configMapPath = '',
templateYaml = '',
) => ({
type: OPEN_DIALOG,
dialogType,
namespace,
configMapNamespace,
configMapName,
templateName,
configMapPath,
templateYaml,
});

Expand All @@ -33,65 +33,72 @@ 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 = (edittedNamespace, edittedConfigMapName, edittedName, edittedYaml) => ({
export const addTemplate = (
updatedConfigMapNamespace,
updatedConfigMapName,
updatedConfigMapPath,
updatedTemplateYaml,
) => ({
type: ADD_TEMPLATE_REQUEST,
edittedNamespace,
edittedConfigMapName,
edittedName,
edittedYaml,
updatedConfigMapNamespace,
updatedConfigMapName,
updatedConfigMapPath,
updatedTemplateYaml,
});

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 = (
edittedNamespace,
edittedConfigMapName,
currentName,
edittedName,
edittedYaml,
updatedConfigMapNamespace,
updatedConfigMapName,
configMapPath,
updatedConfigMapPath,
updatedTemplateYaml,
) => ({
type: EDIT_TEMPLATE_REQUEST,
edittedNamespace,
edittedConfigMapName,
currentName,
edittedName,
edittedYaml,
updatedConfigMapNamespace,
updatedConfigMapName,
configMapPath,
updatedConfigMapPath,
updatedTemplateYaml,
});

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 = (edittedNamespace, edittedConfigMapName, edittedName) => ({
export const deleteTemplate = (
updatedConfigMapNamespace,
updatedConfigMapName,
updatedConfigMapPath,
) => ({
type: DELETE_TEMPLATE_REQUEST,
edittedNamespace,
edittedConfigMapName,
edittedName,
updatedConfigMapNamespace,
updatedConfigMapName,
updatedConfigMapPath,
});

export const CHANGE_TEMPLATE = 'CHANGE_TEMPLATE';

export const changeTemplate = (
edittedTemplateNamespace,
edittedTemplateConfigMapName,
edittedTemplateName,
edittedTemplateYaml,
edittedTemplateConfigMapSelectList,
updatedConfigMapNamespace,
updatedConfigMapName,
updatedConfigMapPath,
updatedTemplateYaml,
) => ({
type: CHANGE_TEMPLATE,
edittedTemplateNamespace,
edittedTemplateConfigMapName,
edittedTemplateName,
edittedTemplateYaml,
edittedTemplateConfigMapSelectList,
updatedConfigMapNamespace,
updatedConfigMapName,
updatedConfigMapPath,
updatedTemplateYaml,
});

export const FILTER_TEMPLATES = 'FILTER_TEMPLATES';

export const filterTemplates = (filteredNamespace, filteredConfigMapName) => ({
export const filterTemplates = (filteredConfigMapNamespace, filteredConfigMapName) => ({
type: FILTER_TEMPLATES,
filteredNamespace,
filteredConfigMapNamespace,
filteredConfigMapName,
});
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ class MetricsCollectorSpec extends React.Component {
</MenuItem>
);
})}
)}
</Select>
</FormControl>
</Grid>
Expand Down
Loading

0 comments on commit b819275

Please sign in to comment.