Skip to content

Commit

Permalink
raise value error when model is empty when trying to set tensor dict
Browse files Browse the repository at this point in the history
Signed-off-by: kta-intel <[email protected]>
  • Loading branch information
kta-intel committed Nov 18, 2024
1 parent ac2a925 commit d65def1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions openfl/federated/task/runner_xgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,14 @@ def set_tensor_dict(self, tensor_dict, with_opt_vars=False):
"""
# The with_opt_vars argument is not used in this method
self.global_model = tensor_dict["local_tree"]
global_model_byte_array = bytearray(self.global_model.astype(np.uint8).tobytes())
self.bst = xgb.Booster()
self.bst.load_model(global_model_byte_array)
if (
isinstance(self.global_model, np.ndarray) and self.global_model.size == 0
) or self.global_model is None:
raise ValueError("The model does not exist or is empty.")
else:
global_model_byte_array = bytearray(self.global_model.astype(np.uint8).tobytes())
self.bst = xgb.Booster()
self.bst.load_model(global_model_byte_array)

def save_native(
self,
Expand Down

0 comments on commit d65def1

Please sign in to comment.