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

remove 'port' when experiment stopped #3181

Merged
merged 1 commit into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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