allenai/allenact

IndexError: Cannot choose from an empty sequence

GracefulMan opened this issue · 3 comments

when i run tutorial code, i get the following error, the command is

python main.py object_nav_ithor_ppo_one_object -b projects/tutorials

i want to know how to fix it?
Error detail:

Process ForkServerProcess-1:1:
Traceback (most recent call last):
  File "/home/mhy/anaconda3/envs/ai2thor/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/home/mhy/anaconda3/envs/ai2thor/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/home/mhy/research/allenact/allenact/algorithms/onpolicy_sync/vector_sampled_tasks.py", line 257, in _task_sampling_loop_worker
    should_log=should_log,
  File "/home/mhy/research/allenact/allenact/algorithms/onpolicy_sync/vector_sampled_tasks.py", line 787, in __init__
    sampler_fn_args=[{"mp_ctx": None, **args} for args in sampler_fn_args_list],
  File "/home/mhy/research/allenact/allenact/algorithms/onpolicy_sync/vector_sampled_tasks.py", line 990, in _create_generators
    if next(generators[-1]) != "started":
  File "/home/mhy/research/allenact/allenact/algorithms/onpolicy_sync/vector_sampled_tasks.py", line 848, in _task_sampling_loop_generator_fn
    current_task = task_sampler.next_task()
  File "/home/mhy/research/allenact/allenact_plugins/ithor_plugin/ithor_task_samplers.py", line 158, in next_task
    pose = self.env.randomize_agent_location()
  File "/home/mhy/research/allenact/allenact_plugins/ithor_plugin/ithor_environment.py", line 393, in randomize_agent_location
    state = self.random_reachable_state(seed=seed)
  File "/home/mhy/research/allenact/allenact_plugins/ithor_plugin/ithor_environment.py", line 375, in random_reachable_state
    xyz = random.choice(self.currently_reachable_points)
  File "/home/mhy/anaconda3/envs/ai2thor/lib/python3.7/random.py", line 261, in choice
    raise IndexError('Cannot choose from an empty sequence') from None
IndexError: Cannot choose from an empty sequence

Hey,

Sorry about this! This is a bug that exists and is being fixed in the latest version of AI2-THOR (allenai/ai2thor#618) and (allenai/ai2thor#628).

In the meantime, in the following line, if you change return self.last_event.metadata["reachablePositions"] to return self.last_event.metadata["actionReturn"], it will work immediately:

return self.last_event.metadata["reachablePositions"] # type:ignore

This appears to correspond to your path /home/mhy/research/allenact/allenact_plugins/ithor_plugin/ithor_environment.py.

Hey,

Sorry about this! This is a bug that exists and is being fixed in the latest version of AI2-THOR (allenai/ai2thor#618) and (allenai/ai2thor#628).

In the meantime, in the following line, if you change return self.last_event.metadata["reachablePositions"] to return self.last_event.metadata["actionReturn"], it will work immediately:

return self.last_event.metadata["reachablePositions"] # type:ignore

This appears to correspond to your path /home/mhy/research/allenact/allenact_plugins/ithor_plugin/ithor_environment.py.

thanks!

This should be fixed by PR #259, closing this for now but let us know if you run into any other issues.