Skip to content

Issue with Enum on Python3.11 #2904

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

Closed
kalkun opened this issue Mar 31, 2023 · 2 comments · Fixed by #2907
Closed

Issue with Enum on Python3.11 #2904

kalkun opened this issue Mar 31, 2023 · 2 comments · Fixed by #2907
Labels

Comments

@kalkun
Copy link

kalkun commented Mar 31, 2023

🐛 Bug description

Importing ignite.distributed fails on Python3.11.

To reproduce:

python3.11 -m pip install pytorch-ignite
python3.11 -c 'import ignite.distributed'

I get the following AttributeError:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/homebrew/lib/python3.11/site-packages/ignite/__init__.py", line 3, in <module>
    import ignite.engine
  File "/opt/homebrew/lib/python3.11/site-packages/ignite/engine/__init__.py", line 7, in <module>
    from ignite.engine.deterministic import DeterministicEngine
  File "/opt/homebrew/lib/python3.11/site-packages/ignite/engine/deterministic.py", line 11, in <module>
    from ignite.engine.engine import Engine
  File "/opt/homebrew/lib/python3.11/site-packages/ignite/engine/engine.py", line 13, in <module>
    from ignite.engine.events import CallableEventWithFilter, EventEnum, Events, EventsList, RemovableEventHandle, State
  File "/opt/homebrew/lib/python3.11/site-packages/ignite/engine/events.py", line 254, in <module>
    class Events(EventEnum):
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/enum.py", line 560, in __new__
    raise exc
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/enum.py", line 280, in __set_name__
    enum_member = enum_class._value2member_map_[value]
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/ignite/engine/events.py", line 200, in __hash__
    return hash(self._name_)
                ^^^^^^^^^^^
AttributeError: 'CallableEventWithFilter' object has no attribute '_name_'. Did you mean: 'name'?

Environment

  • PyTorch Version: 2.0.0
  • Ignite Version: 0.4.11
  • OS (e.g., Linux): macOS Ventura 13.2.1
  • How you installed Ignite: pip
  • Python version: 3.11
@vfdev-5
Copy link
Collaborator

vfdev-5 commented Mar 31, 2023

@kalkun thanks a lot for reporting this issue! Definitely, we have to fix this.

@vfdev-5 vfdev-5 added bug module: engine Engine module labels Mar 31, 2023
vfdev-5 added a commit that referenced this issue Apr 6, 2023
Fixes #2904

- Replaced DynamicClassAttribute by property
- other minor updates
@vfdev-5 vfdev-5 changed the title Cannot import ignite.distributed on Python3.11 Issue with Enum on Python3.11 Apr 26, 2023
@vfdev-5
Copy link
Collaborator

vfdev-5 commented Apr 26, 2023

Just for visibility:

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