From 33766a5a8e597bad8d72208df569d387e855bcab Mon Sep 17 00:00:00 2001 From: Yuhong Wen Date: Mon, 10 Jan 2022 16:38:14 -0500 Subject: [PATCH] Added check to ensure the Learner returnCode is OK. (#108) * 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. --- nvflare/app_common/executors/learner_executor.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/nvflare/app_common/executors/learner_executor.py b/nvflare/app_common/executors/learner_executor.py index 18865e5f25..ecc8a18c3e 100644 --- a/nvflare/app_common/executors/learner_executor.py +++ b/nvflare/app_common/executors/learner_executor.py @@ -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