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

Commit

Permalink
remove 'port' when stopped (#3181)
Browse files Browse the repository at this point in the history
Co-authored-by: Ning Shang <nishang@microsoft.com>
  • Loading branch information
J-shang and Ning Shang authored Dec 14, 2020
1 parent 683c458 commit dec91f7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion nni/tools/nnictl/config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ def update_experiment(self, expId, key, value):
self.experiments = self.read_file()
if expId not in self.experiments:
return False
self.experiments[expId][key] = value
if value is None:
self.experiments[expId].pop(key, None)
else:
self.experiments[expId][key] = value
self.write_file()
return True

Expand Down
1 change: 1 addition & 0 deletions nni/tools/nnictl/nnictl_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def update_experiment():
rest_pid = nni_config.get_config('restServerPid')
if not detect_process(rest_pid):
experiment_config.update_experiment(key, 'status', 'STOPPED')
experiment_config.update_experiment(key, 'port', None)
continue

def check_experiment_id(args, update=True):
Expand Down
7 changes: 6 additions & 1 deletion ts/nni_manager/core/nniExperimentsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ class NNIExperimentsManager implements ExperimentManager {
this.withLockSync(() => {
const experimentsInformation = JSON.parse(fs.readFileSync(this.experimentsPath).toString());
assert(experimentId in experimentsInformation, `Experiment Manager: Experiment Id ${experimentId} not found, this should not happen`);
experimentsInformation[experimentId][key] = value;
if (value !== undefined) {
experimentsInformation[experimentId][key] = value;
} else {
delete experimentsInformation[experimentId][key];
}
fs.writeFileSync(this.experimentsPath, JSON.stringify(experimentsInformation, null, 4));
});
} catch (err) {
Expand Down Expand Up @@ -128,6 +132,7 @@ class NNIExperimentsManager implements ExperimentManager {
updateList.forEach((expId: string) => {
if (experimentsInformation[expId]) {
experimentsInformation[expId]['status'] = 'STOPPED';
delete experimentsInformation[expId]['port'];
} else {
this.log.error(`Experiment Manager: Experiment Id ${expId} not found, this should not happen`);
}
Expand Down
1 change: 1 addition & 0 deletions ts/nni_manager/core/nnimanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ class NNIManager implements Manager {
}
await this.storeExperimentProfile();
this.setStatus('STOPPED');
this.experimentManager.setExperimentInfo(this.experimentProfile.id, 'port', undefined);
}

private async periodicallyUpdateExecDuration(): Promise<void> {
Expand Down

0 comments on commit dec91f7

Please sign in to comment.