Unverified Commit dec91f7e authored by J-shang's avatar J-shang Committed by GitHub
Browse files

remove 'port' when stopped (#3181)


Co-authored-by: default avatarNing Shang <nishang@microsoft.com>
parent 683c458a
......@@ -85,7 +85,10 @@ class Experiments:
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
......
......@@ -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):
......
......@@ -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) {
......@@ -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`);
}
......
......@@ -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> {
......
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