imitation.scripts.convert_trajs#

Converts old-style pickle or npz trajectories to new-style HuggingFace datasets.

See https://github.com/HumanCompatibleAI/imitation/pull/448 for a description of the new trajectory format.

This script takes as command-line input multiple paths to saved trajectories, in the old .pkl or .npz format. It then saves each sequence in the new HuggingFace datasets format. The path is the same as the original but a directory without an extension (i.e. “A.pkl” -> “A/”, “A.npz” -> “A/”, “A/” -> “A/”, “A.foo” -> “A/”).

Functions

main()

update_traj_file_in_place(path_str, /)

Converts pickle or npz file to the new HuggingFace format.

imitation.scripts.convert_trajs.main()[source]#
imitation.scripts.convert_trajs.update_traj_file_in_place(path_str, /)[source]#

Converts pickle or npz file to the new HuggingFace format.

The new data is saved as Sequence[imitation.types.TrajectoryWithRew].

Parameters

path_str (Union[str, bytes, PathLike]) – Path to a pickle or npz file containing Sequence[imitation.types.Trajectory] or Sequence[imitation.old_types.TrajectoryWithRew].

Return type

Path

Returns

The path to the converted trajectory dataset.