dragon-ml-toolbox 12.4.0__py3-none-any.whl → 12.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of dragon-ml-toolbox might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dragon-ml-toolbox
3
- Version: 12.4.0
3
+ Version: 12.5.0
4
4
  Summary: A collection of tools for data science and machine learning projects.
5
5
  Author-email: "Karl L. Loza Vidaurre" <luigiloza@gmail.com>
6
6
  License-Expression: MIT
@@ -1,5 +1,5 @@
1
- dragon_ml_toolbox-12.4.0.dist-info/licenses/LICENSE,sha256=L35WDmmLZNTlJvxF6Vy7Uy4SYNi6rCfWUqlTHpoRMoU,1081
2
- dragon_ml_toolbox-12.4.0.dist-info/licenses/LICENSE-THIRD-PARTY.md,sha256=iy2r_R7wjzsCbz_Q_jMsp_jfZ6oP8XW9QhwzRBH0mGY,1904
1
+ dragon_ml_toolbox-12.5.0.dist-info/licenses/LICENSE,sha256=L35WDmmLZNTlJvxF6Vy7Uy4SYNi6rCfWUqlTHpoRMoU,1081
2
+ dragon_ml_toolbox-12.5.0.dist-info/licenses/LICENSE-THIRD-PARTY.md,sha256=iy2r_R7wjzsCbz_Q_jMsp_jfZ6oP8XW9QhwzRBH0mGY,1904
3
3
  ml_tools/ETL_cleaning.py,sha256=PLRSR-VYnt1nNT9XrcWq40SE0VzHCw7DQ8v9czfSQsU,20366
4
4
  ml_tools/ETL_engineering.py,sha256=l0I6Og9o4s6EODdk0kZXjbbC-a3vVPYy1FopP2BkQSQ,54909
5
5
  ml_tools/GUI_tools.py,sha256=Va6ig-dHULPVRwQYYtH3fvY5XPIoqRcJpRW8oXC55Hw,45413
@@ -33,9 +33,9 @@ ml_tools/keys.py,sha256=FDpbS3Jb0pjrVvvp2_8nZi919mbob_-xwuy5OOtKM_A,1848
33
33
  ml_tools/math_utilities.py,sha256=PxoOrnuj6Ntp7_TJqyDWi0JX03WpAO5iaFNK2Oeq5I4,8800
34
34
  ml_tools/optimization_tools.py,sha256=ewYMAdSGlFxYALAGFXn-MsHpvW_Sbx6I-sKg9Kp6rB8,13533
35
35
  ml_tools/path_manager.py,sha256=CyDU16pOKmC82jPubqJPT6EBt-u-3rGVbxyPIZCvDDY,18432
36
- ml_tools/serde.py,sha256=k0qAwfMf13lVBQSgq5u9MSXEoo31iOA2-Ncm8XgMCMI,3974
36
+ ml_tools/serde.py,sha256=UIshIesHRFmxr8F6B3LxGG8bYc1HHK-nlE3kENSZL18,5288
37
37
  ml_tools/utilities.py,sha256=gef62GLK7ev5BWkkQekeJoVZqwf2mIuOlOfyCw6WdtE,13882
38
- dragon_ml_toolbox-12.4.0.dist-info/METADATA,sha256=KylxsFKgAXRHl6A_0w3PXcevzLc_GnAtmR1SLRC4x8g,6166
39
- dragon_ml_toolbox-12.4.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
40
- dragon_ml_toolbox-12.4.0.dist-info/top_level.txt,sha256=wm-oxax3ciyez6VoO4zsFd-gSok2VipYXnbg3TH9PtU,9
41
- dragon_ml_toolbox-12.4.0.dist-info/RECORD,,
38
+ dragon_ml_toolbox-12.5.0.dist-info/METADATA,sha256=dGSxxwPh1WKW5Tnnq2XCo35VyAnAajajhOgckHRseKQ,6166
39
+ dragon_ml_toolbox-12.5.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
40
+ dragon_ml_toolbox-12.5.0.dist-info/top_level.txt,sha256=wm-oxax3ciyez6VoO4zsFd-gSok2VipYXnbg3TH9PtU,9
41
+ dragon_ml_toolbox-12.5.0.dist-info/RECORD,,
ml_tools/serde.py CHANGED
@@ -9,12 +9,13 @@ from ._logger import _LOGGER
9
9
 
10
10
 
11
11
  __all__ = [
12
+ "serialize_object_filename",
12
13
  "serialize_object",
13
14
  "deserialize_object",
14
15
  ]
15
16
 
16
17
 
17
- def serialize_object(obj: Any, save_dir: Union[str,Path], filename: str, verbose: bool=True, raise_on_error: bool=False) -> None:
18
+ def serialize_object_filename(obj: Any, save_dir: Union[str,Path], filename: str, verbose: bool=True, raise_on_error: bool=False) -> None:
18
19
  """
19
20
  Serializes a Python object using joblib; suitable for Python built-ins, numpy, and pandas.
20
21
 
@@ -40,6 +41,41 @@ def serialize_object(obj: Any, save_dir: Union[str,Path], filename: str, verbose
40
41
  _LOGGER.info(f"Object of type '{type(obj)}' saved to '{full_path}'")
41
42
  return None
42
43
 
44
+
45
+ def serialize_object(obj: Any, file_path: Path, verbose: bool = True, raise_on_error: bool = False) -> None:
46
+ """
47
+ Serializes a Python object using joblib to a specific file path.
48
+
49
+ Suitable for Python built-ins, numpy, and pandas.
50
+
51
+ Parameters:
52
+ obj (Any) : The Python object to serialize.
53
+ file_path (Path) : The full file path to save the object to.
54
+ '.joblib' extension will be appended if missing.
55
+ raise_on_error (bool) : If True, raises exceptions on failure.
56
+ """
57
+ try:
58
+ # Ensure the extension is correct
59
+ if file_path.suffix != '.joblib':
60
+ file_path = file_path.with_suffix(file_path.suffix + '.joblib')
61
+
62
+ # Ensure the parent directory exists
63
+ _save_dir = make_fullpath(file_path.parent, make=True, enforce="directory")
64
+
65
+ # Dump the object
66
+ joblib.dump(obj, file_path)
67
+
68
+ except (IOError, OSError, TypeError, TerminatedWorkerError) as e:
69
+ _LOGGER.error(f"Failed to serialize object of type '{type(obj)}' to '{file_path}'. Error: {e}")
70
+ if raise_on_error:
71
+ raise e
72
+ return None
73
+ else:
74
+ if verbose:
75
+ _LOGGER.info(f"Object of type '{type(obj)}' saved to '{file_path}'")
76
+ return None
77
+
78
+
43
79
  # Define a TypeVar to link the expected type to the return type of deserialization
44
80
  T = TypeVar('T')
45
81