Unverified Commit 543239c6 authored by SparkSnail's avatar SparkSnail Committed by GitHub
Browse files

Merge pull request #220 from microsoft/master

merge master
parents 32efaa36 659480f2
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// Licensed under the MIT license. // Licensed under the MIT license.
'use strict'; 'use strict';
/* tslint:disable:no-any */
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
...@@ -84,7 +83,7 @@ class Logger { ...@@ -84,7 +83,7 @@ class Logger {
this.readonly = isReadonly(); this.readonly = isReadonly();
} }
public close() { public close(): void {
this.writable.destroy(); this.writable.destroy();
} }
......
...@@ -18,7 +18,7 @@ class ObservableTimer { ...@@ -18,7 +18,7 @@ class ObservableTimer {
return this.observableSource.subscribe(onNext, onError, onCompleted); return this.observableSource.subscribe(onNext, onError, onCompleted);
} }
public unsubscribe( subscription : Rx.IDisposable) { public unsubscribe( subscription: Rx.IDisposable): void {
if(typeof subscription !== undefined) { if(typeof subscription !== undefined) {
subscription.dispose(); subscription.dispose();
} }
......
...@@ -34,7 +34,6 @@ export abstract class RestServer { ...@@ -34,7 +34,6 @@ export abstract class RestServer {
} }
get endPoint(): string { get endPoint(): string {
// tslint:disable-next-line:no-http-string
return `http://${this.hostName}:${this.port}`; return `http://${this.hostName}:${this.port}`;
} }
......
...@@ -16,11 +16,9 @@ import { Container } from 'typescript-ioc'; ...@@ -16,11 +16,9 @@ import { Container } from 'typescript-ioc';
import * as util from 'util'; import * as util from 'util';
import { Database, DataStore } from './datastore'; import { Database, DataStore } from './datastore';
import { ExperimentStartupInfo, getExperimentId, getExperimentStartupInfo, setExperimentStartupInfo } from './experimentStartupInfo'; import { ExperimentStartupInfo, getExperimentStartupInfo, setExperimentStartupInfo } from './experimentStartupInfo';
import { Manager } from './manager'; import { Manager } from './manager';
import { TrialConfig } from '../training_service/common/trialConfig';
import { HyperParameters, TrainingService, TrialJobStatus } from './trainingService'; import { HyperParameters, TrainingService, TrialJobStatus } from './trainingService';
import { getLogger } from './log';
function getExperimentRootDir(): string { function getExperimentRootDir(): string {
return getExperimentStartupInfo() return getExperimentStartupInfo()
...@@ -118,7 +116,6 @@ function uniqueString(len: number): string { ...@@ -118,7 +116,6 @@ function uniqueString(len: number): string {
function randomSelect<T>(a: T[]): T { function randomSelect<T>(a: T[]): T {
assert(a !== undefined); assert(a !== undefined);
// tslint:disable-next-line:insecure-random
return a[Math.floor(Math.random() * a.length)]; return a[Math.floor(Math.random() * a.length)];
} }
function parseArg(names: string[]): string { function parseArg(names: string[]): string {
...@@ -236,11 +233,11 @@ function getMsgDispatcherCommand(tuner: any, assessor: any, advisor: any, multiP ...@@ -236,11 +233,11 @@ function getMsgDispatcherCommand(tuner: any, assessor: any, advisor: any, multiP
* Generate parameter file name based on HyperParameters object * Generate parameter file name based on HyperParameters object
* @param hyperParameters HyperParameters instance * @param hyperParameters HyperParameters instance
*/ */
function generateParamFileName(hyperParameters : HyperParameters): string { function generateParamFileName(hyperParameters: HyperParameters): string {
assert(hyperParameters !== undefined); assert(hyperParameters !== undefined);
assert(hyperParameters.index >= 0); assert(hyperParameters.index >= 0);
let paramFileName : string; let paramFileName: string;
if(hyperParameters.index == 0) { if(hyperParameters.index == 0) {
paramFileName = 'parameter.cfg'; paramFileName = 'parameter.cfg';
} else { } else {
...@@ -283,7 +280,7 @@ function cleanupUnitTest(): void { ...@@ -283,7 +280,7 @@ function cleanupUnitTest(): void {
Container.restore(ExperimentStartupInfo); Container.restore(ExperimentStartupInfo);
} }
let cachedipv4Address : string = ''; let cachedipv4Address: string = '';
/** /**
* Get IPv4 address of current machine * Get IPv4 address of current machine
*/ */
...@@ -325,15 +322,15 @@ function getJobCancelStatus(isEarlyStopped: boolean): TrialJobStatus { ...@@ -325,15 +322,15 @@ function getJobCancelStatus(isEarlyStopped: boolean): TrialJobStatus {
* Utility method to calculate file numbers under a directory, recursively * Utility method to calculate file numbers under a directory, recursively
* @param directory directory name * @param directory directory name
*/ */
function countFilesRecursively(directory: string, timeoutMilliSeconds?: number): Promise<number> { function countFilesRecursively(directory: string): Promise<number> {
if(!fs.existsSync(directory)) { if(!fs.existsSync(directory)) {
throw Error(`Direcotory ${directory} doesn't exist`); throw Error(`Direcotory ${directory} doesn't exist`);
} }
const deferred: Deferred<number> = new Deferred<number>(); const deferred: Deferred<number> = new Deferred<number>();
let timeoutId : NodeJS.Timer let timeoutId: NodeJS.Timer
const delayTimeout : Promise<number> = new Promise((resolve : Function, reject : Function) : void => { const delayTimeout: Promise<number> = new Promise((resolve: Function, reject: Function): void => {
// Set timeout and reject the promise once reach timeout (5 seconds) // Set timeout and reject the promise once reach timeout (5 seconds)
timeoutId = setTimeout(() => { timeoutId = setTimeout(() => {
reject(new Error(`Timeout: path ${directory} has too many files`)); reject(new Error(`Timeout: path ${directory} has too many files`));
...@@ -359,7 +356,7 @@ function countFilesRecursively(directory: string, timeoutMilliSeconds?: number): ...@@ -359,7 +356,7 @@ function countFilesRecursively(directory: string, timeoutMilliSeconds?: number):
} }
function validateFileName(fileName: string): boolean { function validateFileName(fileName: string): boolean {
let pattern: string = '^[a-z0-9A-Z\._-]+$'; const pattern: string = '^[a-z0-9A-Z._-]+$';
const validateResult = fileName.match(pattern); const validateResult = fileName.match(pattern);
if(validateResult) { if(validateResult) {
return true; return true;
...@@ -374,7 +371,7 @@ async function validateFileNameRecursively(directory: string): Promise<boolean> ...@@ -374,7 +371,7 @@ async function validateFileNameRecursively(directory: string): Promise<boolean>
const fileNameArray: string[] = fs.readdirSync(directory); const fileNameArray: string[] = fs.readdirSync(directory);
let result = true; let result = true;
for(var name of fileNameArray){ for(const name of fileNameArray){
const fullFilePath: string = path.join(directory, name); const fullFilePath: string = path.join(directory, name);
try { try {
// validate file names and directory names // validate file names and directory names
...@@ -396,7 +393,7 @@ async function validateFileNameRecursively(directory: string): Promise<boolean> ...@@ -396,7 +393,7 @@ async function validateFileNameRecursively(directory: string): Promise<boolean>
* get the version of current package * get the version of current package
*/ */
async function getVersion(): Promise<string> { async function getVersion(): Promise<string> {
const deferred : Deferred<string> = new Deferred<string>(); const deferred: Deferred<string> = new Deferred<string>();
import(path.join(__dirname, '..', 'package.json')).then((pkg)=>{ import(path.join(__dirname, '..', 'package.json')).then((pkg)=>{
deferred.resolve(pkg.version); deferred.resolve(pkg.version);
}).catch((error)=>{ }).catch((error)=>{
...@@ -430,7 +427,7 @@ function getTunerProc(command: string, stdio: StdioOptions, newCwd: string, newE ...@@ -430,7 +427,7 @@ function getTunerProc(command: string, stdio: StdioOptions, newCwd: string, newE
* judge whether the process is alive * judge whether the process is alive
*/ */
async function isAlive(pid: any): Promise<boolean> { async function isAlive(pid: any): Promise<boolean> {
let deferred : Deferred<boolean> = new Deferred<boolean>(); const deferred: Deferred<boolean> = new Deferred<boolean>();
let alive: boolean = false; let alive: boolean = false;
if (process.platform === 'win32') { if (process.platform === 'win32') {
try { try {
...@@ -440,6 +437,7 @@ async function isAlive(pid: any): Promise<boolean> { ...@@ -440,6 +437,7 @@ async function isAlive(pid: any): Promise<boolean> {
} }
} }
catch (error) { catch (error) {
//ignore
} }
} }
else { else {
...@@ -458,7 +456,7 @@ async function isAlive(pid: any): Promise<boolean> { ...@@ -458,7 +456,7 @@ async function isAlive(pid: any): Promise<boolean> {
* kill process * kill process
*/ */
async function killPid(pid: any): Promise<void> { async function killPid(pid: any): Promise<void> {
let deferred : Deferred<void> = new Deferred<void>(); const deferred: Deferred<void> = new Deferred<void>();
try { try {
if (process.platform === "win32") { if (process.platform === "win32") {
await cpp.exec(`cmd.exe /c taskkill /PID ${pid} /F`); await cpp.exec(`cmd.exe /c taskkill /PID ${pid} /F`);
......
...@@ -159,7 +159,7 @@ class NNIDataStore implements DataStore { ...@@ -159,7 +159,7 @@ class NNIDataStore implements DataStore {
public async exportTrialHpConfigs(): Promise<string> { public async exportTrialHpConfigs(): Promise<string> {
const jobs: TrialJobInfo[] = await this.listTrialJobs(); const jobs: TrialJobInfo[] = await this.listTrialJobs();
let exportedData: ExportedDataFormat[] = []; const exportedData: ExportedDataFormat[] = [];
for (const job of jobs) { for (const job of jobs) {
if (job.hyperParameters && job.finalMetricData) { if (job.hyperParameters && job.finalMetricData) {
if (job.hyperParameters.length === 1 && job.finalMetricData.length === 1) { if (job.hyperParameters.length === 1 && job.finalMetricData.length === 1) {
...@@ -172,18 +172,18 @@ class NNIDataStore implements DataStore { ...@@ -172,18 +172,18 @@ class NNIDataStore implements DataStore {
}; };
exportedData.push(oneEntry); exportedData.push(oneEntry);
} else { } else {
let paraMap: Map<number, Object> = new Map(); const paraMap: Map<number, Record<string, any>> = new Map();
let metricMap: Map<number, Object> = new Map(); const metricMap: Map<number, Record<string, any>> = new Map();
for (const eachPara of job.hyperParameters) { for (const eachPara of job.hyperParameters) {
const parameters: HyperParameterFormat = <HyperParameterFormat>JSON.parse(eachPara); const parameters: HyperParameterFormat = <HyperParameterFormat>JSON.parse(eachPara);
paraMap.set(parameters.parameter_id, parameters.parameters); paraMap.set(parameters.parameter_id, parameters.parameters);
} }
for (const eachMetric of job.finalMetricData) { for (const eachMetric of job.finalMetricData) {
const value: Object = JSON.parse(eachMetric.data); const value: Record<string, any> = JSON.parse(eachMetric.data);
metricMap.set(Number(eachMetric.parameterId), value); metricMap.set(Number(eachMetric.parameterId), value);
} }
paraMap.forEach((value: Object, key: number) => { paraMap.forEach((value: Record<string, any>, key: number) => {
const metricValue: Object | undefined = metricMap.get(key); const metricValue: Record<string, any> | undefined = metricMap.get(key);
if (metricValue) { if (metricValue) {
const oneEntry: ExportedDataFormat = { const oneEntry: ExportedDataFormat = {
parameter: value, parameter: value,
...@@ -201,7 +201,7 @@ class NNIDataStore implements DataStore { ...@@ -201,7 +201,7 @@ class NNIDataStore implements DataStore {
} }
public async getImportedData(): Promise<string[]> { public async getImportedData(): Promise<string[]> {
let importedData: string[] = []; const importedData: string[] = [];
const importDataEvents: TrialJobEventRecord[] = await this.db.queryTrialJobEvent(undefined, 'IMPORT_DATA'); const importDataEvents: TrialJobEventRecord[] = await this.db.queryTrialJobEvent(undefined, 'IMPORT_DATA');
for (const event of importDataEvents) { for (const event of importDataEvents) {
if (event.data) { if (event.data) {
...@@ -304,7 +304,6 @@ class NNIDataStore implements DataStore { ...@@ -304,7 +304,6 @@ class NNIDataStore implements DataStore {
} }
} }
// 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'); this.log.debug('getTrialJobsByReplayEvents begin');
...@@ -329,6 +328,7 @@ class NNIDataStore implements DataStore { ...@@ -329,6 +328,7 @@ class NNIDataStore implements DataStore {
if (!jobInfo) { if (!jobInfo) {
throw new Error('Empty JobInfo'); throw new Error('Empty JobInfo');
} }
/* eslint-disable no-fallthrough */
switch (record.event) { switch (record.event) {
case 'RUNNING': case 'RUNNING':
if (record.timestamp !== undefined) { if (record.timestamp !== undefined) {
...@@ -358,6 +358,7 @@ class NNIDataStore implements DataStore { ...@@ -358,6 +358,7 @@ class NNIDataStore implements DataStore {
} }
default: default:
} }
/* eslint-enable no-fallthrough */
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); const newHParam: any = this.parseHyperParameter(record.data);
......
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
'use strict'; 'use strict';
import * as assert from 'assert'; import * as assert from 'assert';
import * as cpp from 'child-process-promise'; import { ChildProcess, StdioOptions } from 'child_process';
import { ChildProcess, spawn, StdioOptions } from 'child_process';
import { Deferred } from 'ts-deferred'; import { Deferred } from 'ts-deferred';
import * as component from '../common/component'; import * as component from '../common/component';
import { DataStore, MetricDataRecord, MetricType, TrialJobInfo } from '../common/datastore'; import { DataStore, MetricDataRecord, MetricType, TrialJobInfo } from '../common/datastore';
...@@ -21,7 +20,7 @@ import { ...@@ -21,7 +20,7 @@ import {
} from '../common/trainingService'; } from '../common/trainingService';
import { delay, getCheckpointDir, getExperimentRootDir, getLogDir, getMsgDispatcherCommand, mkDirP, getTunerProc, getLogLevel, isAlive, killPid } from '../common/utils'; import { delay, getCheckpointDir, getExperimentRootDir, getLogDir, getMsgDispatcherCommand, mkDirP, getTunerProc, getLogLevel, isAlive, killPid } from '../common/utils';
import { import {
ADD_CUSTOMIZED_TRIAL_JOB, INITIALIZE, INITIALIZED, KILL_TRIAL_JOB, NEW_TRIAL_JOB, NO_MORE_TRIAL_JOBS, PING, INITIALIZE, INITIALIZED, KILL_TRIAL_JOB, NEW_TRIAL_JOB, NO_MORE_TRIAL_JOBS, PING,
REPORT_METRIC_DATA, REQUEST_TRIAL_JOBS, SEND_TRIAL_JOB_PARAMETER, TERMINATE, TRIAL_END, UPDATE_SEARCH_SPACE, IMPORT_DATA REPORT_METRIC_DATA, REQUEST_TRIAL_JOBS, SEND_TRIAL_JOB_PARAMETER, TERMINATE, TRIAL_END, UPDATE_SEARCH_SPACE, IMPORT_DATA
} from './commands'; } from './commands';
import { createDispatcherInterface, IpcInterface } from './ipcInterface'; import { createDispatcherInterface, IpcInterface } from './ipcInterface';
...@@ -64,7 +63,7 @@ class NNIManager implements Manager { ...@@ -64,7 +63,7 @@ class NNIManager implements Manager {
status: 'INITIALIZED', status: 'INITIALIZED',
errors: [] errors: []
}; };
this.trialJobMetricListener = (metric: TrialJobMetric) => { this.trialJobMetricListener = (metric: TrialJobMetric): void => {
this.onTrialJobMetrics(metric).catch((err: Error) => { this.onTrialJobMetrics(metric).catch((err: Error) => {
this.criticalError(NNIError.FromError(err, 'Job metrics error: ')); this.criticalError(NNIError.FromError(err, 'Job metrics error: '));
}); });
...@@ -123,8 +122,8 @@ class NNIManager implements Manager { ...@@ -123,8 +122,8 @@ class NNIManager implements Manager {
// TODO: NNI manager should not peek tuner's internal protocol, let's refactor this later // TODO: NNI manager should not peek tuner's internal protocol, let's refactor this later
const packedParameter = { const packedParameter = {
parameter_id: null, parameter_id: null, // eslint-disable-line @typescript-eslint/camelcase
parameter_source: 'customized', parameter_source: 'customized', // eslint-disable-line @typescript-eslint/camelcase
parameters: JSON.parse(hyperParams) parameters: JSON.parse(hyperParams)
} }
...@@ -235,10 +234,10 @@ class NNIManager implements Manager { ...@@ -235,10 +234,10 @@ class NNIManager implements Manager {
// Collect generated trials and imported trials // Collect generated trials and imported trials
const finishedTrialData: string = await this.exportData(); const finishedTrialData: string = await this.exportData();
const importedData: string[] = await this.dataStore.getImportedData(); const importedData: string[] = await this.dataStore.getImportedData();
let trialData: Object[] = JSON.parse(finishedTrialData); let trialData: Record<string, any>[] = JSON.parse(finishedTrialData);
for (const oneImportedData of importedData) { for (const oneImportedData of importedData) {
// do not deduplicate // do not deduplicate
trialData = trialData.concat(<Object[]>JSON.parse(oneImportedData)); trialData = trialData.concat(<Record<string, any>[]>JSON.parse(oneImportedData));
} }
this.trialDataForTuner = JSON.stringify(trialData); this.trialDataForTuner = JSON.stringify(trialData);
...@@ -361,7 +360,7 @@ class NNIManager implements Manager { ...@@ -361,7 +360,7 @@ class NNIManager implements Manager {
includeIntermediateResultsEnv = this.experimentProfile.params.tuner.includeIntermediateResults; includeIntermediateResultsEnv = this.experimentProfile.params.tuner.includeIntermediateResults;
} }
let nniEnv = { const nniEnv = {
NNI_MODE: mode, NNI_MODE: mode,
NNI_CHECKPOINT_DIRECTORY: dataDirectory, NNI_CHECKPOINT_DIRECTORY: dataDirectory,
NNI_LOG_DIRECTORY: getLogDir(), NNI_LOG_DIRECTORY: getLogDir(),
...@@ -369,7 +368,7 @@ class NNIManager implements Manager { ...@@ -369,7 +368,7 @@ class NNIManager implements Manager {
NNI_INCLUDE_INTERMEDIATE_RESULTS: includeIntermediateResultsEnv, NNI_INCLUDE_INTERMEDIATE_RESULTS: includeIntermediateResultsEnv,
CUDA_VISIBLE_DEVICES: this.getGpuEnvvarValue() CUDA_VISIBLE_DEVICES: this.getGpuEnvvarValue()
}; };
let newEnv = Object.assign({}, process.env, nniEnv); const newEnv = Object.assign({}, process.env, nniEnv);
const tunerProc: ChildProcess = getTunerProc(command,stdio,newCwd,newEnv); const tunerProc: ChildProcess = getTunerProc(command,stdio,newCwd,newEnv);
this.dispatcherPid = tunerProc.pid; this.dispatcherPid = tunerProc.pid;
this.dispatcher = createDispatcherInterface(tunerProc); this.dispatcher = createDispatcherInterface(tunerProc);
...@@ -502,9 +501,9 @@ class NNIManager implements Manager { ...@@ -502,9 +501,9 @@ class NNIManager implements Manager {
finishedTrialJobNum++; finishedTrialJobNum++;
hyperParams = trialJobDetail.form.hyperParameters.value; hyperParams = trialJobDetail.form.hyperParameters.value;
this.dispatcher.sendCommand(TRIAL_END, JSON.stringify({ this.dispatcher.sendCommand(TRIAL_END, JSON.stringify({
trial_job_id: trialJobDetail.id, trial_job_id: trialJobDetail.id, // eslint-disable-line @typescript-eslint/camelcase
event: trialJobDetail.status, event: trialJobDetail.status,
hyper_params: hyperParams hyper_params: hyperParams // eslint-disable-line @typescript-eslint/camelcase
})); }));
break; break;
case 'FAILED': case 'FAILED':
...@@ -515,9 +514,9 @@ class NNIManager implements Manager { ...@@ -515,9 +514,9 @@ class NNIManager implements Manager {
finishedTrialJobNum++; finishedTrialJobNum++;
hyperParams = trialJobDetail.form.hyperParameters.value; hyperParams = trialJobDetail.form.hyperParameters.value;
this.dispatcher.sendCommand(TRIAL_END, JSON.stringify({ this.dispatcher.sendCommand(TRIAL_END, JSON.stringify({
trial_job_id: trialJobDetail.id, trial_job_id: trialJobDetail.id, // eslint-disable-line @typescript-eslint/camelcase
event: trialJobDetail.status, event: trialJobDetail.status,
hyper_params: hyperParams hyper_params: hyperParams // eslint-disable-line @typescript-eslint/camelcase
})); }));
break; break;
case 'WAITING': case 'WAITING':
...@@ -695,7 +694,7 @@ class NNIManager implements Manager { ...@@ -695,7 +694,7 @@ class NNIManager implements Manager {
private async onTunerCommand(commandType: string, content: string): Promise<void> { private async onTunerCommand(commandType: string, content: string): Promise<void> {
this.log.info(`NNIManager received command from dispatcher: ${commandType}, ${content}`); this.log.info(`NNIManager received command from dispatcher: ${commandType}, ${content}`);
switch (commandType) { switch (commandType) {
case INITIALIZED: case INITIALIZED: {
// Tuner is intialized, search space is set, request tuner to generate hyper parameters // Tuner is intialized, search space is set, request tuner to generate hyper parameters
if (this.trialDataForTuner.length > 0) { if (this.trialDataForTuner.length > 0) {
if (this.dispatcher === undefined) { if (this.dispatcher === undefined) {
...@@ -705,7 +704,8 @@ class NNIManager implements Manager { ...@@ -705,7 +704,8 @@ class NNIManager implements Manager {
} }
this.requestTrialJobs(this.experimentProfile.params.trialConcurrency); this.requestTrialJobs(this.experimentProfile.params.trialConcurrency);
break; break;
case NEW_TRIAL_JOB: }
case NEW_TRIAL_JOB: {
if (this.status.status === 'TUNER_NO_MORE_TRIAL') { if (this.status.status === 'TUNER_NO_MORE_TRIAL') {
this.log.warning('It is not supposed to receive more trials after NO_MORE_TRIAL is set'); this.log.warning('It is not supposed to receive more trials after NO_MORE_TRIAL is set');
this.setStatus('RUNNING'); this.setStatus('RUNNING');
...@@ -719,7 +719,8 @@ class NNIManager implements Manager { ...@@ -719,7 +719,8 @@ class NNIManager implements Manager {
}; };
this.waitingTrials.push(form); this.waitingTrials.push(form);
break; break;
case SEND_TRIAL_JOB_PARAMETER: }
case SEND_TRIAL_JOB_PARAMETER: {
const tunerCommand: any = JSON.parse(content); const tunerCommand: any = JSON.parse(content);
assert(tunerCommand.parameter_index >= 0); assert(tunerCommand.parameter_index >= 0);
assert(tunerCommand.trial_job_id !== undefined); assert(tunerCommand.trial_job_id !== undefined);
...@@ -739,15 +740,18 @@ class NNIManager implements Manager { ...@@ -739,15 +740,18 @@ class NNIManager implements Manager {
'ADD_HYPERPARAMETER', tunerCommand.trial_job_id, content, undefined); 'ADD_HYPERPARAMETER', tunerCommand.trial_job_id, content, undefined);
} }
break; break;
case NO_MORE_TRIAL_JOBS: }
case NO_MORE_TRIAL_JOBS: {
if (!['ERROR', 'STOPPING', 'STOPPED'].includes(this.status.status)) { if (!['ERROR', 'STOPPING', 'STOPPED'].includes(this.status.status)) {
this.setStatus('TUNER_NO_MORE_TRIAL'); this.setStatus('TUNER_NO_MORE_TRIAL');
} }
break; break;
case KILL_TRIAL_JOB: }
case KILL_TRIAL_JOB: {
this.log.info(`cancelTrialJob: ${JSON.parse(content)}`); this.log.info(`cancelTrialJob: ${JSON.parse(content)}`);
await this.trainingService.cancelTrialJob(JSON.parse(content), true); await this.trainingService.cancelTrialJob(JSON.parse(content), true);
break; break;
}
default: default:
throw new Error('Error: unsupported command type from tuner'); throw new Error('Error: unsupported command type from tuner');
} }
......
...@@ -20,7 +20,6 @@ import { getLogger, Logger } from '../common/log'; ...@@ -20,7 +20,6 @@ import { getLogger, Logger } from '../common/log';
import { ExperimentProfile } from '../common/manager'; import { ExperimentProfile } from '../common/manager';
import { TrialJobDetail } from '../common/trainingService'; import { TrialJobDetail } from '../common/trainingService';
/* tslint:disable:no-any */
const createTables: string = ` 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);
...@@ -91,7 +90,6 @@ class SqlDB implements Database { ...@@ -91,7 +90,6 @@ class SqlDB implements Database {
this.log.debug(`Database directory: ${dbDir}`); this.log.debug(`Database directory: ${dbDir}`);
assert(fs.existsSync(dbDir)); assert(fs.existsSync(dbDir));
// tslint:disable-next-line:no-bitwise
const mode: number = createNew ? (sqlite3.OPEN_CREATE | sqlite3.OPEN_READWRITE) : sqlite3.OPEN_READWRITE; const mode: number = createNew ? (sqlite3.OPEN_CREATE | sqlite3.OPEN_READWRITE) : sqlite3.OPEN_READWRITE;
const dbFileName: string = path.join(dbDir, 'nni.sqlite'); const dbFileName: string = path.join(dbDir, 'nni.sqlite');
......
...@@ -107,7 +107,6 @@ describe('Unit test for dataStore', () => { ...@@ -107,7 +107,6 @@ describe('Unit test for dataStore', () => {
} }
]; ];
// tslint:disable-next-line:no-any
const metricsData: any = [ const metricsData: any = [
{ {
trial_job_id: '111', trial_job_id: '111',
......
...@@ -47,7 +47,7 @@ function startProcess(): void { ...@@ -47,7 +47,7 @@ function startProcess(): void {
// create IPC interface // create IPC interface
dispatcher = createDispatcherInterface(proc); dispatcher = createDispatcherInterface(proc);
(<IpcInterface>dispatcher).onCommand((commandType: string, content: string): void => { (<IpcInterface>dispatcher).onCommand((commandType: string, content: string): void => {
console.log(commandType, content); // tslint:disable-line:no-console console.log(commandType, content);
}); });
} }
......
...@@ -70,19 +70,17 @@ const metrics: MetricDataRecord[] = [ ...@@ -70,19 +70,17 @@ const metrics: MetricDataRecord[] = [
{ timestamp: Date.now(), trialJobId: 'C', parameterId: '2', type: 'FINAL', sequence: 0, data: 2.2 } // 5 { timestamp: Date.now(), trialJobId: 'C', parameterId: '2', type: 'FINAL', sequence: 0, data: 2.2 } // 5
]; ];
// tslint:disable-next-line:no-any
function assertRecordEqual(record: any, value: any): void { function assertRecordEqual(record: any, value: any): void {
assert.ok(record.timestamp > new Date(2018, 6, 1).getTime()); assert.ok(record.timestamp > new Date(2018, 6, 1).getTime());
assert.ok(record.timestamp < Date.now()); assert.ok(record.timestamp < Date.now());
for (const key in value) { // tslint:disable-line:no-for-in for (const key in value) {
if (key !== 'timestamp') { if (key !== 'timestamp') {
assert.equal(record[key], value[key]); assert.equal(record[key], value[key]);
} }
} }
} }
// tslint:disable-next-line:no-any
function assertRecordsEqual(records: any[], inputs: any[], indices: number[]): void { function assertRecordsEqual(records: any[], inputs: any[], indices: number[]): void {
assert.equal(records.length, indices.length); assert.equal(records.length, indices.length);
for (let i: number = 0; i < records.length; i++) { for (let i: number = 0; i < records.length; i++) {
......
...@@ -55,7 +55,7 @@ async function initContainer(platformMode: string, logFileName?: string): Promis ...@@ -55,7 +55,7 @@ async function initContainer(platformMode: string, logFileName?: string): Promis
.to(FrameworkControllerTrainingService) .to(FrameworkControllerTrainingService)
.scope(Scope.Singleton); .scope(Scope.Singleton);
} else { } else {
throw new Error(`Error: unsupported mode: ${mode}`); throw new Error(`Error: unsupported mode: ${platformMode}`);
} }
Container.bind(Manager) Container.bind(Manager)
.to(NNIManager) .to(NNIManager)
......
...@@ -54,8 +54,6 @@ ...@@ -54,8 +54,6 @@
"rmdir": "^1.2.0", "rmdir": "^1.2.0",
"tmp": "^0.0.33", "tmp": "^0.0.33",
"ts-node": "^7.0.0", "ts-node": "^7.0.0",
"tslint": "^5.12.0",
"tslint-microsoft-contrib": "^6.0.0",
"typescript": "^3.2.2" "typescript": "^3.2.2"
}, },
"resolutions": { "resolutions": {
......
...@@ -11,7 +11,7 @@ import { DataStore, MetricDataRecord, TrialJobInfo } from '../common/datastore'; ...@@ -11,7 +11,7 @@ import { DataStore, MetricDataRecord, TrialJobInfo } from '../common/datastore';
import { NNIError, NNIErrorNames } from '../common/errors'; import { NNIError, NNIErrorNames } from '../common/errors';
import { isNewExperiment, isReadonly } from '../common/experimentStartupInfo'; import { isNewExperiment, isReadonly } from '../common/experimentStartupInfo';
import { getLogger, Logger } from '../common/log'; import { getLogger, Logger } from '../common/log';
import { ExperimentProfile, Manager, TrialJobStatistics, ExperimentStartUpMode } from '../common/manager'; import { ExperimentProfile, Manager, TrialJobStatistics } from '../common/manager';
import { ValidationSchemas } from './restValidationSchemas'; import { ValidationSchemas } from './restValidationSchemas';
import { NNIRestServer } from './nniRestServer'; import { NNIRestServer } from './nniRestServer';
import { getVersion } from '../common/utils'; import { getVersion } from '../common/utils';
...@@ -32,7 +32,6 @@ class NNIRestHandler { ...@@ -32,7 +32,6 @@ class NNIRestHandler {
public createRestHandler(): Router { public createRestHandler(): Router {
const router: Router = Router(); const router: Router = Router();
// tslint:disable-next-line:typedef
router.use((req: Request, res: Response, next) => { router.use((req: Request, res: Response, next) => {
this.log.debug(`${req.method}: ${req.url}: body:\n${JSON.stringify(req.body, undefined, 4)}`); this.log.debug(`${req.method}: ${req.url}: body:\n${JSON.stringify(req.body, undefined, 4)}`);
res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Origin', '*');
...@@ -72,7 +71,7 @@ class NNIRestHandler { ...@@ -72,7 +71,7 @@ class NNIRestHandler {
return router; return router;
} }
private handle_error(err: Error, res: Response, isFatal: boolean = false, errorCode: number = 500): void { private handleError(err: Error, res: Response, isFatal: boolean = false, errorCode: number = 500): void {
if (err instanceof NNIError && err.name === NNIErrorNames.NOT_FOUND) { if (err instanceof NNIError && err.name === NNIErrorNames.NOT_FOUND) {
res.status(404); res.status(404);
} else { } else {
...@@ -105,7 +104,7 @@ class NNIRestHandler { ...@@ -105,7 +104,7 @@ class NNIRestHandler {
ds.init().then(() => { ds.init().then(() => {
res.send(this.nniManager.getStatus()); res.send(this.nniManager.getStatus());
}).catch(async (err: Error) => { }).catch(async (err: Error) => {
this.handle_error(err, res); this.handleError(err, res);
this.log.error(err.message); this.log.error(err.message);
this.log.error(`Datastore initialize failed, stopping rest server...`); this.log.error(`Datastore initialize failed, stopping rest server...`);
await this.restServer.stop(); await this.restServer.stop();
...@@ -118,7 +117,7 @@ class NNIRestHandler { ...@@ -118,7 +117,7 @@ class NNIRestHandler {
this.nniManager.getExperimentProfile().then((profile: ExperimentProfile) => { this.nniManager.getExperimentProfile().then((profile: ExperimentProfile) => {
res.send(profile); res.send(profile);
}).catch((err: Error) => { }).catch((err: Error) => {
this.handle_error(err, res); this.handleError(err, res);
}); });
}); });
} }
...@@ -128,7 +127,7 @@ class NNIRestHandler { ...@@ -128,7 +127,7 @@ class NNIRestHandler {
this.nniManager.updateExperimentProfile(req.body, req.query.update_type).then(() => { this.nniManager.updateExperimentProfile(req.body, req.query.update_type).then(() => {
res.send(); res.send();
}).catch((err: Error) => { }).catch((err: Error) => {
this.handle_error(err, res); this.handleError(err, res);
}); });
}); });
} }
...@@ -138,7 +137,7 @@ class NNIRestHandler { ...@@ -138,7 +137,7 @@ class NNIRestHandler {
this.nniManager.importData(JSON.stringify(req.body)).then(() => { this.nniManager.importData(JSON.stringify(req.body)).then(() => {
res.send(); res.send();
}).catch((err: Error) => { }).catch((err: Error) => {
this.handle_error(err, res); this.handleError(err, res);
}); });
}); });
} }
...@@ -148,18 +147,18 @@ class NNIRestHandler { ...@@ -148,18 +147,18 @@ class NNIRestHandler {
if (isNewExperiment()) { if (isNewExperiment()) {
this.nniManager.startExperiment(req.body).then((eid: string) => { this.nniManager.startExperiment(req.body).then((eid: string) => {
res.send({ res.send({
experiment_id: eid experiment_id: eid // eslint-disable-line @typescript-eslint/camelcase
}); });
}).catch((err: Error) => { }).catch((err: Error) => {
// Start experiment is a step of initialization, so any exception thrown is a fatal // Start experiment is a step of initialization, so any exception thrown is a fatal
this.handle_error(err, res); this.handleError(err, res);
}); });
} else { } else {
this.nniManager.resumeExperiment(isReadonly()).then(() => { this.nniManager.resumeExperiment(isReadonly()).then(() => {
res.send(); res.send();
}).catch((err: Error) => { }).catch((err: Error) => {
// Resume experiment is a step of initialization, so any exception thrown is a fatal // Resume experiment is a step of initialization, so any exception thrown is a fatal
this.handle_error(err, res); this.handleError(err, res);
}); });
} }
}); });
...@@ -170,7 +169,7 @@ class NNIRestHandler { ...@@ -170,7 +169,7 @@ class NNIRestHandler {
this.nniManager.getTrialJobStatistics().then((statistics: TrialJobStatistics[]) => { this.nniManager.getTrialJobStatistics().then((statistics: TrialJobStatistics[]) => {
res.send(statistics); res.send(statistics);
}).catch((err: Error) => { }).catch((err: Error) => {
this.handle_error(err, res); this.handleError(err, res);
}); });
}); });
} }
...@@ -179,7 +178,6 @@ class NNIRestHandler { ...@@ -179,7 +178,6 @@ class NNIRestHandler {
router.put( router.put(
'/experiment/cluster-metadata', expressJoi(ValidationSchemas.SETCLUSTERMETADATA), '/experiment/cluster-metadata', expressJoi(ValidationSchemas.SETCLUSTERMETADATA),
async (req: Request, res: Response) => { async (req: Request, res: Response) => {
// tslint:disable-next-line:no-any
const metadata: any = req.body; const metadata: any = req.body;
const keys: string[] = Object.keys(metadata); const keys: string[] = Object.keys(metadata);
try { try {
...@@ -189,7 +187,7 @@ class NNIRestHandler { ...@@ -189,7 +187,7 @@ class NNIRestHandler {
res.send(); res.send();
} catch (err) { } catch (err) {
// setClusterMetata is a step of initialization, so any exception thrown is a fatal // setClusterMetata is a step of initialization, so any exception thrown is a fatal
this.handle_error(NNIError.FromError(err), res, true); this.handleError(NNIError.FromError(err), res, true);
} }
}); });
} }
...@@ -202,7 +200,7 @@ class NNIRestHandler { ...@@ -202,7 +200,7 @@ class NNIRestHandler {
}); });
res.send(jobInfos); res.send(jobInfos);
}).catch((err: Error) => { }).catch((err: Error) => {
this.handle_error(err, res); this.handleError(err, res);
}); });
}); });
} }
...@@ -213,7 +211,7 @@ class NNIRestHandler { ...@@ -213,7 +211,7 @@ class NNIRestHandler {
const jobInfo: TrialJobInfo = this.setErrorPathForFailedJob(jobDetail); const jobInfo: TrialJobInfo = this.setErrorPathForFailedJob(jobDetail);
res.send(jobInfo); res.send(jobInfo);
}).catch((err: Error) => { }).catch((err: Error) => {
this.handle_error(err, res); this.handleError(err, res);
}); });
}); });
} }
...@@ -223,7 +221,7 @@ class NNIRestHandler { ...@@ -223,7 +221,7 @@ class NNIRestHandler {
this.nniManager.addCustomizedTrialJob(JSON.stringify(req.body)).then((sequenceId: number) => { this.nniManager.addCustomizedTrialJob(JSON.stringify(req.body)).then((sequenceId: number) => {
res.send({sequenceId}); res.send({sequenceId});
}).catch((err: Error) => { }).catch((err: Error) => {
this.handle_error(err, res); this.handleError(err, res);
}); });
}); });
} }
...@@ -233,7 +231,7 @@ class NNIRestHandler { ...@@ -233,7 +231,7 @@ class NNIRestHandler {
this.nniManager.cancelTrialJobByUser(req.params.id).then(() => { this.nniManager.cancelTrialJobByUser(req.params.id).then(() => {
res.send(); res.send();
}).catch((err: Error) => { }).catch((err: Error) => {
this.handle_error(err, res); this.handleError(err, res);
}); });
}); });
} }
...@@ -243,7 +241,7 @@ class NNIRestHandler { ...@@ -243,7 +241,7 @@ class NNIRestHandler {
this.nniManager.getMetricData(req.params.job_id, req.query.type).then((metricsData: MetricDataRecord[]) => { this.nniManager.getMetricData(req.params.job_id, req.query.type).then((metricsData: MetricDataRecord[]) => {
res.send(metricsData); res.send(metricsData);
}).catch((err: Error) => { }).catch((err: Error) => {
this.handle_error(err, res); this.handleError(err, res);
}); });
}); });
} }
...@@ -255,7 +253,7 @@ class NNIRestHandler { ...@@ -255,7 +253,7 @@ class NNIRestHandler {
this.nniManager.getMetricDataByRange(minSeqId, maxSeqId).then((metricsData: MetricDataRecord[]) => { this.nniManager.getMetricDataByRange(minSeqId, maxSeqId).then((metricsData: MetricDataRecord[]) => {
res.send(metricsData); res.send(metricsData);
}).catch((err: Error) => { }).catch((err: Error) => {
this.handle_error(err, res); this.handleError(err, res);
}); });
}); });
} }
...@@ -265,7 +263,7 @@ class NNIRestHandler { ...@@ -265,7 +263,7 @@ class NNIRestHandler {
this.nniManager.getLatestMetricData().then((metricsData: MetricDataRecord[]) => { this.nniManager.getLatestMetricData().then((metricsData: MetricDataRecord[]) => {
res.send(metricsData); res.send(metricsData);
}).catch((err: Error) => { }).catch((err: Error) => {
this.handle_error(err, res); this.handleError(err, res);
}); });
}); });
} }
...@@ -275,7 +273,7 @@ class NNIRestHandler { ...@@ -275,7 +273,7 @@ class NNIRestHandler {
this.nniManager.exportData().then((exportedData: string) => { this.nniManager.exportData().then((exportedData: string) => {
res.send(exportedData); res.send(exportedData);
}).catch((err: Error) => { }).catch((err: Error) => {
this.handle_error(err, res); this.handleError(err, res);
}); });
}); });
} }
......
...@@ -8,7 +8,7 @@ const joi = require('joi'); ...@@ -8,7 +8,7 @@ const joi = require('joi');
export namespace ValidationSchemas { export namespace ValidationSchemas {
export const SETCLUSTERMETADATA = { export const SETCLUSTERMETADATA = {
body: { body: {
machine_list: joi.array().items(joi.object({ machine_list: joi.array().items(joi.object({ // eslint-disable-line @typescript-eslint/camelcase
username: joi.string().required(), username: joi.string().required(),
ip: joi.string().ip().required(), ip: joi.string().ip().required(),
port: joi.number().min(1).max(65535).required(), port: joi.number().min(1).max(65535).required(),
...@@ -19,12 +19,12 @@ export namespace ValidationSchemas { ...@@ -19,12 +19,12 @@ export namespace ValidationSchemas {
maxTrialNumPerGpu: joi.number(), maxTrialNumPerGpu: joi.number(),
useActiveGpu: joi.boolean() useActiveGpu: joi.boolean()
})), })),
local_config: joi.object({ local_config: joi.object({ // eslint-disable-line @typescript-eslint/camelcase
gpuIndices: joi.string(), gpuIndices: joi.string(),
maxTrialNumPerGpu: joi.number(), maxTrialNumPerGpu: joi.number(),
useActiveGpu: joi.boolean() useActiveGpu: joi.boolean()
}), }),
trial_config: joi.object({ trial_config: joi.object({ // eslint-disable-line @typescript-eslint/camelcase
image: joi.string().min(1), image: joi.string().min(1),
codeDir: joi.string().min(1).required(), codeDir: joi.string().min(1).required(),
dataDir: joi.string(), dataDir: joi.string(),
...@@ -89,13 +89,13 @@ export namespace ValidationSchemas { ...@@ -89,13 +89,13 @@ export namespace ValidationSchemas {
}) })
}) })
}), }),
pai_config: joi.object({ pai_config: joi.object({ // eslint-disable-line @typescript-eslint/camelcase
userName: joi.string().min(1).required(), userName: joi.string().min(1).required(),
passWord: joi.string().min(1), passWord: joi.string().min(1),
token: joi.string().min(1), token: joi.string().min(1),
host: joi.string().min(1).required() host: joi.string().min(1).required()
}), }),
kubeflow_config: joi.object({ kubeflow_config: joi.object({ // eslint-disable-line @typescript-eslint/camelcase
operator: joi.string().min(1).required(), operator: joi.string().min(1).required(),
storage: joi.string().min(1), storage: joi.string().min(1),
apiVersion: joi.string().min(1), apiVersion: joi.string().min(1),
...@@ -113,7 +113,7 @@ export namespace ValidationSchemas { ...@@ -113,7 +113,7 @@ export namespace ValidationSchemas {
}), }),
uploadRetryCount: joi.number().min(1) uploadRetryCount: joi.number().min(1)
}), }),
frameworkcontroller_config: joi.object({ frameworkcontroller_config: joi.object({ // eslint-disable-line @typescript-eslint/camelcase
storage: joi.string().min(1), storage: joi.string().min(1),
serviceAccountName: joi.string().min(1), serviceAccountName: joi.string().min(1),
nfs: joi.object({ nfs: joi.object({
...@@ -130,7 +130,7 @@ export namespace ValidationSchemas { ...@@ -130,7 +130,7 @@ export namespace ValidationSchemas {
}), }),
uploadRetryCount: joi.number().min(1) uploadRetryCount: joi.number().min(1)
}), }),
nni_manager_ip: joi.object({ nni_manager_ip: joi.object({ // eslint-disable-line @typescript-eslint/camelcase
nniManagerIp: joi.string().min(1) nniManagerIp: joi.string().min(1)
}) })
} }
...@@ -184,6 +184,7 @@ export namespace ValidationSchemas { ...@@ -184,6 +184,7 @@ export namespace ValidationSchemas {
}; };
export const UPDATEEXPERIMENT = { export const UPDATEEXPERIMENT = {
query: { query: {
/* eslint-disable-next-line @typescript-eslint/camelcase */
update_type: joi.string().required().valid('TRIAL_CONCURRENCY', 'MAX_EXEC_DURATION', 'SEARCH_SPACE', 'MAX_TRIAL_NUM') update_type: joi.string().required().valid('TRIAL_CONCURRENCY', 'MAX_EXEC_DURATION', 'SEARCH_SPACE', 'MAX_TRIAL_NUM')
}, },
body: { body: {
......
...@@ -66,7 +66,6 @@ export class MockedNNIManager extends Manager { ...@@ -66,7 +66,6 @@ export class MockedNNIManager extends Manager {
startTime: Date.now(), startTime: Date.now(),
endTime: Date.now(), endTime: Date.now(),
tags: ['test'], tags: ['test'],
// tslint:disable-next-line:no-http-string
url: 'http://test', url: 'http://test',
workingDirectory: '/tmp/mocked', workingDirectory: '/tmp/mocked',
form: { form: {
......
...@@ -3,9 +3,7 @@ ...@@ -3,9 +3,7 @@
'use strict'; 'use strict';
// tslint:disable-next-line:no-implicit-dependencies
import { assert, expect } from 'chai'; import { assert, expect } from 'chai';
// tslint:disable-next-line:no-implicit-dependencies
import * as request from 'request'; import * as request from 'request';
import { Container } from 'typescript-ioc'; import { Container } from 'typescript-ioc';
...@@ -54,7 +52,6 @@ describe('Unit test for rest server', () => { ...@@ -54,7 +52,6 @@ describe('Unit test for rest server', () => {
}); });
it('Test GET trial-jobs/:id', (done: Mocha.Done) => { it('Test GET trial-jobs/:id', (done: Mocha.Done) => {
// tslint:disable-next-line:no-any
request.get(`${ROOT_URL}/trial-jobs/1234`, (err: Error, res: request.Response, body: any) => { request.get(`${ROOT_URL}/trial-jobs/1234`, (err: Error, res: request.Response, body: any) => {
if (err) { if (err) {
assert.fail(err.message); assert.fail(err.message);
...@@ -88,7 +85,6 @@ describe('Unit test for rest server', () => { ...@@ -88,7 +85,6 @@ describe('Unit test for rest server', () => {
}); });
it('Test change concurrent-trial-jobs', (done: Mocha.Done) => { it('Test change concurrent-trial-jobs', (done: Mocha.Done) => {
// tslint:disable-next-line:no-any
request.get(`${ROOT_URL}/experiment`, (err: Error, res: request.Response, body: any) => { request.get(`${ROOT_URL}/experiment`, (err: Error, res: request.Response, body: any) => {
if (err) { if (err) {
assert.fail(err.message); assert.fail(err.message);
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
'use strict'; 'use strict';
import * as assert from 'assert'; import * as assert from 'assert';
// tslint:disable-next-line:no-implicit-dependencies
import * as bodyParser from 'body-parser'; import * as bodyParser from 'body-parser';
import { Request, Response, Router } from 'express'; import { Request, Response, Router } from 'express';
import * as fs from 'fs'; import * as fs from 'fs';
...@@ -71,11 +70,9 @@ export abstract class ClusterJobRestServer extends RestServer { ...@@ -71,11 +70,9 @@ export abstract class ClusterJobRestServer extends RestServer {
} }
// Abstract method to handle trial metrics data // Abstract method to handle trial metrics data
// tslint:disable-next-line:no-any protected abstract handleTrialMetrics(jobId: string, trialMetrics: any[]): void;
protected abstract handleTrialMetrics(jobId : string, trialMetrics : any[]) : void;
// tslint:disable: no-unsafe-any no-any protected createRestHandler(): Router {
protected createRestHandler() : Router {
const router: Router = Router(); const router: Router = Router();
router.use((req: Request, res: Response, next: any) => { router.use((req: Request, res: Response, next: any) => {
...@@ -146,7 +143,6 @@ export abstract class ClusterJobRestServer extends RestServer { ...@@ -146,7 +143,6 @@ export abstract class ClusterJobRestServer extends RestServer {
if (!skipLogging) { if (!skipLogging) {
// Construct write stream to write remote trial's log into local file // Construct write stream to write remote trial's log into local file
// tslint:disable-next-line:non-literal-fs-path
const writeStream: Writable = fs.createWriteStream(trialLogPath, { const writeStream: Writable = fs.createWriteStream(trialLogPath, {
flags: 'a+', flags: 'a+',
encoding: 'utf8', encoding: 'utf8',
...@@ -166,5 +162,4 @@ export abstract class ClusterJobRestServer extends RestServer { ...@@ -166,5 +162,4 @@ export abstract class ClusterJobRestServer extends RestServer {
return router; return router;
} }
// tslint:enable: no-unsafe-any no-any
} }
...@@ -17,7 +17,7 @@ export class GPUInfo { ...@@ -17,7 +17,7 @@ export class GPUInfo {
// the index number of this GPU (starting from 0) // the index number of this GPU (starting from 0)
public readonly index: number; public readonly index: number;
constructor(activeProcessNum : number, gpuMemUtil : number, gpuUtil : number, index : number) { constructor(activeProcessNum: number, gpuMemUtil: number, gpuUtil: number, index: number) {
this.activeProcessNum = activeProcessNum; this.activeProcessNum = activeProcessNum;
this.gpuMemUtil = gpuMemUtil; this.gpuMemUtil = gpuMemUtil;
this.gpuUtil = gpuUtil; this.gpuUtil = gpuUtil;
......
...@@ -15,7 +15,7 @@ export class JobMetrics { ...@@ -15,7 +15,7 @@ export class JobMetrics {
public readonly jobStatus: TrialJobStatus; public readonly jobStatus: TrialJobStatus;
public readonly endTimestamp: number; public readonly endTimestamp: number;
constructor(jobId : string, metrics : string[], jobStatus : TrialJobStatus, endTimestamp : number) { constructor(jobId: string, metrics: string[], jobStatus: TrialJobStatus, endTimestamp: number) {
this.jobId = jobId; this.jobId = jobId;
this.metrics = metrics; this.metrics = metrics;
this.jobStatus = jobStatus; this.jobStatus = jobStatus;
......
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
*/ */
export class TrialConfig { export class TrialConfig {
// Trail command // Trail command
public readonly command : string; public readonly command: string;
// Code directory // Code directory
public readonly codeDir : string; public readonly codeDir: string;
// Required GPU number for trial job. The number should be in [0,100] // Required GPU number for trial job. The number should be in [0,100]
public readonly gpuNum : number; public readonly gpuNum: number;
/** /**
* Constructor * Constructor
...@@ -23,7 +23,7 @@ export class TrialConfig { ...@@ -23,7 +23,7 @@ export class TrialConfig {
* @param codeDir Code directory * @param codeDir Code directory
* @param gpuNum Required GPU number for trial job * @param gpuNum Required GPU number for trial job
*/ */
constructor(command : string, codeDir : string, gpuNum : number) { constructor(command: string, codeDir: string, gpuNum: number) {
this.command = command; this.command = command;
this.codeDir = codeDir; this.codeDir = codeDir;
this.gpuNum = gpuNum; this.gpuNum = gpuNum;
......
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