Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Show trial environment information in reuse mode (#3389)
Browse files Browse the repository at this point in the history
  • Loading branch information
SparkSnail authored Feb 24, 2021
1 parent 9caf521 commit bd2543e
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 29 deletions.
1 change: 1 addition & 0 deletions ts/nni_manager/common/datastore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface TrialJobEventRecord {
readonly data?: string;
readonly logPath?: string;
readonly sequenceId?: number;
readonly message?: string;
}

interface MetricData {
Expand Down
1 change: 0 additions & 1 deletion ts/nni_manager/common/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ abstract class Manager {
public abstract getTrialLog(trialJobId: string, logType: LogType): Promise<string>;

public abstract getTrialJobStatistics(): Promise<TrialJobStatistics[]>;
public abstract getTrialJobMessage(trialJobId: string): string | undefined;
public abstract getStatus(): NNIManagerStatus;
}

Expand Down
2 changes: 1 addition & 1 deletion ts/nni_manager/core/nniDataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class NNIDataStore implements DataStore {
if (timestamp === undefined) {
timestamp = Date.now();
}

return this.db.storeTrialJobEvent(event, trialJobId, timestamp, hyperParameter, jobDetail).catch(
(err: Error) => {
throw NNIError.FromError(err, 'Datastore error: ');
Expand Down Expand Up @@ -381,6 +380,7 @@ class NNIDataStore implements DataStore {
if (record.sequenceId !== undefined && jobInfo.sequenceId === undefined) {
jobInfo.sequenceId = record.sequenceId;
}
jobInfo.message = record.message;
map.set(record.trialJobId, jobInfo);
}

Expand Down
8 changes: 0 additions & 8 deletions ts/nni_manager/core/nnimanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,6 @@ class NNIManager implements Manager {
return this.status;
}

public getTrialJobMessage(trialJobId: string): string | undefined {
const trialJob = this.trialJobs.get(trialJobId);
if (trialJob !== undefined){
return trialJob.message
}
return undefined
}

public async listTrialJobs(status?: TrialJobStatus): Promise<TrialJobInfo[]> {
return this.dataStore.listTrialJobs(status);
}
Expand Down
10 changes: 6 additions & 4 deletions ts/nni_manager/core/sqlDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { TrialJobDetail } from '../common/trainingService';


const createTables: string = `
create table TrialJobEvent (timestamp integer, trialJobId text, event text, data text, logPath text, sequenceId integer);
create table TrialJobEvent (timestamp integer, trialJobId text, event text, data text, logPath text, sequenceId integer, message text);
create index TrialJobEvent_trialJobId on TrialJobEvent(trialJobId);
create index TrialJobEvent_event on TrialJobEvent(event);
Expand Down Expand Up @@ -62,7 +62,8 @@ function loadTrialJobEvent(row: any): TrialJobEventRecord {
event: row.event,
data: row.data === null ? undefined : row.data,
logPath: row.logPath === null ? undefined : row.logPath,
sequenceId: row.sequenceId === null ? undefined : row.sequenceId
sequenceId: row.sequenceId === null ? undefined : row.sequenceId,
message: row.message === null ? undefined: row.message
};
}

Expand Down Expand Up @@ -163,10 +164,11 @@ class SqlDB implements Database {

public storeTrialJobEvent(
event: TrialJobEvent, trialJobId: string, timestamp: number, hyperParameter?: string, jobDetail?: TrialJobDetail): Promise<void> {
const sql: string = 'insert into TrialJobEvent values (?,?,?,?,?,?)';
const sql: string = 'insert into TrialJobEvent values (?,?,?,?,?,?,?)';
const logPath: string | undefined = jobDetail === undefined ? undefined : jobDetail.url;
const sequenceId: number | undefined = jobDetail === undefined ? undefined : jobDetail.form.sequenceId;
const args: any[] = [timestamp, trialJobId, event, hyperParameter, logPath, sequenceId];
const message: string | undefined = jobDetail === undefined ? undefined : jobDetail.message;
const args: any[] = [timestamp, trialJobId, event, hyperParameter, logPath, sequenceId, message];

this.log.trace(`storeTrialJobEvent: SQL: ${sql}, args: ${JSON.stringify(args)}`);
const deferred: Deferred<void> = new Deferred<void>();
Expand Down
10 changes: 0 additions & 10 deletions ts/nni_manager/rest_server/restHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ class NNIRestHandler {
this.nniManager.listTrialJobs(req.query.status).then((jobInfos: TrialJobInfo[]) => {
jobInfos.forEach((trialJob: TrialJobInfo) => {
this.setErrorPathForFailedJob(trialJob);
this.setMessageforJob(trialJob);
});
res.send(jobInfos);
}).catch((err: Error) => {
Expand All @@ -226,7 +225,6 @@ class NNIRestHandler {
router.get('/trial-jobs/:id', (req: Request, res: Response) => {
this.nniManager.getTrialJob(req.params.id).then((jobDetail: TrialJobInfo) => {
const jobInfo: TrialJobInfo = this.setErrorPathForFailedJob(jobDetail);
this.setMessageforJob(jobInfo);
res.send(jobInfo);
}).catch((err: Error) => {
this.handleError(err, res);
Expand Down Expand Up @@ -327,14 +325,6 @@ class NNIRestHandler {

return jobInfo;
}

private setMessageforJob(jobInfo: TrialJobInfo): TrialJobInfo {
if (jobInfo === undefined){
return jobInfo
}
jobInfo.message = this.nniManager.getTrialJobMessage(jobInfo.trialJobId);
return jobInfo
}
}

export function createRestHandler(rs: NNIRestServer): Router {
Expand Down
4 changes: 0 additions & 4 deletions ts/nni_manager/rest_server/test/mockedNNIManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ export class MockedNNIManager extends Manager {
return deferred.promise;
}

public getTrialJobMessage(trialJobId: string): string | undefined {
return "TEST-MESSAGE"
}

public stopExperiment(): Promise<void> {
throw new MethodNotImplementedError();
}
Expand Down
1 change: 1 addition & 0 deletions ts/nni_manager/training_service/reusable/trial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class TrialDetail implements TrialJobDetail {
public form: TrialJobApplicationForm;
public isEarlyStopped?: boolean;
public environment?: EnvironmentInformation;
public message?: string;

// init settings of trial
public settings = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ class TrialDispatcher implements TrainingService {
if (environment.environmentService === undefined) {
throw new Error(`${environment.id} does not has environment service!`);
}

trial.url = environment.trackingUrl;
const environmentStatus = environment.status;

Expand Down Expand Up @@ -704,6 +703,7 @@ class TrialDispatcher implements TrainingService {
if (environment.environmentService === undefined) {
throw new Error(`${environment.id} environmentService not initialized!`);
}
trial.message = `Platform: ${environment.environmentService.getName}, environment: ${environment.id}`;
if (environment.environmentService.hasStorageService) {
const storageService = component.get<StorageService>(StorageService);
trial.workingDirectory = storageService.joinPath('trials', trial.id);
Expand Down

0 comments on commit bd2543e

Please sign in to comment.