Skip to content

Commit

Permalink
Merge pull request #170 from microsoft/master
Browse files Browse the repository at this point in the history
merge master
  • Loading branch information
SparkSnail authored May 15, 2019
2 parents f39d69e + 8818cb6 commit a030505
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
17 changes: 17 additions & 0 deletions src/nni_manager/common/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ export class NNIError extends Error {
}
this.cause = err;
}

public static FromError(err: NNIError | Error | string, messagePrefix?: string): NNIError {
const msgPrefix: string = messagePrefix === undefined ? '' : messagePrefix;
if (err instanceof NNIError) {
if (err.message !== undefined) {
err.message = msgPrefix + err.message;
}

return err;
} else if (typeof(err) === 'string') {
return new NNIError('', msgPrefix + err);
} else if (err instanceof Error) {
return new NNIError('', msgPrefix + err.message, err);
} else {
throw new Error(`Wrong instance type: ${typeof(err)}`);
}
}
}

export class MethodNotImplementedError extends Error {
Expand Down
2 changes: 1 addition & 1 deletion src/nni_manager/core/ipcInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class IpcInterface {
this.logger.warning('Commands jammed in buffer!');
}
} catch (err) {
throw new NNIError('Dispatcher Error', `Dispatcher Error: ${err.message}`, err);
throw NNIError.FromError(err, 'Dispatcher Error: ');
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/nni_manager/core/nniDataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class NNIDataStore implements DataStore {
try {
await this.db.storeExperimentProfile(experimentProfile);
} catch (err) {
throw new NNIError('Datastore error', `Datastore error: ${err.message}`, err);
throw NNIError.FromError(err, 'Datastore error: ');
}
}

Expand Down Expand Up @@ -105,7 +105,7 @@ class NNIDataStore implements DataStore {

return this.db.storeTrialJobEvent(event, trialJobId, timestamp, hyperParameter, jobDetail).catch(
(err: Error) => {
throw new NNIError('Datastore error', `Datastore error: ${err.message}`, err);
throw NNIError.FromError(err, 'Datastore error: ');
}
);
}
Expand Down Expand Up @@ -163,7 +163,7 @@ class NNIDataStore implements DataStore {
timestamp: Date.now()
}));
} catch (err) {
throw new NNIError('Datastore error', `Datastore error: ${err.message}`, err);
throw NNIError.FromError(err, 'Datastore error');
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/nni_manager/core/nnimanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,13 +573,13 @@ class NNIManager implements Manager {
await Promise.all([
this.periodicallyUpdateExecDuration(),
this.pingDispatcher().catch((err: Error) => {
throw new NNIError('Dispatcher error', `Dispatcher error: ${err.message}`, err);
throw NNIError.FromError(err, 'Dispatcher error: ');
}),
this.trainingService.run().catch((err: Error) => {
throw new NNIError('Training service error', `Training service error: ${err.message}`, err);
throw NNIError.FromError(err, 'Training service error: ');
}),
this.manageTrials().catch((err: Error) => {
throw new NNIError('Job management error', `Job management error: ${err.message}`, err);
throw NNIError.FromError(err, 'Job management error: ');
})]);
}

Expand All @@ -591,13 +591,13 @@ class NNIManager implements Manager {
}
this.trainingService.addTrialJobMetricListener((metric: TrialJobMetric) => {
this.onTrialJobMetrics(metric).catch((err: Error) => {
this.criticalError(new NNIError('Job metrics error', `Job metrics error: ${err.message}`, err));
this.criticalError(NNIError.FromError(err, 'Job metrics error: '));
});
});

this.dispatcher.onCommand((commandType: string, content: string) => {
this.onTunerCommand(commandType, content).catch((err: Error) => {
this.criticalError(new NNIError('Tuner command event error', `Tuner command event error: ${err.message}`, err));
this.criticalError(NNIError.FromError(err, 'Tuner command event error: '));
});
});
}
Expand Down
9 changes: 7 additions & 2 deletions src/nni_manager/training_service/local/gpuScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ class GPUScheduler {

public getAvailableGPUIndices(): number[] {
if (this.gpuSummary !== undefined) {
return this.gpuSummary.gpuInfos.filter((info: GPUInfo) => info.activeProcessNum === 0)
.map((info: GPUInfo) => info.index);
if(process.platform === 'win32') {
return this.gpuSummary.gpuInfos.map((info: GPUInfo) => info.index);
}
else{
return this.gpuSummary.gpuInfos.filter((info: GPUInfo) => info.activeProcessNum === 0)
.map((info: GPUInfo) => info.index);
}
}

return [];
Expand Down

0 comments on commit a030505

Please sign in to comment.