Skip to content

Commit

Permalink
delete multiphase in webui (microsoft#2760)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lijiaoa authored Aug 7, 2020
1 parent 109d9a3 commit 214a8e1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 89 deletions.
2 changes: 1 addition & 1 deletion src/webui/src/components/Modals/Killjob.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class KillJob extends React.Component<KillJobProps, KillJobState> {
onKill = (): void => {
this.setState({ isCalloutVisible: false }, () => {
const { trial } = this.props;
killJob(trial.key, trial.jobId, trial.status);
killJob(trial.key, trial.id, trial.status);
});
}

Expand Down
10 changes: 3 additions & 7 deletions src/webui/src/components/trial-detail/TableList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,22 +269,18 @@ class TableList extends React.Component<TableListProps, TableListState> {
showIntermediateModal = async (record: TrialJobInfo, event: React.SyntheticEvent<EventTarget>): Promise<void> => {
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
// final result in a succeed trial, it may be a dict.
// 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);
Expand Down
6 changes: 0 additions & 6 deletions src/webui/src/static/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ interface TableRecord {
startTime: number;
endTime?: number;
id: string;
jobId: string;
parameterId: string;
duration: number;
status: string;
intermediateCount: number;
Expand Down Expand Up @@ -126,17 +124,13 @@ interface Intermedia {
interface MetricDataRecord {
timestamp: number;
trialJobId: string;
trialId: string;
parameterId: string;
type: string;
sequence: number;
data: string;
}

interface TrialJobInfo {
id: string;
jobId: string;
parameterId: string;
sequenceId: number;
status: string;
startTime?: number;
Expand Down
2 changes: 0 additions & 2 deletions src/webui/src/static/model/trial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
77 changes: 4 additions & 73 deletions src/webui/src/static/model/trialmanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,13 @@ import { requestAxios } from '../function';
function groupMetricsByTrial(metrics: MetricDataRecord[]): Map<string, MetricDataRecord[]> {
const ret = new Map<string, MetricDataRecord[]>();
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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 214a8e1

Please sign in to comment.