Skip to content

Commit

Permalink
Fix cloudpickle being introduced as a dependency; #87
Browse files Browse the repository at this point in the history
  • Loading branch information
opcode81 committed Mar 18, 2024
1 parent 77d1903 commit c60ddd4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/sensai/util/pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from pathlib import Path
from typing import Any, Callable, Dict, Iterable, List, Union

import cloudpickle
import joblib

from .io import S3Object, is_s3_path
Expand All @@ -27,6 +26,7 @@ def _load_with_error_log(loader: Callable):
if backend == "pickle":
return _load_with_error_log(pickle.load)
elif backend == "cloudpickle":
import cloudpickle
return _load_with_error_log(cloudpickle.load)
elif backend == "joblib":
return joblib.load(f)
Expand Down Expand Up @@ -62,6 +62,7 @@ def open_file():
elif backend == "joblib":
joblib.dump(obj, f, protocol=protocol)
elif backend == "cloudpickle":
import cloudpickle
cloudpickle.dump(obj, f, protocol=protocol)
else:
raise ValueError(f"Unknown backend '{backend}'. Supported backends are 'pickle', 'joblib' and 'cloudpickle'")
Expand Down

0 comments on commit c60ddd4

Please sign in to comment.