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

Commit

Permalink
quick fix unknow trial report to resume experiment (#3096)
Browse files Browse the repository at this point in the history
  • Loading branch information
J-shang authored Nov 25, 2020
1 parent c55300d commit 2c5d89a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions nni/runtime/msg_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _sort_history(history):
# Tuner global variables
_next_parameter_id = 0
_trial_params = {}
'''key: trial job ID; value: parameters'''
'''key: parameter ID; value: parameters'''
_customized_parameter_ids = set()


Expand Down Expand Up @@ -114,7 +114,7 @@ def handle_import_data(self, data):
data: a list of dictionaries, each of which has at least two keys, 'parameter' and 'value'
"""
for entry in data:
entry['value'] = entry['value'] if type(entry['value']) is str else json_tricks.dumps(entry['value'])
entry['value'] = entry['value'] if type(entry['value']) is str else json_tricks.dumps(entry['value'])
entry['value'] = json_tricks.loads(entry['value'])
self.tuner.import_data(data)

Expand Down Expand Up @@ -182,8 +182,11 @@ def _handle_final_metric_data(self, data):
customized = True
else:
customized = False
if id_ in _trial_params:
self.tuner.receive_trial_result(id_, _trial_params[id_], value, customized=customized,
trial_job_id=data.get('trial_job_id'))
else:
_logger.warning('Find unknown job parameter id %s, maybe something goes wrong.', _trial_params[id_])

def _handle_intermediate_metric_data(self, data):
"""Call assessor to process intermediate results
Expand Down
12 changes: 8 additions & 4 deletions ts/nni_manager/core/nnimanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,11 +678,15 @@ class NNIManager implements Manager {

private async onTrialJobMetrics(metric: TrialJobMetric): Promise<void> {
this.log.debug(`NNIManager received trial job metrics: ${metric}`);
await this.dataStore.storeMetricData(metric.id, metric.data);
if (this.dispatcher === undefined) {
throw new Error('Error: tuner has not been setup');
if (this.trialJobs.has(metric.id)){
await this.dataStore.storeMetricData(metric.id, metric.data);
if (this.dispatcher === undefined) {
throw new Error('Error: tuner has not been setup');
}
this.dispatcher.sendCommand(REPORT_METRIC_DATA, metric.data);
} else {
this.log.warning(`NNIManager received non-existent trial job metrics: ${metric}`);
}
this.dispatcher.sendCommand(REPORT_METRIC_DATA, metric.data);
}

private requestTrialJobs(jobNum: number): void {
Expand Down

0 comments on commit 2c5d89a

Please sign in to comment.