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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handler without engine raises error on filtered events #918

Closed
vfdev-5 opened this issue Apr 14, 2020 · 0 comments 路 Fixed by #919
Closed

Handler without engine raises error on filtered events #918

vfdev-5 opened this issue Apr 14, 2020 · 0 comments 路 Fixed by #919
Assignees
Labels
Projects

Comments

@vfdev-5
Copy link
Collaborator

vfdev-5 commented Apr 14, 2020

馃悰 Bug description

The following code does not work:

import torch
print(torch.__version__)
import ignite
print(ignite.__version__)

from ignite.engine import Engine, Events, State

def f4():
    print("f4")

    
e = Engine(lambda e, b: None)
e.state = State(iteration=0, epoch=0, max_epochs=10)

e.add_event_handler(Events.ITERATION_COMPLETED(every=2), f4)
e.fire_event(Events.ITERATION_COMPLETED)
e.fire_event(Events.ITERATION_COMPLETED)

Output


TypeErrorTraceback (most recent call last)
<ipython-input-13-832efed482dd> in <module>
     14 
     15 e.add_event_handler(Events.ITERATION_COMPLETED(every=2), f4)
---> 16 e.fire_event(Events.ITERATION_COMPLETED)
     17 e.fire_event(Events.ITERATION_COMPLETED)

/opt/conda/lib/python3.7/site-packages/ignite/engine/engine.py in fire_event(self, event_name)
    414 
    415         """
--> 416         return self._fire_event(event_name)
    417 
    418     def terminate(self) -> None:

/opt/conda/lib/python3.7/site-packages/ignite/engine/engine.py in _fire_event(self, event_name, *event_args, **event_kwargs)
    391                 kwargs.update(event_kwargs)
    392                 first, others = ((args[0],), args[1:]) if (args and args[0] == self) else ((), args)
--> 393                 func(*first, *(event_args + others), **kwargs)
    394 
    395     def fire_event(self, event_name: Any) -> None:

/opt/conda/lib/python3.7/site-packages/ignite/engine/engine.py in wrapper(engine, *args, **kwargs)
    203             event = engine.state.get_event_attrib_value(event_name)
    204             if event_filter(engine, event):
--> 205                 return handler(engine, *args, **kwargs)
    206 
    207         # setup input handler as parent to make has_event_handler work

TypeError: f4() takes 0 positional arguments but 1 was given

Environment

  • PyTorch Version (e.g., 1.4): 1.6.0.dev20200411+cu101
  • Ignite Version (e.g., 0.3.0): 0.4.0.dev20200412

@sdesrozis could you please take a look. Thanks !

@vfdev-5 vfdev-5 added the bug label Apr 14, 2020
@vfdev-5 vfdev-5 added this to To do in 0.4.0 via automation Apr 14, 2020
@sdesrozis sdesrozis mentioned this issue Apr 14, 2020
3 tasks
0.4.0 automation moved this from To do to Done Apr 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
0.4.0
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants