Unverified Commit ade0b5b1 authored by liuzhe-lz's avatar liuzhe-lz Committed by GitHub
Browse files

Fix two bugs introduced in this sprint (#4877)

parent 21539654
...@@ -84,7 +84,8 @@ def create_experiment(args): ...@@ -84,7 +84,8 @@ def create_experiment(args):
exp.url_prefix = url_prefix exp.url_prefix = url_prefix
if foreground: if foreground:
exp.run(port, debug=debug) exp.start(port, debug, RunMode.Foreground)
exp._wait_completion()
else: else:
exp.start(port, debug, RunMode.Detach) exp.start(port, debug, RunMode.Detach)
......
...@@ -105,10 +105,10 @@ function randomSelect<T>(a: T[]): T { ...@@ -105,10 +105,10 @@ function randomSelect<T>(a: T[]): T {
* @param expParams: experiment startup parameters * @param expParams: experiment startup parameters
* *
*/ */
function getMsgDispatcherCommand(expParams: ExperimentConfig): string { function getMsgDispatcherCommand(expParams: ExperimentConfig): string[] {
const clonedParams = Object.assign({}, expParams); const clonedParams = Object.assign({}, expParams);
delete clonedParams.searchSpace; delete clonedParams.searchSpace;
return `${globals.args.pythonInterpreter} -m nni --exp_params ${Buffer.from(JSON.stringify(clonedParams)).toString('base64')}`; return [ globals.args.pythonInterpreter, '-m', 'nni', '--exp_params', Buffer.from(JSON.stringify(clonedParams)).toString('base64') ];
} }
/** /**
...@@ -249,16 +249,13 @@ async function getVersion(): Promise<string> { ...@@ -249,16 +249,13 @@ async function getVersion(): Promise<string> {
/** /**
* run command as ChildProcess * run command as ChildProcess
*/ */
function getTunerProc(command: string, stdio: StdioOptions, newCwd: string, newEnv: any, newShell: boolean = true, isDetached: boolean = false): ChildProcess { function getTunerProc(command: string[], stdio: StdioOptions, newCwd: string, newEnv: any, newShell: boolean = true, isDetached: boolean = false): ChildProcess {
let cmd: string = command; // FIXME: TensorBoard has no reason to use get TUNER proc
let arg: string[] = [];
if (process.platform === "win32") { if (process.platform === "win32") {
cmd = command.split(" ", 1)[0];
arg = command.substr(cmd.length + 1).split(" ");
newShell = false; newShell = false;
isDetached = true; isDetached = true;
} }
const tunerProc: ChildProcess = spawn(cmd, arg, { const tunerProc: ChildProcess = spawn(command[0], command.slice(1), {
stdio, stdio,
cwd: newCwd, cwd: newCwd,
env: newEnv, env: newEnv,
......
...@@ -178,7 +178,7 @@ class NNIManager implements Manager { ...@@ -178,7 +178,7 @@ class NNIManager implements Manager {
} }
this.log.info('Setup tuner...'); this.log.info('Setup tuner...');
const dispatcherCommand: string = getMsgDispatcherCommand(config); const dispatcherCommand: string[] = getMsgDispatcherCommand(config);
this.log.debug(`dispatcher command: ${dispatcherCommand}`); this.log.debug(`dispatcher command: ${dispatcherCommand}`);
const checkpointDir: string = await this.createCheckpointDir(); const checkpointDir: string = await this.createCheckpointDir();
await this.setupTuner(dispatcherCommand, undefined, 'start', checkpointDir); await this.setupTuner(dispatcherCommand, undefined, 'start', checkpointDir);
...@@ -211,7 +211,7 @@ class NNIManager implements Manager { ...@@ -211,7 +211,7 @@ class NNIManager implements Manager {
} }
this.log.info('Setup tuner...'); this.log.info('Setup tuner...');
const dispatcherCommand: string = getMsgDispatcherCommand(config); const dispatcherCommand: string[] = getMsgDispatcherCommand(config);
this.log.debug(`dispatcher command: ${dispatcherCommand}`); this.log.debug(`dispatcher command: ${dispatcherCommand}`);
const checkpointDir: string = await this.createCheckpointDir(); const checkpointDir: string = await this.createCheckpointDir();
await this.setupTuner(dispatcherCommand, undefined, 'resume', checkpointDir); await this.setupTuner(dispatcherCommand, undefined, 'resume', checkpointDir);
...@@ -457,7 +457,7 @@ class NNIManager implements Manager { ...@@ -457,7 +457,7 @@ class NNIManager implements Manager {
} }
} }
private async setupTuner(command: string, cwd: string | undefined, mode: 'start' | 'resume', dataDirectory: string): Promise<void> { private async setupTuner(command: string[], cwd: string | undefined, mode: 'start' | 'resume', dataDirectory: string): Promise<void> {
if (this.dispatcher !== undefined) { if (this.dispatcher !== undefined) {
return; return;
} }
......
...@@ -81,7 +81,7 @@ class NNITensorboardManager implements TensorboardManager { ...@@ -81,7 +81,7 @@ class NNITensorboardManager implements TensorboardManager {
return tensorboardTask; return tensorboardTask;
} }
private async getTensorboardStartCommand(trialJobIdList: string[], trialLogDirectoryList: string[], port: number): Promise<string> { private async getTensorboardStartCommand(trialJobIdList: string[], trialLogDirectoryList: string[], port: number): Promise<string[]> {
if (this.tensorboardVersion === undefined) { if (this.tensorboardVersion === undefined) {
this.setTensorboardVersion(); this.setTensorboardVersion();
if (this.tensorboardVersion === undefined) { if (this.tensorboardVersion === undefined) {
...@@ -105,9 +105,8 @@ class NNITensorboardManager implements TensorboardManager { ...@@ -105,9 +105,8 @@ class NNITensorboardManager implements TensorboardManager {
const trialJob = await this.nniManager.getTrialJob(trialJobIdList[idx]); const trialJob = await this.nniManager.getTrialJob(trialJobIdList[idx]);
logRealPaths.push(`${trialJob.sequenceId}-${trialJobIdList[idx]}:${realPath}`); logRealPaths.push(`${trialJob.sequenceId}-${trialJobIdList[idx]}:${realPath}`);
} }
const command = `tensorboard ${logdirCmd}=${logRealPaths.join(',')} --port=${port}`; return [ 'tensorboard', `${logdirCmd}=${logRealPaths.join(',')}`, `--port=${port}` ];
return command; } catch (error) {
} catch (error){
throw new Error(`${error.message}`); throw new Error(`${error.message}`);
} }
} }
......
...@@ -22,7 +22,7 @@ async function runProcess(): Promise<Error | null> { ...@@ -22,7 +22,7 @@ async function runProcess(): Promise<Error | null> {
// create fake assessor process // create fake assessor process
const stdio: StdioOptions = ['ignore', 'pipe', process.stderr, 'pipe', 'pipe']; const stdio: StdioOptions = ['ignore', 'pipe', process.stderr, 'pipe', 'pipe'];
const command: string = 'python assessor.py'; const command: string[] = [ 'python', 'assessor.py' ];
const proc: ChildProcess = getTunerProc(command, stdio, 'core/test', process.env); const proc: ChildProcess = getTunerProc(command, stdio, 'core/test', process.env);
// record its sent/received commands on exit // record its sent/received commands on exit
proc.on('error', (error: Error): void => { deferred.resolve(error); }); proc.on('error', (error: Error): void => { deferred.resolve(error); });
......
...@@ -18,7 +18,7 @@ async function startProcess(): Promise<void> { ...@@ -18,7 +18,7 @@ async function startProcess(): Promise<void> {
// create fake assessor process // create fake assessor process
const stdio: StdioOptions = ['ignore', 'pipe', process.stderr, 'pipe', 'pipe']; const stdio: StdioOptions = ['ignore', 'pipe', process.stderr, 'pipe', 'pipe'];
const dispatcherCmd: string = getMsgDispatcherCommand( const dispatcherCmd: string[] = getMsgDispatcherCommand(
// Mock tuner config // Mock tuner config
<any>{ <any>{
experimentName: 'exp1', experimentName: 'exp1',
......
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