Montspy/LooPyGen

[python] User's GIF generation fails with: 'build_and_save_image' was never awaited

Closed this issue · 4 comments

The user initially just ran the pull commands and updated, but after getting the error they deleted the loopygen project and cloned frmo scratch again. Evidently they had an issue updating previously, and a fresh clone worked. In this instance it was a no-go, even after I had them prune the Docker images and run ./docker.sh reload

Log:

Traceback (most recent call last):
  File "/var/www/html/generator/generate.py", line 285, in <module>
    main()
  File "/var/www/html/generator/generate.py", line 279, in main
    composites = asyncio.run(generate(paths, traits, this_batch))
  File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/var/www/html/generator/generate.py", line 167, in generate
    result = await task
  File "/usr/lib/python3.9/asyncio/tasks.py", line 611, in _wait_for_one
    return f.result()  # May raise f.exception().
  File "/var/www/html/generator/generate.py", line 156, in sem_task
    return await task
  File "/var/www/html/generator/generate.py", line 130, in build_and_save_image
    composite = await img_builder.build()
  File "/var/www/html/generator/ImageBuilder.py", line 126, in build
    self._make_canvas(self.descriptors[0].fp)
  File "/usr/lib/python3.9/functools.py", line 938, in _method
    return method.__get__(obj, cls)(*args, **kwargs)
  File "/var/www/html/generator/ImageBuilder.py", line 168, in _
    self.img = ImageDescriptor(type=ImageType.STATIC, img=Image.new(mode=self.STATIC_MODE, size=self._get_size(fp)))
  File "/usr/lib/python3.9/functools.py", line 938, in _method
    return method.__get__(obj, cls)(*args, **kwargs)
  File "/var/www/html/generator/ImageBuilder.py", line 187, in _
    return tuple( (int(x) for x in subprocess.run(cmd.split(), capture_output=True, text=True).stdout.split(sep=',')) )
  File "/var/www/html/generator/ImageBuilder.py", line 187, in <genexpr>
    return tuple( (int(x) for x in subprocess.run(cmd.split(), capture_output=True, text=True).stdout.split(sep=',')) )
ValueError: invalid literal for int() with base 10: ''
Task exception was never retrieved
future: <Task finished name='Task-15' coro=<generate.<locals>.sem_task() done, defined at /var/www/html/generator/generate.py:154> exception=ValueError("invalid literal for int() with base 10: ''")>
Traceback (most recent call last):
  File "/var/www/html/generator/generate.py", line 156, in sem_task
    return await task
  File "/var/www/html/generator/generate.py", line 130, in build_and_save_image
    composite = await img_builder.build()
  File "/var/www/html/generator/ImageBuilder.py", line 126, in build
    self._make_canvas(self.descriptors[0].fp)
  File "/usr/lib/python3.9/functools.py", line 938, in _method
    return method.__get__(obj, cls)(*args, **kwargs)
  File "/var/www/html/generator/ImageBuilder.py", line 168, in _
    self.img = ImageDescriptor(type=ImageType.STATIC, img=Image.new(mode=self.STATIC_MODE, size=self._get_size(fp)))
  File "/usr/lib/python3.9/functools.py", line 938, in _method
    return method.__get__(obj, cls)(*args, **kwargs)
  File "/var/www/html/generator/ImageBuilder.py", line 187, in _
    return tuple( (int(x) for x in subprocess.run(cmd.split(), capture_output=True, text=True).stdout.split(sep=',')) )
  File "/var/www/html/generator/ImageBuilder.py", line 187, in <genexpr>
    return tuple( (int(x) for x in subprocess.run(cmd.split(), capture_output=True, text=True).stdout.split(sep=',')) )
ValueError: invalid literal for int() with base 10: ''
Task exception was never retrieved
future: <Task finished name='Task-18' coro=<generate.<locals>.sem_task() done, defined at /var/www/html/generator/generate.py:154> exception=ValueError("invalid literal for int() with base 10: ''")>
Traceback (most recent call last):
  File "/var/www/html/generator/generate.py", line 156, in sem_task
    return await task
  File "/var/www/html/generator/generate.py", line 130, in build_and_save_image
    composite = await img_builder.build()
  File "/var/www/html/generator/ImageBuilder.py", line 126, in build
    self._make_canvas(self.descriptors[0].fp)
  File "/usr/lib/python3.9/functools.py", line 938, in _method
    return method.__get__(obj, cls)(*args, **kwargs)
  File "/var/www/html/generator/ImageBuilder.py", line 168, in _
    self.img = ImageDescriptor(type=ImageType.STATIC, img=Image.new(mode=self.STATIC_MODE, size=self._get_size(fp)))
  File "/usr/lib/python3.9/functools.py", line 938, in _method
    return method.__get__(obj, cls)(*args, **kwargs)
  File "/var/www/html/generator/ImageBuilder.py", line 187, in _
    return tuple( (int(x) for x in subprocess.run(cmd.split(), capture_output=True, text=True).stdout.split(sep=',')) )
  File "/var/www/html/generator/ImageBuilder.py", line 187, in <genexpr>
    return tuple( (int(x) for x in subprocess.run(cmd.split(), capture_output=True, text=True).stdout.split(sep=',')) )
ValueError: invalid literal for int() with base 10: ''
sys:1: RuntimeWarning: coroutine 'build_and_save_image' was never awaited

Looks like it is trying to get the resolution of the first layer (with ffprobe since it's an animated one) and failing to parse the output of ffprobe.

ffprobe is installed, otherwise we'd get a FileNotFoundError
Potentially ffprobe is a different version.
Here is what I get, would be good to compare

$ ./docker.sh which ffprobe
/usr/bin/ffprobe

$ ./docker.sh ffprobe -version
ffprobe version 4.3.3-0+deb11u1 Copyright (c) 2007-2021 the FFmpeg developers
built with gcc 10 (Debian 10.2.1-6)
configuration: --prefix=/usr --extra-version=0+deb11u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil      56. 51.100 / 56. 51.100
libavcodec     58. 91.100 / 58. 91.100
libavformat    58. 45.100 / 58. 45.100
libavdevice    58. 10.100 / 58. 10.100
libavfilter     7. 85.100 /  7. 85.100
libavresample   4.  0.  0 /  4.  0.  0
libswscale      5.  7.100 /  5.  7.100
libswresample   3.  7.100 /  3.  7.100
libpostproc    55.  7.100 / 55.  7.100

Versions appear to be identical. As I mentioned in chat it seems this might be related to the GIF exports from Aseprite. I am working with the user to see what kind of options there are and if I can get a hold of the files themselves to try and suss it out.

User's output:

ffprobe version 4.3.3-0+deb11u1 Copyright (c) 2007-2021 the FFmpeg developers
built with gcc 10 (Debian 10.2.1-6)
configuration: --prefix=/usr --extra-version=0+deb11u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil      56. 51.100 / 56. 51.100
libavcodec     58. 91.100 / 58. 91.100
libavformat    58. 45.100 / 58. 45.100
libavdevice    58. 10.100 / 58. 10.100
libavfilter     7. 85.100 /  7. 85.100
libavresample   4.  0.  0 /  4.  0.  0
libswscale      5.  7.100 /  5.  7.100
libswresample   3.  7.100 /  3.  7.100
libpostproc    55.  7.100 / 55.  7.100

Further, these are the only options for exporting in the Aseprite app

image

And this is some info from MacOS on the file itself

image

I wonder if the color profile has anything to do with this, as well.

Possibly linked to file names with whitespace characters.
A fix is in 433b50e
To be tested by Vinzo