"docs/_removed/TrainingService/RemoteMachineMode.rst" did not exist on "85fd39a74d4c8f3e671c23901099db0bd2c7c085"
Unverified Commit 8fd18a5a authored by chicm-ms's avatar chicm-ms Committed by GitHub
Browse files

Optimize query job performance (#898)

* Optimize job query performance
parent aaa8f446
...@@ -250,29 +250,26 @@ class NNIDataStore implements DataStore { ...@@ -250,29 +250,26 @@ class NNIDataStore implements DataStore {
return <TrialJobStatus>event; return <TrialJobStatus>event;
} }
private mergeHyperParameters(hyperParamList: string[], newParamStr: string): string[] { private parseHyperParameter(hParamStr: string): any {
const mergedHyperParams: any[] = []; let hParam: any;
let newParam: any;
try { try {
newParam = JSON.parse(newParamStr); hParam = JSON.parse(hParamStr);
return hParam;
} catch (err) { } catch (err) {
this.log.error(`Hyper parameter needs to be in json format: ${newParamStr}`); this.log.error(`Hyper parameter needs to be in json format: ${hParamStr}`);
return hyperParamList; return undefined;
}
for (const hyperParamStr of hyperParamList) {
const hyperParam: any = JSON.parse(hyperParamStr);
mergedHyperParams.push(hyperParam);
} }
if (mergedHyperParams.filter((value: any) => value.parameter_index === newParam.parameter_index).length <= 0) {
mergedHyperParams.push(newParam);
}
return mergedHyperParams.map<string>((value: any) => { return JSON.stringify(value); });
} }
// tslint:disable-next-line:cyclomatic-complexity
private getTrialJobsByReplayEvents(trialJobEvents: TrialJobEventRecord[]): Map<string, TrialJobInfo> { private getTrialJobsByReplayEvents(trialJobEvents: TrialJobEventRecord[]): Map<string, TrialJobInfo> {
this.log.debug('getTrialJobsByReplayEvents begin');
const map: Map<string, TrialJobInfo> = new Map(); const map: Map<string, TrialJobInfo> = new Map();
const hParamIdMap: Map<string, Set<number>> = new Map();
// assume data is stored by time ASC order // assume data is stored by time ASC order
for (const record of trialJobEvents) { for (const record of trialJobEvents) {
let jobInfo: TrialJobInfo | undefined; let jobInfo: TrialJobInfo | undefined;
...@@ -322,18 +319,31 @@ class NNIDataStore implements DataStore { ...@@ -322,18 +319,31 @@ class NNIDataStore implements DataStore {
} }
jobInfo.status = this.getJobStatusByLatestEvent(jobInfo.status, record.event); jobInfo.status = this.getJobStatusByLatestEvent(jobInfo.status, record.event);
if (record.data !== undefined && record.data.trim().length > 0) { if (record.data !== undefined && record.data.trim().length > 0) {
const newHParam: any = this.parseHyperParameter(record.data);
if (newHParam !== undefined) {
if (jobInfo.hyperParameters !== undefined) { if (jobInfo.hyperParameters !== undefined) {
jobInfo.hyperParameters = this.mergeHyperParameters(jobInfo.hyperParameters, record.data); let hParamIds: Set<number> | undefined = hParamIdMap.get(jobInfo.id);
if (hParamIds === undefined) {
hParamIds = new Set();
}
if (!hParamIds.has(newHParam.parameter_index)) {
jobInfo.hyperParameters.push(JSON.stringify(newHParam));
hParamIds.add(newHParam.parameter_index);
hParamIdMap.set(jobInfo.id, hParamIds);
}
} else { } else {
assert(false, 'jobInfo.hyperParameters is undefined'); assert(false, 'jobInfo.hyperParameters is undefined');
} }
} }
}
if (record.sequenceId !== undefined && jobInfo.sequenceId === undefined) { if (record.sequenceId !== undefined && jobInfo.sequenceId === undefined) {
jobInfo.sequenceId = record.sequenceId; jobInfo.sequenceId = record.sequenceId;
} }
map.set(record.trialJobId, jobInfo); map.set(record.trialJobId, jobInfo);
} }
this.log.debug('getTrialJobsByReplayEvents done');
return map; return map;
} }
} }
......
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