sb-ai-lab / LightAutoML

Fast and customizable framework for automatic ML model creation (AutoML)
https://developers.sber.ru/portal/products/lightautoml
Apache License 2.0
1.08k stars 47 forks source link

Python 3.10 TypeError: cannot set 'get_record_history_wrapper' attribute of immutable type 'object' from log_calls dependency #127

Closed gelonsoft closed 9 months ago

gelonsoft commented 9 months ago

šŸ› Bug

Error from log_calls package in Python 3.10+

To Reproduce

Install python 3.10, install lightautoml and run:

from lightautoml.automl.presets.tabular_presets import TabularAutoML
from lightautoml.tasks import Task
automl = TabularAutoML(task = Task(name = 'reg',metric = 'mse'))

You will got the following:

Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Python310\lib\site-packages\lightautoml\__init__.py", line 16, in <module>
    from .addons import *
  File "C:\Python310\lib\site-packages\lightautoml\addons\utilization\__init__.py", line 2, in <module>
    from .utilization import TimeUtilization
  File "C:\Python310\lib\site-packages\lightautoml\addons\utilization\utilization.py", line 8, in <module>
    from ...automl.base import AutoML
  File "C:\Python310\lib\site-packages\lightautoml\automl\base.py", line 8, in <module>
    from .blend import Blender, BestModelSelector
  File "C:\Python310\lib\site-packages\lightautoml\automl\blend.py", line 9, in <module>
    from ..dataset.base import LAMLDataset
  File "C:\Python310\lib\site-packages\lightautoml\dataset\base.py", line 8, in <module>
    from .roles import ColumnRole
  File "C:\Python310\lib\site-packages\lightautoml\dataset\roles.py", line 15, in <module>
    class ColumnRole:
  File "C:\Python310\lib\site-packages\log_calls\log_calls.py", line 1691, in __call__
    self._class__call__(klass)      # modifies klass (methods & inner classes) (if not builtin)
  File "C:\Python310\lib\site-packages\log_calls\log_calls.py", line 1482, in _class__call__
    new_class = self.__class__(
  File "C:\Python310\lib\site-packages\log_calls\log_calls.py", line 1692, in __call__
    self._add_class_attrs(klass)    # v0.3.0v20 traps TypeError for builtins
  File "C:\Python310\lib\site-packages\log_calls\log_calls.py", line 2138, in _add_class_attrs
    setattr(
TypeError: cannot set 'get_record_history_wrapper' attribute of immutable type 'object'
python-BaseException

Expected behavior

No exception

Additional context

Tested on Python 3.10.0 on Windows

Checklist

alexmryzhkov commented 9 months ago

Hello @gelonsoft,

please try to use the latest lightautoml version:

pip install -U lightautoml==0.3.8b1

This will fix your problem.

Alex