Unverified Commit 1328f412 authored by chicm-ms's avatar chicm-ms Committed by GitHub
Browse files

Fix eslint errors (#1836)

* update eslint rules
* auto fix eslint
* manually fix eslint (#1833)
parent 8c07cf41
...@@ -18,7 +18,12 @@ ...@@ -18,7 +18,12 @@
"plugin:@typescript-eslint/recommended" "plugin:@typescript-eslint/recommended"
], ],
"rules": { "rules": {
"@typescript-eslint/no-explicit-any": 0 "@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-namespace": 0,
"@typescript-eslint/consistent-type-assertions": 0,
"@typescript-eslint/no-inferrable-types": 0,
"no-inner-declarations": 0,
"@typescript-eslint/no-var-requires": 0
}, },
"ignorePatterns": [ "ignorePatterns": [
"node_modules/", "node_modules/",
......
...@@ -56,13 +56,13 @@ interface TrialJobInfo { ...@@ -56,13 +56,13 @@ interface TrialJobInfo {
interface HyperParameterFormat { interface HyperParameterFormat {
parameter_source: string; parameter_source: string;
parameters: Object; parameters: Record<string, any>;
parameter_id: number; parameter_id: number;
} }
interface ExportedDataFormat { interface ExportedDataFormat {
parameter: Object; parameter: Record<string, any>;
value: Object; value: Record<string, any>;
id: string; id: string;
} }
......
...@@ -27,9 +27,9 @@ class ExperimentStartupInfo { ...@@ -27,9 +27,9 @@ class ExperimentStartupInfo {
this.initialized = true; this.initialized = true;
if (logDir !== undefined && logDir.length > 0) { if (logDir !== undefined && logDir.length > 0) {
this.logDir = path.join(path.normalize(logDir), getExperimentId()); this.logDir = path.join(path.normalize(logDir), this.getExperimentId());
} else { } else {
this.logDir = path.join(os.homedir(), 'nni', 'experiments', getExperimentId()); this.logDir = path.join(os.homedir(), 'nni', 'experiments', this.getExperimentId());
} }
if (logLevel !== undefined && logLevel.length > 1) { if (logLevel !== undefined && logLevel.length > 1) {
......
...@@ -84,7 +84,7 @@ class Logger { ...@@ -84,7 +84,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();
} }
......
...@@ -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()
...@@ -236,11 +234,11 @@ function getMsgDispatcherCommand(tuner: any, assessor: any, advisor: any, multiP ...@@ -236,11 +234,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 +281,7 @@ function cleanupUnitTest(): void { ...@@ -283,7 +281,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 +323,15 @@ function getJobCancelStatus(isEarlyStopped: boolean): TrialJobStatus { ...@@ -325,15 +323,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 +357,7 @@ function countFilesRecursively(directory: string, timeoutMilliSeconds?: number): ...@@ -359,7 +357,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 +372,7 @@ async function validateFileNameRecursively(directory: string): Promise<boolean> ...@@ -374,7 +372,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 +394,7 @@ async function validateFileNameRecursively(directory: string): Promise<boolean> ...@@ -396,7 +394,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 +428,7 @@ function getTunerProc(command: string, stdio: StdioOptions, newCwd: string, newE ...@@ -430,7 +428,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 +438,7 @@ async function isAlive(pid: any): Promise<boolean> { ...@@ -440,6 +438,7 @@ async function isAlive(pid: any): Promise<boolean> {
} }
} }
catch (error) { catch (error) {
//ignore
} }
} }
else { else {
...@@ -458,7 +457,7 @@ async function isAlive(pid: any): Promise<boolean> { ...@@ -458,7 +457,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) {
...@@ -329,6 +329,7 @@ class NNIDataStore implements DataStore { ...@@ -329,6 +329,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 +359,7 @@ class NNIDataStore implements DataStore { ...@@ -358,6 +359,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');
} }
......
...@@ -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)
......
...@@ -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';
...@@ -72,7 +72,7 @@ class NNIRestHandler { ...@@ -72,7 +72,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 +105,7 @@ class NNIRestHandler { ...@@ -105,7 +105,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 +118,7 @@ class NNIRestHandler { ...@@ -118,7 +118,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 +128,7 @@ class NNIRestHandler { ...@@ -128,7 +128,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 +138,7 @@ class NNIRestHandler { ...@@ -138,7 +138,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 +148,18 @@ class NNIRestHandler { ...@@ -148,18 +148,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 +170,7 @@ class NNIRestHandler { ...@@ -170,7 +170,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);
}); });
}); });
} }
...@@ -189,7 +189,7 @@ class NNIRestHandler { ...@@ -189,7 +189,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 +202,7 @@ class NNIRestHandler { ...@@ -202,7 +202,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 +213,7 @@ class NNIRestHandler { ...@@ -213,7 +213,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 +223,7 @@ class NNIRestHandler { ...@@ -223,7 +223,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 +233,7 @@ class NNIRestHandler { ...@@ -233,7 +233,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 +243,7 @@ class NNIRestHandler { ...@@ -243,7 +243,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 +255,7 @@ class NNIRestHandler { ...@@ -255,7 +255,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 +265,7 @@ class NNIRestHandler { ...@@ -265,7 +265,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 +275,7 @@ class NNIRestHandler { ...@@ -275,7 +275,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: {
......
...@@ -72,10 +72,10 @@ export abstract class ClusterJobRestServer extends RestServer { ...@@ -72,10 +72,10 @@ 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 // 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 // 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) => {
......
...@@ -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;
......
...@@ -10,7 +10,6 @@ import * as os from 'os'; ...@@ -10,7 +10,6 @@ import * as os from 'os';
import * as path from 'path'; import * as path from 'path';
import { String } from 'typescript-string-operations'; import { String } from 'typescript-string-operations';
import { countFilesRecursively, getNewLine, validateFileNameRecursively } from '../../common/utils'; import { countFilesRecursively, getNewLine, validateFileNameRecursively } from '../../common/utils';
import { file } from '../../node_modules/@types/tmp';
import { GPU_INFO_COLLECTOR_FORMAT_WINDOWS } from './gpuData'; import { GPU_INFO_COLLECTOR_FORMAT_WINDOWS } from './gpuData';
/** /**
...@@ -20,7 +19,7 @@ import { GPU_INFO_COLLECTOR_FORMAT_WINDOWS } from './gpuData'; ...@@ -20,7 +19,7 @@ import { GPU_INFO_COLLECTOR_FORMAT_WINDOWS } from './gpuData';
* @returns file number under codeDir * @returns file number under codeDir
*/ */
// tslint:disable: no-redundant-jsdoc // tslint:disable: no-redundant-jsdoc
export async function validateCodeDir(codeDir: string) : Promise<number> { export async function validateCodeDir(codeDir: string): Promise<number> {
let fileCount: number | undefined; let fileCount: number | undefined;
let fileNameValid: boolean = true; let fileNameValid: boolean = true;
try { try {
......
...@@ -66,7 +66,7 @@ export namespace AzureStorageClientUtility { ...@@ -66,7 +66,7 @@ export namespace AzureStorageClientUtility {
let rootDirectory: string = ''; let rootDirectory: string = '';
for (const directory of directories) { for (const directory of directories) {
rootDirectory += directory; rootDirectory += directory;
let result:boolean = await createDirectory(fileServerClient, rootDirectory, azureShare); const result: boolean = await createDirectory(fileServerClient, rootDirectory, azureShare);
if (!result) { if (!result) {
deferred.resolve(false); deferred.resolve(false);
return deferred.promise; return deferred.promise;
...@@ -141,7 +141,7 @@ export namespace AzureStorageClientUtility { ...@@ -141,7 +141,7 @@ export namespace AzureStorageClientUtility {
localDirectory: string): Promise<boolean> { localDirectory: string): Promise<boolean> {
const deferred: Deferred<boolean> = new Deferred<boolean>(); const deferred: Deferred<boolean> = new Deferred<boolean>();
const fileNameArray: string[] = fs.readdirSync(localDirectory); const fileNameArray: string[] = fs.readdirSync(localDirectory);
let result: boolean = await createDirectoryRecursive(fileServerClient, azureDirectory, azureShare); const result: boolean = await createDirectoryRecursive(fileServerClient, azureDirectory, azureShare);
if (!result) { if (!result) {
deferred.resolve(false); deferred.resolve(false);
return deferred.promise; return deferred.promise;
......
...@@ -26,7 +26,7 @@ export class FrameworkControllerTrialConfigTemplate extends KubernetesTrialConfi ...@@ -26,7 +26,7 @@ export class FrameworkControllerTrialConfigTemplate extends KubernetesTrialConfi
public readonly frameworkAttemptCompletionPolicy: FrameworkAttemptCompletionPolicy; public readonly frameworkAttemptCompletionPolicy: FrameworkAttemptCompletionPolicy;
public readonly name: string; public readonly name: string;
public readonly taskNum: number; public readonly taskNum: number;
constructor(taskNum: number, command : string, gpuNum : number, constructor(taskNum: number, command: string, gpuNum: number,
cpuNum: number, memoryMB: number, image: string, cpuNum: number, memoryMB: number, image: string,
frameworkAttemptCompletionPolicy: FrameworkAttemptCompletionPolicy, privateRegistryFilePath?: string | undefined) { frameworkAttemptCompletionPolicy: FrameworkAttemptCompletionPolicy, privateRegistryFilePath?: string | undefined) {
super(command, gpuNum, cpuNum, memoryMB, image, privateRegistryFilePath); super(command, gpuNum, cpuNum, memoryMB, image, privateRegistryFilePath);
......
...@@ -17,7 +17,7 @@ export class FrameworkControllerJobInfoCollector extends KubernetesJobInfoCollec ...@@ -17,7 +17,7 @@ export class FrameworkControllerJobInfoCollector extends KubernetesJobInfoCollec
} }
protected async retrieveSingleTrialJobInfo(kubernetesCRDClient: KubernetesCRDClient | undefined, protected async retrieveSingleTrialJobInfo(kubernetesCRDClient: KubernetesCRDClient | undefined,
kubernetesTrialJob : KubernetesTrialJobDetail) : Promise<void> { kubernetesTrialJob: KubernetesTrialJobDetail): Promise<void> {
if (!this.statusesNeedToCheck.includes(kubernetesTrialJob.status)) { if (!this.statusesNeedToCheck.includes(kubernetesTrialJob.status)) {
return Promise.resolve(); return Promise.resolve();
} }
...@@ -52,8 +52,8 @@ export class FrameworkControllerJobInfoCollector extends KubernetesJobInfoCollec ...@@ -52,8 +52,8 @@ export class FrameworkControllerJobInfoCollector extends KubernetesJobInfoCollec
kubernetesTrialJob.startTime = Date.parse(<string>kubernetesJobInfo.status.startTime); kubernetesTrialJob.startTime = Date.parse(<string>kubernetesJobInfo.status.startTime);
} }
break; break;
case 'Completed': case 'Completed': {
const completedJobType : FrameworkControllerJobCompleteStatus = const completedJobType: FrameworkControllerJobCompleteStatus =
<FrameworkControllerJobCompleteStatus>kubernetesJobInfo.status.attemptStatus.completionStatus.type.name; <FrameworkControllerJobCompleteStatus>kubernetesJobInfo.status.attemptStatus.completionStatus.type.name;
switch (completedJobType) { switch (completedJobType) {
case 'Succeeded': case 'Succeeded':
...@@ -66,6 +66,7 @@ export class FrameworkControllerJobInfoCollector extends KubernetesJobInfoCollec ...@@ -66,6 +66,7 @@ export class FrameworkControllerJobInfoCollector extends KubernetesJobInfoCollec
} }
kubernetesTrialJob.endTime = Date.parse(<string>kubernetesJobInfo.status.completionTime); kubernetesTrialJob.endTime = Date.parse(<string>kubernetesJobInfo.status.completionTime);
break; break;
}
default: default:
} }
} }
......
...@@ -15,7 +15,6 @@ import { delay, generateParamFileName, getExperimentRootDir, uniqueString } from ...@@ -15,7 +15,6 @@ import { delay, generateParamFileName, getExperimentRootDir, uniqueString } from
import { CONTAINER_INSTALL_NNI_SHELL_FORMAT } from '../../common/containerJobData'; import { CONTAINER_INSTALL_NNI_SHELL_FORMAT } from '../../common/containerJobData';
import { TrialConfigMetadataKey } from '../../common/trialConfigMetadataKey'; import { TrialConfigMetadataKey } from '../../common/trialConfigMetadataKey';
import { validateCodeDir } from '../../common/util'; import { validateCodeDir } from '../../common/util';
import { AzureStorageClientUtility } from '../azureStorageClientUtils';
import { NFSConfig } from '../kubernetesConfig'; import { NFSConfig } from '../kubernetesConfig';
import { KubernetesTrialJobDetail } from '../kubernetesData'; import { KubernetesTrialJobDetail } from '../kubernetesData';
import { KubernetesTrainingService } from '../kubernetesTrainingService'; import { KubernetesTrainingService } from '../kubernetesTrainingService';
...@@ -119,7 +118,7 @@ class FrameworkControllerTrainingService extends KubernetesTrainingService imple ...@@ -119,7 +118,7 @@ class FrameworkControllerTrainingService extends KubernetesTrainingService imple
case TrialConfigMetadataKey.NNI_MANAGER_IP: case TrialConfigMetadataKey.NNI_MANAGER_IP:
this.nniManagerIpConfig = <NNIManagerIpConfig>JSON.parse(value); this.nniManagerIpConfig = <NNIManagerIpConfig>JSON.parse(value);
break; break;
case TrialConfigMetadataKey.FRAMEWORKCONTROLLER_CLUSTER_CONFIG: case TrialConfigMetadataKey.FRAMEWORKCONTROLLER_CLUSTER_CONFIG: {
const frameworkcontrollerClusterJsonObject: any = JSON.parse(value); const frameworkcontrollerClusterJsonObject: any = JSON.parse(value);
this.fcClusterConfig = FrameworkControllerClusterConfigFactory this.fcClusterConfig = FrameworkControllerClusterConfigFactory
.generateFrameworkControllerClusterConfig(frameworkcontrollerClusterJsonObject); .generateFrameworkControllerClusterConfig(frameworkcontrollerClusterJsonObject);
...@@ -130,9 +129,7 @@ class FrameworkControllerTrainingService extends KubernetesTrainingService imple ...@@ -130,9 +129,7 @@ class FrameworkControllerTrainingService extends KubernetesTrainingService imple
this.azureStorageShare = azureFrameworkControllerClusterConfig.azureStorage.azureShare; this.azureStorageShare = azureFrameworkControllerClusterConfig.azureStorage.azureShare;
await this.createAzureStorage( await this.createAzureStorage(
azureFrameworkControllerClusterConfig.keyVault.vaultName, azureFrameworkControllerClusterConfig.keyVault.vaultName,
azureFrameworkControllerClusterConfig.keyVault.name, azureFrameworkControllerClusterConfig.keyVault.name
azureFrameworkControllerClusterConfig.azureStorage.accountName,
azureFrameworkControllerClusterConfig.azureStorage.azureShare
); );
} else if (this.fcClusterConfig.storageType === 'nfs') { } else if (this.fcClusterConfig.storageType === 'nfs') {
const nfsFrameworkControllerClusterConfig: FrameworkControllerClusterConfigNFS = const nfsFrameworkControllerClusterConfig: FrameworkControllerClusterConfigNFS =
...@@ -144,7 +141,8 @@ class FrameworkControllerTrainingService extends KubernetesTrainingService imple ...@@ -144,7 +141,8 @@ class FrameworkControllerTrainingService extends KubernetesTrainingService imple
} }
this.kubernetesCRDClient = FrameworkControllerClientFactory.createClient(); this.kubernetesCRDClient = FrameworkControllerClientFactory.createClient();
break; break;
case TrialConfigMetadataKey.TRIAL_CONFIG: }
case TrialConfigMetadataKey.TRIAL_CONFIG: {
const frameworkcontrollerTrialJsonObjsect: any = JSON.parse(value); const frameworkcontrollerTrialJsonObjsect: any = JSON.parse(value);
this.fcTrialConfig = new FrameworkControllerTrialConfig( this.fcTrialConfig = new FrameworkControllerTrialConfig(
...@@ -161,6 +159,7 @@ class FrameworkControllerTrainingService extends KubernetesTrainingService imple ...@@ -161,6 +159,7 @@ class FrameworkControllerTrainingService extends KubernetesTrainingService imple
return Promise.reject(new Error(error)); return Promise.reject(new Error(error));
} }
break; break;
}
case TrialConfigMetadataKey.VERSION_CHECK: case TrialConfigMetadataKey.VERSION_CHECK:
this.versionCheck = (value === 'true' || value === 'True'); this.versionCheck = (value === 'true' || value === 'True');
break; break;
...@@ -237,7 +236,7 @@ class FrameworkControllerTrainingService extends KubernetesTrainingService imple ...@@ -237,7 +236,7 @@ class FrameworkControllerTrainingService extends KubernetesTrainingService imple
await cpp.exec(`mkdir -p ${trialLocalTempFolder}`); await cpp.exec(`mkdir -p ${trialLocalTempFolder}`);
const installScriptContent : string = CONTAINER_INSTALL_NNI_SHELL_FORMAT; const installScriptContent: string = CONTAINER_INSTALL_NNI_SHELL_FORMAT;
// Write NNI installation file to local tmp files // Write NNI installation file to local tmp files
await fs.promises.writeFile(path.join(trialLocalTempFolder, 'install_nni.sh'), installScriptContent, { encoding: 'utf8' }); await fs.promises.writeFile(path.join(trialLocalTempFolder, 'install_nni.sh'), installScriptContent, { encoding: 'utf8' });
// Create tmp trial working folder locally. // Create tmp trial working folder locally.
...@@ -251,7 +250,6 @@ class FrameworkControllerTrainingService extends KubernetesTrainingService imple ...@@ -251,7 +250,6 @@ class FrameworkControllerTrainingService extends KubernetesTrainingService imple
} }
// Write file content ( parameter.cfg ) to local tmp folders // Write file content ( parameter.cfg ) to local tmp folders
const trialForm : TrialJobApplicationForm = (<TrialJobApplicationForm>form);
if (form !== undefined) { if (form !== undefined) {
await fs.promises.writeFile(path.join(trialLocalTempFolder, generateParamFileName(form.hyperParameters)), await fs.promises.writeFile(path.join(trialLocalTempFolder, generateParamFileName(form.hyperParameters)),
form.hyperParameters.value, { encoding: 'utf8' }); form.hyperParameters.value, { encoding: 'utf8' });
...@@ -266,7 +264,7 @@ class FrameworkControllerTrainingService extends KubernetesTrainingService imple ...@@ -266,7 +264,7 @@ class FrameworkControllerTrainingService extends KubernetesTrainingService imple
throw new Error('frameworkcontroller trial config is not initialized'); throw new Error('frameworkcontroller trial config is not initialized');
} }
const podResources : any = []; const podResources: any = [];
for (const taskRole of this.fcTrialConfig.taskRoles) { for (const taskRole of this.fcTrialConfig.taskRoles) {
const resource: any = {}; const resource: any = {};
resource.requests = this.generatePodResource(taskRole.memoryMB, taskRole.cpuNum, taskRole.gpuNum); resource.requests = this.generatePodResource(taskRole.memoryMB, taskRole.cpuNum, taskRole.gpuNum);
...@@ -300,7 +298,7 @@ class FrameworkControllerTrainingService extends KubernetesTrainingService imple ...@@ -300,7 +298,7 @@ class FrameworkControllerTrainingService extends KubernetesTrainingService imple
* @param podResources pod template * @param podResources pod template
*/ */
private async generateFrameworkControllerJobConfig(trialJobId: string, trialWorkingFolder: string, private async generateFrameworkControllerJobConfig(trialJobId: string, trialWorkingFolder: string,
frameworkcontrollerJobName : string, podResources : any) : Promise<any> { frameworkcontrollerJobName: string, podResources: any): Promise<any> {
if (this.fcClusterConfig === undefined) { if (this.fcClusterConfig === undefined) {
throw new Error('frameworkcontroller Cluster config is not initialized'); throw new Error('frameworkcontroller Cluster config is not initialized');
} }
...@@ -424,7 +422,7 @@ class FrameworkControllerTrainingService extends KubernetesTrainingService imple ...@@ -424,7 +422,7 @@ class FrameworkControllerTrainingService extends KubernetesTrainingService imple
}] }]
}]; }];
let spec: any = { const spec: any = {
containers: containers, containers: containers,
initContainers: initContainers, initContainers: initContainers,
restartPolicy: 'OnFailure', restartPolicy: 'OnFailure',
......
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