Open den-schmidt opened 3 months ago
I get the same. Here is the full stack trace:
{
"name": "TypeError",
"message": "argument of type 'PosixPath' is not iterable",
"stack": "---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[106], line 11
2 print(tmpdir)
3 dagger_trainer = SimpleDAggerTrainer(
4 venv=env,
5 scratch_dir=tmpdir,
(...)
8 rng=np.random.default_rng(),
9 )
---> 11 dagger_trainer.train(2000)
File ~/miniconda3/envs/lerobot/lib/python3.10/site-packages/imitation/algorithms/dagger.py:669, in SimpleDAggerTrainer.train(self, total_timesteps, rollout_round_min_episodes, rollout_round_min_timesteps, bc_train_kwargs)
662 round_timestep_count = 0
664 sample_until = rollout.make_sample_until(
665 min_timesteps=max(rollout_round_min_timesteps, self.batch_size),
666 min_episodes=rollout_round_min_episodes,
667 )
--> 669 trajectories = rollout.generate_trajectories(
670 policy=self.expert_policy,
671 venv=collector,
672 sample_until=sample_until,
673 deterministic_policy=True,
674 rng=collector.rng,
675 )
677 for traj in trajectories:
678 self._logger.record_mean(
679 \"dagger/mean_episode_reward\",
680 np.sum(traj.rews),
681 )
File ~/miniconda3/envs/lerobot/lib/python3.10/site-packages/imitation/data/rollout.py:447, in generate_trajectories(policy, venv, sample_until, rng, deterministic_policy)
444 while np.any(active):
445 # policy gets unwrapped observations (eg as dict, not dictobs)
446 acts, state = get_actions(obs, state, dones)
--> 447 obs, rews, dones, infos = venv.step(acts)
448 assert isinstance(
449 obs,
450 (np.ndarray, dict),
451 ), \"Tuple observations are not supported.\"
452 wrapped_obs = types.maybe_wrap_in_dictobs(obs)
File ~/miniconda3/envs/lerobot/lib/python3.10/site-packages/stable_baselines3/common/vec_env/base_vec_env.py:206, in VecEnv.step(self, actions)
199 \"\"\"
200 Step the environments with the given action
201
202 :param actions: the action
203 :return: observation, reward, done, information
204 \"\"\"
205 self.step_async(actions)
--> 206 return self.step_wait()
File ~/miniconda3/envs/lerobot/lib/python3.10/site-packages/imitation/algorithms/dagger.py:285, in InteractiveTrajectoryCollector.step_wait(self)
277 fresh_demos = self.traj_accum.add_steps_and_auto_finish(
278 obs=next_obs,
279 acts=self._last_user_actions,
(...)
282 dones=dones,
283 )
284 for traj_index, traj in enumerate(fresh_demos):
--> 285 _save_dagger_demo(traj, traj_index, self.save_dir, self.rng)
287 return next_obs, rews, dones, infos
File ~/miniconda3/envs/lerobot/lib/python3.10/site-packages/imitation/algorithms/dagger.py:147, in _save_dagger_demo(trajectory, trajectory_index, save_dir, rng, prefix)
143 npz_path = save_dir / filename
144 assert (
145 not npz_path.exists()
146 ), \"The following DAgger demonstration path already exists: {0}\".format(npz_path)
--> 147 serialize.save(npz_path, [trajectory])
148 logging.info(f\"Saved demo at '{npz_path}'\")
File ~/miniconda3/envs/lerobot/lib/python3.10/site-packages/imitation/data/serialize.py:23, in save(path, trajectories)
16 \"\"\"Save a sequence of Trajectories to disk using HuggingFace's datasets library.
17
18 Args:
19 path: Trajectories are saved to this path.
20 trajectories: The trajectories to save.
21 \"\"\"
22 p = util.parse_path(path)
---> 23 huggingface_utils.trajectories_to_dataset(trajectories).save_to_disk(p)
24 logging.info(f\"Dumped demonstrations to {p}.\")
File ~/miniconda3/envs/lerobot/lib/python3.10/site-packages/datasets/arrow_dataset.py:1515, in Dataset.save_to_disk(self, dataset_path, fs, max_shard_size, num_shards, num_proc, storage_options)
1512 num_shards = num_shards if num_shards is not None else num_proc
1514 fs: fsspec.AbstractFileSystem
-> 1515 fs, _ = url_to_fs(dataset_path, **(storage_options or {}))
1517 if not is_remote_filesystem(fs):
1518 parent_cache_files_paths = {
1519 Path(cache_filename[\"filename\"]).resolve().parent for cache_filename in self.cache_files
1520 }
File ~/miniconda3/envs/lerobot/lib/python3.10/site-packages/fsspec/core.py:383, in url_to_fs(url, **kwargs)
372 known_kwargs = {
373 \"compression\",
374 \"encoding\",
(...)
380 \"num\",
381 }
382 kwargs = {k: v for k, v in kwargs.items() if k not in known_kwargs}
--> 383 chain = _un_chain(url, kwargs)
384 inkwargs = {}
385 # Reverse iterate the chain, creating a nested target_* structure
File ~/miniconda3/envs/lerobot/lib/python3.10/site-packages/fsspec/core.py:323, in _un_chain(path, kwargs)
319 def _un_chain(path, kwargs):
320 x = re.compile(\".*[^a-z]+.*\") # test for non protocol-like single word
321 bits = (
322 [p if \"://\" in p or x.match(p) else p + \"://\" for p in path.split(\"::\")]
--> 323 if \"::\" in path
324 else [path]
325 )
326 # [[url, protocol, kwargs], ...]
327 out = []
TypeError: argument of type 'PosixPath' is not iterable"
}
Bug description
Hi everyone,
I am trying to play with the DAgger example from
docs/tutorials/2_train_dagger.ipynb
but get the following error when executing the linedagger_trainer.train(2000)
:Steps to reproduce
I would be really thankful if someone could try out the steps to see if that is only my issue. To reproduce the bug, please try out the file
docs/tutorials/2_train_dagger.ipynb
as I did on my personal machine as well as in Google Colab.Environment
pip freeze --all
: I just installedimitation
+ thisapt-get install ffmpeg freeglut3-dev xvfb
beforehand. /Same for Google Colab