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

Commit

Permalink
fix rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Hao Ni committed Apr 7, 2021
1 parent feb8e40 commit e32bda9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
10 changes: 5 additions & 5 deletions ts/nni_manager/training_service/common/containerJobData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ else
fi`;

export const CONTAINER_INSTALL_NNI_SHELL_FORMAT_FOR_WIN: string =
`echo off
python -c "import nni" 2>nul
if not %ERRORLEVEL% EQU 0 (
python -m pip install --user --upgrade nni
)`;
`python -c "import nni" 2>$error
if ($error -ne ''){
python -m pip install --user --upgrade nni
}
exit`;
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ class ShellExecutor {
private readonly sshClient: Client;
private readonly log: Logger;
private tempPath: string = "";
private isWindows: boolean = false;
private channelDefaultOutputs: string[] = [];
private pythonPath: string | undefined;

public isWindows: boolean = false;

constructor() {
this.log = getLogger();
this.sshClient = new Client();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getExperimentId } from '../../../common/experimentStartupInfo';
import { getLogger, Logger } from '../../../common/log';
import { EnvironmentInformation, EnvironmentService } from '../environment';
import {
getExperimentRootDir,
getExperimentRootDir, getLogLevel,
} from '../../../common/utils';
import { TrialConfig } from '../../common/trialConfig';
import { TrialConfigMetadataKey } from '../../common/trialConfigMetadataKey';
Expand Down Expand Up @@ -218,6 +218,27 @@ export class RemoteEnvironmentService extends EnvironmentService {
this.remoteMachineMetaOccupiedMap.set(remoteEnvironment.rmMachineMeta, false);
}

private async getScript(environment: EnvironmentInformation): Promise<string> {
const executor = await this.getExecutor(environment.id);
const logLevel = getLogLevel();
let script: string = environment.command;

if (executor.isWindows) {
const prepare = `mkdir envs\\${environment.id} && cd envs\\${environment.id}`;
const startrun = `powershell ..\\install_nni.ps1 && python -m nni.tools.trial_tool.trial_runner`;
const developingScript = "IF EXIST nni_trial_tool (ECHO \"nni_trial_tool exists already\") ELSE (mkdir nni_trial_tool && tar -xof ../nni_trial_tool.tar.gz -C ./nni_trial_tool) && pip3 install websockets";

script = logLevel == "debug" ? `${prepare} && ${developingScript} && ${startrun}` : `${prepare} && ${startrun}`;
}

script = `cd ${environment.runnerWorkingFolder} && \
${script} --job_pid_file ${environment.runnerWorkingFolder}/pid \
1>${environment.runnerWorkingFolder}/trialrunner_stdout 2>${environment.runnerWorkingFolder}/trialrunner_stderr \
&& echo $? \`date +%s%3N\` >${environment.runnerWorkingFolder}/code`;

return script;
}

public async startEnvironment(environment: EnvironmentInformation): Promise<void> {
if (this.sshConnectionPromises.length > 0) {
await Promise.all(this.sshConnectionPromises);
Expand Down Expand Up @@ -268,11 +289,8 @@ export class RemoteEnvironmentService extends EnvironmentService {
} else {
this.remoteExperimentRootDir = executor.getRemoteExperimentRootDir(getExperimentId());
}
environment.runnerWorkingFolder = executor.joinPath(this.remoteExperimentRootDir, 'envs', environment.id);
environment.command = `cd ${this.remoteExperimentRootDir} && \
${environment.command} --job_pid_file ${environment.runnerWorkingFolder}/pid \
1>${environment.runnerWorkingFolder}/trialrunner_stdout 2>${environment.runnerWorkingFolder}/trialrunner_stderr \
&& echo $? \`date +%s%3N\` >${environment.runnerWorkingFolder}/code`;

environment.command = await this.getScript(environment);
return Promise.resolve(true);
}
}
Expand Down
4 changes: 2 additions & 2 deletions ts/nni_manager/training_service/reusable/trialDispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ class TrialDispatcher implements TrainingService {
storageService.rename(codeFileName, "nni-code.tar.gz");

const installFileName = storageService.joinPath(envDir, `install_nni.sh`);
const installFileName_forWin = storageService.joinPath(envDir, `install_nni.cmd`);
const installFileNameForWin = storageService.joinPath(envDir, `install_nni.ps1`);
await storageService.save(CONTAINER_INSTALL_NNI_SHELL_FORMAT, installFileName);
await storageService.save(CONTAINER_INSTALL_NNI_SHELL_FORMAT_FOR_WIN, installFileName_forWin);
await storageService.save(CONTAINER_INSTALL_NNI_SHELL_FORMAT_FOR_WIN, installFileNameForWin);

const runnerSettingsConfig = storageService.joinPath(envDir, "settings.json");
await storageService.save(JSON.stringify(runnerSettings), runnerSettingsConfig);
Expand Down

0 comments on commit e32bda9

Please sign in to comment.