import * as React from 'react'; import { Stack, Panel, PrimaryButton } from '@fluentui/react'; import { EXPERIMENT } from '../../static/datamodel'; import MonacoEditor from 'react-monaco-editor'; import { MONACO } from '../../static/const'; import { convertDuration, caclMonacoEditorHeight } from '../../static/function'; import { prettyStringify } from '../../static/json_util'; import lodash from 'lodash'; import '../../static/style/logDrawer.scss'; interface LogDrawerProps { hideConfigPanel: () => void; panelName: string; } interface LogDrawerState { panelInnerHeight: number; innerWidth: number; } /** * search space * config * model */ class TrialConfigPanel extends React.Component { constructor(props: LogDrawerProps) { super(props); this.state = { panelInnerHeight: window.innerHeight, innerWidth: window.innerWidth }; } // use arrow function for change window size met error: this.setState is not a function setLogDrawerHeight = (): void => { this.setState(() => ({ panelInnerHeight: window.innerHeight, innerWidth: window.innerWidth })); }; async componentDidMount(): Promise { window.addEventListener('resize', this.setLogDrawerHeight); } componentWillUnmount(): void { window.removeEventListener('resize', this.setLogDrawerHeight); } render(): React.ReactNode { const { hideConfigPanel, panelName } = this.props; const { panelInnerHeight, innerWidth } = this.state; const monacoEditorHeight = caclMonacoEditorHeight(panelInnerHeight); const blacklist = [ 'id', 'logDir', 'startTime', 'endTime', 'experimentName', 'searchSpace', 'trainingServicePlatform' ]; const filter = (key: string, val: any): any => { return blacklist.includes(key) ? undefined : val; }; const profile = lodash.cloneDeep(EXPERIMENT.profile); profile.execDuration = convertDuration(profile.execDuration); const prettyWidth = innerWidth > 1400 ? 100 : 60; const showProfile = JSON.stringify(profile, filter, 2); return (
{panelName === 'search space' ? (
Search space
) : (
Config
)}
); } } export default TrialConfigPanel;