From 214a8e18a9a19d7f2b13bcd7a8d6decf7e439b80 Mon Sep 17 00:00:00 2001 From: Lijiaoa <61399850+Lijiaoa@users.noreply.github.com> Date: Fri, 7 Aug 2020 14:45:49 +0800 Subject: [PATCH] delete multiphase in webui (#2760) --- src/webui/src/components/Modals/Killjob.tsx | 2 +- .../src/components/trial-detail/TableList.tsx | 10 +-- src/webui/src/static/interface.ts | 6 -- src/webui/src/static/model/trial.ts | 2 - src/webui/src/static/model/trialmanager.ts | 77 +------------------ 5 files changed, 8 insertions(+), 89 deletions(-) diff --git a/src/webui/src/components/Modals/Killjob.tsx b/src/webui/src/components/Modals/Killjob.tsx index 580ff5ff24..2f4c7a1833 100644 --- a/src/webui/src/components/Modals/Killjob.tsx +++ b/src/webui/src/components/Modals/Killjob.tsx @@ -77,7 +77,7 @@ class KillJob extends React.Component { onKill = (): void => { this.setState({ isCalloutVisible: false }, () => { const { trial } = this.props; - killJob(trial.key, trial.jobId, trial.status); + killJob(trial.key, trial.id, trial.status); }); } diff --git a/src/webui/src/components/trial-detail/TableList.tsx b/src/webui/src/components/trial-detail/TableList.tsx index 94af7e8fb9..4ce1ccd7bb 100644 --- a/src/webui/src/components/trial-detail/TableList.tsx +++ b/src/webui/src/components/trial-detail/TableList.tsx @@ -269,7 +269,7 @@ class TableList extends React.Component { showIntermediateModal = async (record: TrialJobInfo, event: React.SyntheticEvent): Promise => { event.preventDefault(); event.stopPropagation(); - const res = await axios.get(`${MANAGER_IP}/metric-data/${record.jobId}`); + const res = await axios.get(`${MANAGER_IP}/metric-data/${record.id}`); if (res.status === 200) { const intermediateArr: number[] = []; // support intermediate result is dict because the last intermediate result is @@ -277,14 +277,10 @@ class TableList extends React.Component { // get intermediate result dict keys array const { intermediateKey } = this.state; const otherkeys: string[] = []; - // One trial job may contains multiple parameter id - // only show current trial's metric data - const metricDatas = res.data.filter(item => { - return item.parameterId == record.parameterId; - }); + const metricDatas = res.data; if (metricDatas.length !== 0) { // just add type=number keys - const intermediateMetrics = parseMetrics(res.data[0].data); + const intermediateMetrics = parseMetrics(metricDatas[0].data); for (const key in intermediateMetrics) { if (typeof intermediateMetrics[key] === 'number') { otherkeys.push(key); diff --git a/src/webui/src/static/interface.ts b/src/webui/src/static/interface.ts index c033c225f4..493ffc4b41 100644 --- a/src/webui/src/static/interface.ts +++ b/src/webui/src/static/interface.ts @@ -43,8 +43,6 @@ interface TableRecord { startTime: number; endTime?: number; id: string; - jobId: string; - parameterId: string; duration: number; status: string; intermediateCount: number; @@ -126,8 +124,6 @@ interface Intermedia { interface MetricDataRecord { timestamp: number; trialJobId: string; - trialId: string; - parameterId: string; type: string; sequence: number; data: string; @@ -135,8 +131,6 @@ interface MetricDataRecord { interface TrialJobInfo { id: string; - jobId: string; - parameterId: string; sequenceId: number; status: string; startTime?: number; diff --git a/src/webui/src/static/model/trial.ts b/src/webui/src/static/model/trial.ts index ebdd35bc77..b1431a0a5f 100644 --- a/src/webui/src/static/model/trial.ts +++ b/src/webui/src/static/model/trial.ts @@ -115,8 +115,6 @@ class Trial implements TableObj { key: this.info.id, sequenceId: this.info.sequenceId, id: this.info.id, - jobId: this.info.jobId, - parameterId: this.info.parameterId, // eslint-disable-next-line @typescript-eslint/no-non-null-assertion startTime: this.info.startTime!, endTime: this.info.endTime, diff --git a/src/webui/src/static/model/trialmanager.ts b/src/webui/src/static/model/trialmanager.ts index b860cfa042..ffc0f85f55 100644 --- a/src/webui/src/static/model/trialmanager.ts +++ b/src/webui/src/static/model/trialmanager.ts @@ -7,29 +7,13 @@ import { requestAxios } from '../function'; function groupMetricsByTrial(metrics: MetricDataRecord[]): Map { const ret = new Map(); for (const metric of metrics) { - const trialId = `${metric.trialJobId}-${metric.parameterId}`; - metric.trialId = trialId; - if (ret.has(trialId)) { + if (ret.has(metric.trialJobId)) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - ret.get(trialId)!.push(metric); + ret.get(metric.trialJobId)!.push(metric); } else { - ret.set(trialId, [metric]); + ret.set(metric.trialJobId, [ metric ]); } } - // to compatiable with multi-trial in same job, fix offset of sequence - ret.forEach((trialMetrics) => { - let minSequenceNumber = Number.POSITIVE_INFINITY; - trialMetrics.map((item) => { - if (item.sequence < minSequenceNumber && item.type !== "FINAL") { - minSequenceNumber = item.sequence; - } - }); - trialMetrics.map((item) => { - if (item.type !== "FINAL") { - item.sequence -= minSequenceNumber; - } - }); - }); return ret; } @@ -145,57 +129,6 @@ class TrialManager { return new MetricSpace([...this.trials.values()]); } - public static expandJobsToTrials(jobs: TrialJobInfo[]): TrialJobInfo[] { - const trials: TrialJobInfo[] = []; - - for (const jobInfo of jobs as TrialJobInfo[]) { - if (jobInfo.hyperParameters) { - let trial: TrialJobInfo | undefined; - let lastTrial: TrialJobInfo | undefined; - for (let i = 0; i < jobInfo.hyperParameters.length; i++) { - const hyperParameters = jobInfo.hyperParameters[i] - const hpObject = JSON.parse(hyperParameters); - const parameterId = hpObject["parameter_id"]; - trial = { - id: `${jobInfo.id}-${parameterId}`, - jobId: jobInfo.id, - parameterId: parameterId, - sequenceId: parameterId, - status: "SUCCEEDED", - startTime: jobInfo.startTime, - endTime: jobInfo.startTime, - hyperParameters: [hyperParameters], - logPath: jobInfo.logPath, - stderrPath: jobInfo.stderrPath, - }; - if (jobInfo.finalMetricData) { - for (const metricData of jobInfo.finalMetricData) { - if (metricData.parameterId == parameterId) { - trial.finalMetricData = [metricData]; - trial.endTime = metricData.timestamp; - break; - } - } - } - if (lastTrial) { - trial.startTime = lastTrial.endTime; - } else { - trial.startTime = jobInfo.startTime; - } - lastTrial = trial; - trials.push(trial); - } - if (lastTrial !== undefined) { - lastTrial.status = jobInfo.status; - lastTrial.endTime = jobInfo.endTime; - } - } else { - trials.push(jobInfo); - } - } - return trials; - } - // if this.jobListError = true, show trial error message [/trial-jobs] public jobListError(): boolean { return this.isJobListError; @@ -239,9 +172,7 @@ class TrialManager { let updated = false; requestAxios(`${MANAGER_IP}/trial-jobs`) .then(data => { - const newTrials = TrialManager.expandJobsToTrials(data as any); - this.trialJobList = newTrials; - for (const trialInfo of newTrials as TrialJobInfo[]) { + for (const trialInfo of data as TrialJobInfo[]) { if (this.trials.has(trialInfo.id)) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion updated = this.trials.get(trialInfo.id)!.updateTrialJobInfo(trialInfo) || updated;