This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix remote machine connection logic #2725
Merged
Merged
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
dcd2ffd
Merge pull request #251 from microsoft/master
SparkSnail 3b8b6fb
Merge pull request #252 from microsoft/master
SparkSnail 916e444
Merge pull request #253 from microsoft/master
SparkSnail caeffb8
Merge pull request #254 from microsoft/master
SparkSnail 57c300e
Merge pull request #255 from microsoft/master
SparkSnail 65660e6
Merge pull request #257 from microsoft/master
SparkSnail 9376d6a
Merge pull request #258 from microsoft/master
SparkSnail 5fef3cf
Merge pull request #259 from microsoft/master
SparkSnail 5544ae8
Merge pull request #261 from microsoft/master
SparkSnail f9fdfee
Merge pull request #262 from microsoft/master
SparkSnail c5e26ef
add trial job detail link
SparkSnail 10a04ba
Merge branch 'master' of https://github.com/SparkSnail/nni
SparkSnail 84638cd
fix remote machine connection
SparkSnail 0371fce
remove unrelated code
SparkSnail 7c1aa95
refactor logic
SparkSnail eb49a76
remove empty line
SparkSnail 259c427
refactor annotation
SparkSnail f3d5e78
fix comments
SparkSnail File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ class RemoteMachineTrainingService implements TrainingService { | |
private nniManagerIpConfig?: NNIManagerIpConfig; | ||
private versionCheck: boolean = true; | ||
private logCollection: string; | ||
private sshConnectionPromises: any[]; | ||
|
||
constructor(@component.Inject timer: ObservableTimer) { | ||
this.metricsEmitter = new EventEmitter(); | ||
|
@@ -66,6 +67,7 @@ class RemoteMachineTrainingService implements TrainingService { | |
this.machineCopyExpCodeDirPromiseMap = new Map<RemoteMachineMeta, Promise<void>>(); | ||
this.machineExecutorManagerMap = new Map<RemoteMachineMeta, ExecutorManager>(); | ||
this.jobQueue = []; | ||
this.sshConnectionPromises = []; | ||
this.expRootDir = getExperimentRootDir(); | ||
this.timer = timer; | ||
this.log = getLogger(); | ||
|
@@ -82,6 +84,12 @@ class RemoteMachineTrainingService implements TrainingService { | |
restServer.setEnableVersionCheck = this.versionCheck; | ||
this.log.info('Run remote machine training service.'); | ||
while (!this.stopping) { | ||
if (this.sshConnectionPromises.length) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks should be put outside of while loop, as it's one time work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
await Promise.all(this.sshConnectionPromises); | ||
this.log.info('ssh connection initialized!'); | ||
// set sshConnectionPromises to [] to avoid log information duplicated | ||
this.sshConnectionPromises = []; | ||
} | ||
while (this.jobQueue.length > 0) { | ||
this.updateGpuReservation(); | ||
const trialJobId: string = this.jobQueue[0]; | ||
|
@@ -409,7 +417,6 @@ class RemoteMachineTrainingService implements TrainingService { | |
//TO DO: verify if value's format is wrong, and json parse failed, how to handle error | ||
const rmMetaList: RemoteMachineMeta[] = <RemoteMachineMeta[]>JSON.parse(machineList); | ||
|
||
const connectionPromises = []; | ||
for (const rmMeta of rmMetaList) { | ||
rmMeta.occupiedGpuIndexMap = new Map<number, number>(); | ||
const executorManager: ExecutorManager = new ExecutorManager(rmMeta); | ||
|
@@ -418,11 +425,9 @@ class RemoteMachineTrainingService implements TrainingService { | |
this.log.debug(`reached ${executor.name}`); | ||
this.machineExecutorManagerMap.set(rmMeta, executorManager); | ||
this.log.debug(`initializing ${executor.name}`); | ||
connectionPromises.push(this.initRemoteMachineOnConnected(rmMeta, executor)); | ||
this.log.info(`connected to ${executor.name}`); | ||
this.sshConnectionPromises.push(this.initRemoteMachineOnConnected(rmMeta, executor)); | ||
this.log.info(`connecting to ${executor.name}`); | ||
} | ||
|
||
await Promise.all(connectionPromises); | ||
} | ||
|
||
private async initRemoteMachineOnConnected(rmMeta: RemoteMachineMeta, executor: ShellExecutor): Promise<void> { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve readabilty, and avoid tricks of JS, it's bettter to write like
this.sshConnectionPromises.length > 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed