sileod / tasknet

Easy multi-task learning with HuggingFace Datasets and Trainer
GNU General Public License v3.0
40 stars 3 forks source link

Python 3.11 dataclass compatibility #2

Closed tboquet closed 11 months ago

tboquet commented 11 months ago

Hi, Using python 3.11 @dataclass decorator throws an error. Here is the traceback

    import tasknet as tn
/venv/lib/python3.11/site-packages/tasknet/__init__.py:1: in <module>
    from .models import *
/venv/lib/python3.11/site-packages/tasknet/models.py:23: in <module>
    from .tasks import Classification
/venv/lib/python3.11/site-packages/tasknet/tasks.py:198: in <module>
    @dataclass
/usr/local/lib/python3.11/dataclasses.py:1230: in dataclass
    return wrap(cls)
/usr/local/lib/python3.11/dataclasses.py:1220: in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
/usr/local/lib/python3.11/dataclasses.py:958: in _process_class
    cls_fields.append(_get_field(cls, name, type, kw_only))
/usr/local/lib/python3.11/dataclasses.py:815: in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
E   ValueError: mutable default <class 'tasknet.tasks.DataCollatorForMultipleChoice'> for field data_collator is not allowed: use default_factory

It looks like a field would be needed here.

sileod commented 11 months ago

Hi, thank you for reporting this. I'll try to fix it tomorrow or friday.

sileod commented 11 months ago

Hi, it should work on the new release

tboquet commented 11 months ago

Thanks a lot 💯 !