oTree-org / oTree

Python framework for multiplayer decision games, behavioral experiments, and surveys
https://groups.google.com/g/otree
Other
464 stars 199 forks source link

Bots don't work properly with live pages #96

Closed qwiglydee closed 3 years ago

qwiglydee commented 3 years ago

Bots code expects Page.live_method to be a string identifying method of Player - the old way.

The new way according to documentation is to make Page.live_method a static method.

Traceback (most recent call last):
  File "/usr/local/bin/otree", line 8, in <module>
    sys.exit(execute_from_command_line())
  File "/usr/local/lib/python3.8/site-packages/otree/main.py", line 113, in execute_from_command_line
    call_command(cmd, *argv[2:])
  File "/usr/local/lib/python3.8/site-packages/otree/cli/base.py", line 28, in call_command
    module.Command().outer_handle(args)
  File "/usr/local/lib/python3.8/site-packages/otree/cli/base.py", line 9, in outer_handle
    return self.handle(**vars(options))
  File "/usr/local/lib/python3.8/site-packages/otree/cli/bots.py", line 54, in handle
    run_all_bots_for_session_config(
  File "/usr/local/lib/python3.8/site-packages/otree/bots/runner.py", line 159, in run_all_bots_for_session_config
    run_bots(session_id, case_number=case_number)
  File "/usr/local/lib/python3.8/site-packages/otree/bots/runner.py", line 124, in run_bots
    runner.play()
  File "/usr/local/lib/python3.8/site-packages/otree/bots/runner.py", line 48, in play
    submission = bot.get_next_submit()
  File "/usr/local/lib/python3.8/site-packages/otree/bots/bot.py", line 233, in get_next_submit
    return next(self.submits_generator)
  File "/usr/local/lib/python3.8/site-packages/otree/bots/bot.py", line 246, in get_submits
    self.live_method_stuff(player_bot, submission)
  File "/usr/local/lib/python3.8/site-packages/otree/bots/bot.py", line 271, in live_method_stuff
    method_calls_fn(
  File "/app/shop/tests.py", line 54, in call_live_method
    method(1, 'foo')
  File "/usr/local/lib/python3.8/site-packages/otree/bots/bot.py", line 269, in method
    return getattr(players[id_in_group], live_method_name)(data)
TypeError: getattr(): attribute name must be string
oTree-org commented 3 years ago

Fixed! I just released a new version. Thank you for reporting :) and good to see people are testing their apps properly...