Unverified Commit 214a8e18 authored by Lijiaoa's avatar Lijiaoa Committed by GitHub
Browse files

delete multiphase in webui (#2760)

parent 109d9a32
...@@ -77,7 +77,7 @@ class KillJob extends React.Component<KillJobProps, KillJobState> { ...@@ -77,7 +77,7 @@ class KillJob extends React.Component<KillJobProps, KillJobState> {
onKill = (): void => { onKill = (): void => {
this.setState({ isCalloutVisible: false }, () => { this.setState({ isCalloutVisible: false }, () => {
const { trial } = this.props; const { trial } = this.props;
killJob(trial.key, trial.jobId, trial.status); killJob(trial.key, trial.id, trial.status);
}); });
} }
......
...@@ -269,7 +269,7 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -269,7 +269,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
showIntermediateModal = async (record: TrialJobInfo, event: React.SyntheticEvent<EventTarget>): Promise<void> => { showIntermediateModal = async (record: TrialJobInfo, event: React.SyntheticEvent<EventTarget>): Promise<void> => {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); 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) { if (res.status === 200) {
const intermediateArr: number[] = []; const intermediateArr: number[] = [];
// support intermediate result is dict because the last intermediate result is // support intermediate result is dict because the last intermediate result is
...@@ -277,14 +277,10 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -277,14 +277,10 @@ class TableList extends React.Component<TableListProps, TableListState> {
// get intermediate result dict keys array // get intermediate result dict keys array
const { intermediateKey } = this.state; const { intermediateKey } = this.state;
const otherkeys: string[] = []; const otherkeys: string[] = [];
// One trial job may contains multiple parameter id const metricDatas = res.data;
// only show current trial's metric data
const metricDatas = res.data.filter(item => {
return item.parameterId == record.parameterId;
});
if (metricDatas.length !== 0) { if (metricDatas.length !== 0) {
// just add type=number keys // just add type=number keys
const intermediateMetrics = parseMetrics(res.data[0].data); const intermediateMetrics = parseMetrics(metricDatas[0].data);
for (const key in intermediateMetrics) { for (const key in intermediateMetrics) {
if (typeof intermediateMetrics[key] === 'number') { if (typeof intermediateMetrics[key] === 'number') {
otherkeys.push(key); otherkeys.push(key);
......
...@@ -43,8 +43,6 @@ interface TableRecord { ...@@ -43,8 +43,6 @@ interface TableRecord {
startTime: number; startTime: number;
endTime?: number; endTime?: number;
id: string; id: string;
jobId: string;
parameterId: string;
duration: number; duration: number;
status: string; status: string;
intermediateCount: number; intermediateCount: number;
...@@ -126,8 +124,6 @@ interface Intermedia { ...@@ -126,8 +124,6 @@ interface Intermedia {
interface MetricDataRecord { interface MetricDataRecord {
timestamp: number; timestamp: number;
trialJobId: string; trialJobId: string;
trialId: string;
parameterId: string;
type: string; type: string;
sequence: number; sequence: number;
data: string; data: string;
...@@ -135,8 +131,6 @@ interface MetricDataRecord { ...@@ -135,8 +131,6 @@ interface MetricDataRecord {
interface TrialJobInfo { interface TrialJobInfo {
id: string; id: string;
jobId: string;
parameterId: string;
sequenceId: number; sequenceId: number;
status: string; status: string;
startTime?: number; startTime?: number;
......
...@@ -115,8 +115,6 @@ class Trial implements TableObj { ...@@ -115,8 +115,6 @@ class Trial implements TableObj {
key: this.info.id, key: this.info.id,
sequenceId: this.info.sequenceId, sequenceId: this.info.sequenceId,
id: this.info.id, id: this.info.id,
jobId: this.info.jobId,
parameterId: this.info.parameterId,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
startTime: this.info.startTime!, startTime: this.info.startTime!,
endTime: this.info.endTime, endTime: this.info.endTime,
......
...@@ -7,29 +7,13 @@ import { requestAxios } from '../function'; ...@@ -7,29 +7,13 @@ import { requestAxios } from '../function';
function groupMetricsByTrial(metrics: MetricDataRecord[]): Map<string, MetricDataRecord[]> { function groupMetricsByTrial(metrics: MetricDataRecord[]): Map<string, MetricDataRecord[]> {
const ret = new Map<string, MetricDataRecord[]>(); const ret = new Map<string, MetricDataRecord[]>();
for (const metric of metrics) { for (const metric of metrics) {
const trialId = `${metric.trialJobId}-${metric.parameterId}`; if (ret.has(metric.trialJobId)) {
metric.trialId = trialId;
if (ret.has(trialId)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
ret.get(trialId)!.push(metric); ret.get(metric.trialJobId)!.push(metric);
} else { } 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; return ret;
} }
...@@ -145,57 +129,6 @@ class TrialManager { ...@@ -145,57 +129,6 @@ class TrialManager {
return new MetricSpace([...this.trials.values()]); 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] // if this.jobListError = true, show trial error message [/trial-jobs]
public jobListError(): boolean { public jobListError(): boolean {
return this.isJobListError; return this.isJobListError;
...@@ -239,9 +172,7 @@ class TrialManager { ...@@ -239,9 +172,7 @@ class TrialManager {
let updated = false; let updated = false;
requestAxios(`${MANAGER_IP}/trial-jobs`) requestAxios(`${MANAGER_IP}/trial-jobs`)
.then(data => { .then(data => {
const newTrials = TrialManager.expandJobsToTrials(data as any); for (const trialInfo of data as TrialJobInfo[]) {
this.trialJobList = newTrials;
for (const trialInfo of newTrials as TrialJobInfo[]) {
if (this.trials.has(trialInfo.id)) { if (this.trials.has(trialInfo.id)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
updated = this.trials.get(trialInfo.id)!.updateTrialJobInfo(trialInfo) || updated; updated = this.trials.get(trialInfo.id)!.updateTrialJobInfo(trialInfo) || updated;
......
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