Skip to content

Commit

Permalink
Added check to ensure the Learner returnCode is OK. (#108)
Browse files Browse the repository at this point in the history
* Added check to ensure the Learner returnCode is OK.

* Fixed black reformat.

* Changed to check the from_shareable() explictly.

* Added from_shareable(validate_result) in the try block.
  • Loading branch information
yhwen authored Jan 10, 2022
1 parent d7f4746 commit 33766a5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions nvflare/app_common/executors/learner_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,13 @@ def train(self, shareable: Shareable, fl_ctx: FLContext, abort_signal: Signal) -
and isinstance(validate_result, Shareable)
and validate_result.get_return_code() == ReturnCode.OK
):
metrics_dxo = from_shareable(validate_result)
train_dxo = from_shareable(train_result)
train_dxo.meta[MetaKey.INITIAL_METRICS] = metrics_dxo.data.get(MetaKey.INITIAL_METRICS, 0)
return train_dxo.to_shareable()
try:
metrics_dxo = from_shareable(validate_result)
train_dxo = from_shareable(train_result)
train_dxo.meta[MetaKey.INITIAL_METRICS] = metrics_dxo.data.get(MetaKey.INITIAL_METRICS, 0)
return train_dxo.to_shareable()
except ValueError:
return train_result
else:
return train_result

Expand Down

0 comments on commit 33766a5

Please sign in to comment.