Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError when running hello world example on Python 3.12 #3517

Closed
trungams opened this issue Nov 19, 2024 · 5 comments
Closed

ValueError when running hello world example on Python 3.12 #3517

trungams opened this issue Nov 19, 2024 · 5 comments

Comments

@trungams
Copy link
Member

  • Environment I'm running Lisa on: Azure Linux 3
  • Python version: 3.12.3

After installing Lisa according to the instructions, I run the hello world example and got the following error:

$ lisa
Traceback (most recent call last):
  File "/home/tvuong/.local/bin/lisa", line 5, in <module>
    from lisa.main import cli
  File "/datadrive/projects/lisa/lisa/main.py", line 16, in <module>
    import lisa.mixin_modules  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/datadrive/projects/lisa/lisa/mixin_modules.py", line 60, in <module>
    import lisa.sut_orchestrator.libvirt.ch_platform  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/datadrive/projects/lisa/lisa/sut_orchestrator/libvirt/ch_platform.py", line 15, in <module>
    from lisa.sut_orchestrator.libvirt.context import (
  File "/datadrive/projects/lisa/lisa/sut_orchestrator/libvirt/context.py", line 53, in <module>
    @dataclass
     ^^^^^^^^^
  File "/usr/lib/python3.12/dataclasses.py", line 1268, in dataclass
    return wrap(cls)
           ^^^^^^^^^
  File "/usr/lib/python3.12/dataclasses.py", line 1258, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/dataclasses.py", line 994, in _process_class
    cls_fields.append(_get_field(cls, name, type, kw_only))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/dataclasses.py", line 852, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <enum 'GuestVmType'> for field guest_vm_type is not allowed: use default_factory

GuestVmType is unhashable, so Python is complaining because it detects an unhashable default parameter in NodeContext (see dataclasses doc). This seems to come from a change since Python version 3.11. A solution would be to remove the @dataclass decorator from GuestVmType definition, or use default_factory as suggested in the error message.

@squirrelsc
Copy link
Member

@LiliDeng can you help check this, and check whether 3.12 tests enabled?

@LiliDeng
Copy link
Collaborator

@LiliDeng can you help check this, and check whether 3.12 tests enabled?

sure

@LiliDeng
Copy link
Collaborator

@squirrelsc I have fixed it here #3518

@squirrelsc
Copy link
Member

@squirrelsc I have fixed it here #3518

Thank you, Lili! Do you know if why isn't caught on PR checks?

@trungams
Copy link
Member Author

fixed by #3518

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants