icaros-usc / pyribs

A bare-bones Python library for quality diversity optimization.
https://pyribs.org
MIT License
208 stars 32 forks source link

Update lunar lander tutorial with v0.5.0 features #292

Closed btjanaka closed 1 year ago

btjanaka commented 1 year ago

Description

We update the tutorial so that it is in line with the new tutorial structure in #291. We also expand the features demonstrated in this tutorial.

Depends on #291 and #295

moviepy woes

Update: It turns out this was all due to the decorator module not being loaded properly; see https://github.com/Zulko/moviepy/issues/1625 -- we just have to reload decorator so that moviepy imports it correctly.

One notable issue was that the tutorial needed ffmpeg to be installed in order to generate videos; this happens because the new Gymansium depends on moviepy for video recording, which in turn depends on ffmpeg. This is not a problem for Colab users as ffmpeg is already installed there, but local users may encounter frustration -- the video generation happens after the run, so they may do the run, wait for 2 hours, and then see that the videos fail. The steps that fail are as follows:

  1. Create a Conda environment with Python 3.7 and activate it.
  2. Install the package with pip install -e .[visualize]
  3. Install jupyterlab with pip install jupyterlab
  4. Start jupyterlab and run the notebook.
  5. Leads to error on first display_video line with message looking like:

         86             '-s', '%dx%d' % (size[0], size[1]),
         87             '-pix_fmt', 'rgba' if withmask else 'rgb24',
    ---> 88             '-r', '%.02f' % fps,
         89             '-an', '-i', '-'
         90         ]
    
    TypeError: must be real number, not NoneType

It appears that if you re-run the notebook without changing anything, everything then works, perhaps because imageio_ffmpeg has had time to load its ffmpeg executable (under the hood moviepy uses imageio_ffmpeg to get ffmpeg).

I tried to see if we could overcome this by loading the ffmpeg executable early on, but it did not work:

import imageio_ffmpeg
imageio_ffmpeg.get_ffmpeg_exe()

I also tried installing moviepy beforehand, so if it is installed before running the notebook, everything works.

TODO

Questions

Status

btjanaka commented 1 year ago

Skipping review because we will edit all the tutorials together later.