flow icon indicating copy to clipboard operation
flow copied to clipboard

Keyerror

Open pengyuan-zhou opened this issue 4 years ago • 4 comments

Hi, I met with KeyError: 'idm_x' (x being a number) in both h-baslines and branch maddpg testing with singleagent_traffic_light_grid, like this:

Traceback (most recent call last):
  File "experiments/run_fcnet.py", line 135, in <module>
    'data/fcnet'
  File "experiments/run_fcnet.py", line 123, in main
    initial_exploration_steps=args.initial_exploration_steps,
  File "experiments/run_fcnet.py", line 72, in run_exp
    seed=seed,
  File "/home/pengzhou/git/h-baselines/hbaselines/algorithms/off_policy.py", line 668, in learn
    random_actions=True)
  File "/home/pengzhou/git/h-baselines/hbaselines/algorithms/off_policy.py", line 815, in _collect_samples
    for env_num in range(n_steps)
  File "/home/pengzhou/miniconda3/envs/h-baselines/lib/python3.6/site-packages/ray/worker.py", line 1457, in get
    raise value.as_instanceof_cause()
ray.exceptions.RayTaskError(KeyError): ray::Sampler.collect_sample() (pid=24270, ip=192.168.0.109)
  File "python/ray/_raylet.pyx", line 636, in ray._raylet.execute_task
  File "python/ray/_raylet.pyx", line 619, in ray._raylet.execute_task.function_executor
  File "/home/pengzhou/git/h-baselines/hbaselines/utils/sampler.py", line 157, in collect_sample
    reset_obs = self.env.reset()
  File "/home/pengzhou/git/h-baselines/hbaselines/envs/mixed_autonomy/core.py", line 114, in reset
    obs = self.wrapped_env.reset()
  File "/home/pengzhou/git/flow/flow/envs/base.py", line 503, in reset
    self.setup_initial_state()
  File "/home/pengzhou/git/flow/flow/envs/base.py", line 295, in setup_initial_state
    type_id = self.k.vehicle.get_type(veh_id)
  File "/home/pengzhou/git/flow/flow/core/kernel/vehicle/traci.py", line 456, in get_type
    return self.__vehicles[veh_id]["type"]
KeyError: 'idm_4'

The error pops up after the test runs for one minute or so, and doesn't appear in "ring" test. Could it be traffic_light_grid require some dedicate modified codes?

Thank you. BR

pengyuan-zhou avatar Jun 21 '20 22:06 pengyuan-zhou

Hi! I had the exact same error when adding inflows to my network. Could you fix this? if yes, how?

Antonio-Dominguez avatar Aug 19 '20 13:08 Antonio-Dominguez

Hi! I had the exact same error when adding inflows to my network. Could you fix this? if yes, how?

Hi, I haven't followed up since then, maybe the recent code updates have solved that?

pengyuan-zhou avatar Aug 21 '20 06:08 pengyuan-zhou

I don't really know, I am working on the previous version and I was wondering if theres' a way to fix this without having to update it since that would make me modify almost everything I did. I don't understand where this error comes from. Any ideas?

Antonio-Dominguez avatar Aug 21 '20 12:08 Antonio-Dominguez

Nope, I had some other errors with previous verions then solved by the updates, so you may wanna try update. I've also seen similar erros in older issues, so there might be sth. in the code worth debugging, can't say for sure, hope someone who succesfully debugged this could join here and enlighten.

pengyuan-zhou avatar Aug 21 '20 12:08 pengyuan-zhou