Unverified Commit 2f166e98 authored by Lijiaoa's avatar Lijiaoa Committed by GitHub
Browse files

fix update experiment paramters bug (#3556)

parent c2c04f6c
......@@ -30,6 +30,7 @@ export const EditExperimentParam = (): any => {
const { title, field, editType, maxExecDuration, maxTrialNum, trialConcurrency, updateOverviewPage } = useContext(
EditExpeParamContext
);
const originMaxDurationStr = EXPERIMENT.profile.params.maxExperimentDuration;
const { maxDurationUnit, changeMaxDurationUnit } = useContext(AppContext);
const [unit, setUnit] = useState(maxDurationUnit);
let defaultVal = '';
......@@ -112,8 +113,10 @@ export const EditExperimentParam = (): any => {
params: { update_type: editType }
});
if (res.status === 200) {
if (isMaxDuration) {
changeMaxDurationUnit(unit);
}
showMessageInfo(`Successfully updated experiment's ${field}`, 'success');
changeMaxDurationUnit(unit);
updateOverviewPage();
}
} catch (error) {
......@@ -127,6 +130,12 @@ export const EditExperimentParam = (): any => {
showMessageInfo(`Failed to update trial ${field}\nUnknown error`, 'error');
}
setEditValInput(defaultVal);
// confirm trial config panel val
if (isMaxDuration) {
newProfile.params[field] = originMaxDurationStr;
} else {
newProfile.params[field] = beforeParam;
}
}
showPencil();
}
......
......@@ -3,8 +3,7 @@ import { Stack, Panel, PrimaryButton } from '@fluentui/react';
import { EXPERIMENT } from '../../static/datamodel';
import MonacoEditor from 'react-monaco-editor';
import { MONACO } from '../../static/const';
import { AppContext } from '../../App';
import { convertDuration, convertTimeAsUnit, caclMonacoEditorHeight } from '../../static/function';
import { convertDuration, caclMonacoEditorHeight } from '../../static/function';
import { prettyStringify } from '../../static/json_util';
import lodash from 'lodash';
import '../../static/style/logDrawer.scss';
......@@ -69,56 +68,45 @@ class TrialConfigPanel extends React.Component<LogDrawerProps, LogDrawerState> {
const prettyWidth = innerWidth > 1400 ? 100 : 60;
const showProfile = JSON.stringify(profile, filter, 2);
return (
<AppContext.Consumer>
{(value): React.ReactNode => {
const unit = value.maxDurationUnit;
profile.params.maxExperimentDuration = `${convertTimeAsUnit(
unit,
profile.params.maxExperimentDuration
)}${unit}`;
const showProfile = JSON.stringify(profile, filter, 2);
return (
<Stack>
<Panel
isOpen={true}
hasCloseButton={false}
isFooterAtBottom={true}
isLightDismiss={true}
onLightDismissClick={hideConfigPanel}
>
<div className='panel'>
{panelName === 'search space' ? (
<div>
<div className='panelName'>Search space</div>
<MonacoEditor
height={monacoEditorHeight}
language='json'
theme='vs-light'
value={prettyStringify(EXPERIMENT.searchSpace, prettyWidth, 2)}
options={MONACO}
/>
</div>
) : (
<div className='profile'>
<div className='panelName'>Config</div>
<MonacoEditor
width='100%'
height={monacoEditorHeight}
language='json'
theme='vs-light'
value={showProfile}
options={MONACO}
/>
</div>
)}
<PrimaryButton text='Close' className='configClose' onClick={hideConfigPanel} />
</div>
</Panel>
</Stack>
);
}}
</AppContext.Consumer>
<Stack>
<Panel
isOpen={true}
hasCloseButton={false}
isFooterAtBottom={true}
isLightDismiss={true}
onLightDismissClick={hideConfigPanel}
>
<div className='panel'>
{panelName === 'search space' ? (
<div>
<div className='panelName'>Search space</div>
<MonacoEditor
height={monacoEditorHeight}
language='json'
theme='vs-light'
value={prettyStringify(EXPERIMENT.searchSpace, prettyWidth, 2)}
options={MONACO}
/>
</div>
) : (
<div className='profile'>
<div className='panelName'>Config</div>
<MonacoEditor
width='100%'
height={monacoEditorHeight}
language='json'
theme='vs-light'
value={showProfile}
options={MONACO}
/>
</div>
)}
<PrimaryButton text='Close' className='configClose' onClick={hideConfigPanel} />
</div>
</Panel>
</Stack>
);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment