matrx-software / matrx

Human-Agent Teaming Rapid Experimentation Software
https://www.matrx-software.com
MIT License
9 stars 3 forks source link

TypeError: 'builtin_function_or_method' object is not iterable #331

Open Krupskis opened 1 year ago

Krupskis commented 1 year ago

Describe the bug Running matrx runs into TypeError in site-packages/matrx/api/api.py", line 896, in __fetch_state_dicts To Reproduce mac m1 python: 3.9.6 This is the requirements of my project.

matrx          == 2.2.0

# all requirements below are
# additional libraries provided to do this assignment.

# libraries used by matrx and their versions, excl webserver stuff
bidict         == 0.21.2
chardet        == 4.0.0
colour         == 0.1.5
docutils       == 0.16
jsonpickle     == 1.5.1
Werkzeug       == 2.0.0
flask          == 2.1.3

# Other libraries requested by students and added to make sure
# Everyone uses the same versions.

Expected behavior I would expect no TypeError. Stacktrace The POST error just keeps getting printed every second.

/Users/martynaskrupskis/Documents/Y3Q3/CAI/brains1/HumanBrain.py:20: UserWarning: FOV Occlusion is not yet fully implemented. Setting fov_occlusion to True has no effect.
  warnings.warn("FOV Occlusion is not yet fully implemented. "
Starting background api server
Initialized app: <Flask 'matrx.api.api'>
 * Serving Flask app 'matrx.api.api' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
/Users/martynaskrupskis/Library/Python/3.9/lib/python/site-packages/matrx/world_builder.py:2403: UserWarning: A media folder path for the MATRX visualizer was given, but run_matrx_visualizer is set to False denoting that the default visualizer should not be run.
  warnings.warn("A media folder path for the MATRX visualizer was "
Starting custom visualizer
Starting visualization server
Initialized app: <Flask 'SaR_gui.visualization_server'>
 * Serving Flask app 'SaR_gui.visualization_server' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
Started world...
/Users/martynaskrupskis/Library/Python/3.9/lib/python/site-packages/matrx/agents/agent_utils/state_tracker.py:39: PendingDeprecationWarning: The StateTracker will be deprecated in a future version of MATRX, replaced by State.
  warnings.warn(
[2023-03-02 17:14:38,649] ERROR in app: Exception on /get_latest_state_and_messages [POST]
Traceback (most recent call last):
  File "/Users/martynaskrupskis/Library/Python/3.9/lib/python/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/martynaskrupskis/Library/Python/3.9/lib/python/site-packages/flask/app.py", line 1519, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/martynaskrupskis/Library/Python/3.9/lib/python/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/Users/martynaskrupskis/Library/Python/3.9/lib/python/site-packages/flask/app.py", line 1517, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/martynaskrupskis/Library/Python/3.9/lib/python/site-packages/flask/app.py", line 1503, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/Users/martynaskrupskis/Library/Python/3.9/lib/python/site-packages/matrx/api/api.py", line 138, in get_latest_state_and_messages
    states_ = __fetch_state_dicts(_current_tick, agent_id)
  File "/Users/martynaskrupskis/Library/Python/3.9/lib/python/site-packages/matrx/api/api.py", line 896, in __fetch_state_dicts
    for agent_id in ids:
TypeError: 'builtin_function_or_method' object is not iterable
[2023-03-02 17:14:38,901] ERROR in app: Exception on /get_latest_state_and_messages [POST]
Traceback (most recent call last):
  File "/Users/martynaskrupskis/Library/Python/3.9/lib/python/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/martynaskrupskis/Library/Python/3.9/lib/python/site-packages/flask/app.py", line 1519, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/martynaskrupskis/Library/Python/3.9/lib/python/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/Users/martynaskrupskis/Library/Python/3.9/lib/python/site-packages/flask/app.py", line 1517, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/martynaskrupskis/Library/Python/3.9/lib/python/site-packages/flask/app.py", line 1503, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/Users/martynaskrupskis/Library/Python/3.9/lib/python/site-packages/matrx/api/api.py", line 138, in get_latest_state_and_messages
    states_ = __fetch_state_dicts(_current_tick, agent_id)
  File "/Users/martynaskrupskis/Library/Python/3.9/lib/python/site-packages/matrx/api/api.py", line 896, in __fetch_state_dicts
    for agent_id in ids:
TypeError: 'builtin_function_or_method' object is not iterable
jwaa commented 1 year ago

Hi @Krupskis, thanks for filing the bug. Sorry for the belated response. Could you give a bit more context on what exactly you are running?

Krupskis commented 1 year ago

@jwaa Hi, I figured it out, I think. The issue was me naming the agent id. Since id is a builtin method, it resulted in the TypeError. Weird edge case, but I assume any agent id that matches the built-in function or method name will result in this error.

jwaa commented 1 year ago

@Krupskis, good to hear you figured it out on your own. Indeed a strange edge-case. Could you share your built world and - if you have one - your custom agent? That way we can test it ourselves and either solve it or make a more elligible stacktrace.

Krupskis commented 1 year ago

https://github.com/rsverhagen94/TUD-Collaborative-AI-2023 This is the world I am using. You can find the installation guide in the README. Once you run it it will ask you for several prompts. Might not work with python 3.10 and above.

  1. Choose official world
  2. Use id as a human name, or any other built-in function should work
  3. Choose normal

The world will start and you should see the terminal blow up with the TypeError messages.