diff --git a/melusine/__init__.py b/melusine/__init__.py index 81eed12..e33be5c 100644 --- a/melusine/__init__.py +++ b/melusine/__init__.py @@ -3,10 +3,6 @@ """ import logging -from ctypes import CDLL, cdll -from typing import Any, Optional - -import pandas as pd from melusine._config import config @@ -19,36 +15,3 @@ # LOGGING # ------------------------------- # logging.getLogger(__name__).addHandler(logging.NullHandler()) - - -# ------------------------------- # -# MONKEY PATCH -# ------------------------------- # - -# Monkey patch for pandas DataFrame memory leaking on linux OS (pandas issue #2659) -try: - # Try executing linux malloc_trim function (release free memory) - cdll.LoadLibrary("libc.so.6") - libc: Optional[CDLL] = CDLL("libc.so.6") - if libc is not None: - libc.malloc_trim(0) -except (OSError, AttributeError): # pragma: no cover - # Incompatible OS: this monkey patch is not needed - libc = None - -# Store the standard pandas method -__std_del: Optional[Any] = getattr(pd.DataFrame, "__del__", None) - - -# Prepare a new __del__ method -def __fixed_del(self: Any) -> None: # pragma: no cover - """Override DataFrame's __del__ method: call the standard method + release free memory with malloc_trim.""" - if __std_del is not None: - __std_del(self) - if libc is not None: - libc.malloc_trim(0) - - -# Override standard pandas method if needed -if libc is not None: - pd.DataFrame.__del__ = __fixed_del diff --git a/melusine/base.py b/melusine/base.py index a0f72c1..18eb785 100644 --- a/melusine/base.py +++ b/melusine/base.py @@ -236,7 +236,7 @@ def transform(self, df: MelusineDataset) -> MelusineDataset: return_cols.append(self.debug_dict_col) for method in self.transform_methods: - logger.debug(f"Running transform for {type(self).__name__} ({method.__name__})") + logger.debug("Running transform for %s (%s)", type(self).__name__, getattr(method, "__name__", "unnamed")) first_arg_name: str = list(inspect.signature(method).parameters)[0] if first_arg_name == "row":