Skip to content

Commit cd8f5e0

Browse files
committed
Adjust h2o model handling to use the h2o functions to save a binary or mojo model.
1 parent 959a41e commit cd8f5e0

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/sasctl/pzmm/pickle_model.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,22 @@ def pickle_trained_model(
106106
)
107107
else:
108108
return {model_prefix + PICKLE: pickle.dumps(trained_model)}
109-
# For binary H2O models, rename the binary file as a pickle file
109+
# For binary H2O models, save the binary file as a "pickle" file
110110
elif is_binary_model and pickle_path:
111-
binary_file = Path(pickle_path) / model_prefix
112-
binary_file.rename(binary_file.with_suffix(PICKLE))
111+
h2o.save_model(
112+
model=trained_model,
113+
force=True,
114+
path=pickle_path,
115+
filename=f"{model_prefix}.pickle"
116+
)
113117
# For MOJO H2O models, gzip the model file and adjust the file extension
114118
elif is_h2o_model and pickle_path:
115-
h2o.save_model(model=trained_model, force=True, path=pickle_path, filename=f'{model_prefix}.mojo')
116-
else:
119+
trained_model.save_mojo(
120+
force=True,
121+
path=pickle_path,
122+
filename=f"{model_prefix}.mojo"
123+
)
124+
elif is_binary_model or is_h2o_model:
117125
raise ValueError(
118126
"There is currently no support for file-less H2O.ai model handling."
119127
" Please include a value for the pickle_path argument."

0 commit comments

Comments
 (0)