Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

fix update experiment parameters bug #3556

Merged
merged 1 commit into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 10 additions & 1 deletion ts/webui/src/components/overview/count/EditExperimentParam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
}
Expand Down
90 changes: 39 additions & 51 deletions ts/webui/src/components/slideNav/TrialConfigPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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>
);
}
}
Expand Down