Re: debug moviepy with jgart

2023-01-27 Thread jgart
Thanks for the reply.

Interestingly, there is no hypothesis code in the moviepy tests so I'm not sure 
why we get that plugins output section mentioning hypothesis.

I wonder if there's a way to start pdb or pudb in the failed build environment 
so that I can step through the test? hmmm

Will try that next... for fun

Here's one test that fails:

# -*- coding: utf-8 -*-
"""Image sequencing clip tests meant to be run with pytest."""
import os
import sys

import pytest

from moviepy.video.io.ImageSequenceClip import ImageSequenceClip

from .test_helper import TMP_DIR


def test_1():
images=[]
durations=[]

for i in range(5):
durations.append(i)
images.append("media/python_logo.png")
durations.append(i)
images.append("media/python_logo_upside_down.png")

with ImageSequenceClip(images, durations=durations) as clip:
assert clip.duration == sum(durations)
clip.write_videofile(os.path.join(TMP_DIR, "ImageSequenceClip1.mp4"), 
fps=30)

def test_2():
images=[]
durations=[]

durations.append(1)
images.append("media/python_logo.png")
durations.append(2)
images.append("media/matplotlib_demo1.png")

#images are not the same size..
with pytest.raises(Exception):
 ImageSequenceClip(images, durations=durations).close()


if __name__ == '__main__':
   pytest.main()

and here's the test failure output:

 test_1 

def test_1():
images=[]
durations=[]

for i in range(5):
durations.append(i)
images.append("media/python_logo.png")
durations.append(i)
images.append("media/python_logo_upside_down.png")

with ImageSequenceClip(images, durations=durations) as clip:
assert clip.duration == sum(durations)
>   clip.write_videofile(os.path.join(TMP_DIR, 
> "ImageSequenceClip1.mp4"), fps=30)

tests/test_ImageSequenceClip.py:25: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/gnu/store/zfw5y8356i5hmfghpix46qk3iaxg3i6y-python-decorator-5.0.9/lib/python3.9/site-packages/decorator.py:232:
 in fun
return caller(func, *(extras + args), **kw)
moviepy/decorators.py:54: in requires_duration
return f(clip, *a, **k)
/gnu/store/zfw5y8356i5hmfghpix46qk3iaxg3i6y-python-decorator-5.0.9/lib/python3.9/site-packages/decorator.py:232:
 in fun
return caller(func, *(extras + args), **kw)
moviepy/decorators.py:135: in use_clip_fps_by_default
return f(clip, *new_a, **new_kw)
/gnu/store/zfw5y8356i5hmfghpix46qk3iaxg3i6y-python-decorator-5.0.9/lib/python3.9/site-packages/decorator.py:232:
 in fun
return caller(func, *(extras + args), **kw)
moviepy/decorators.py:22: in convert_masks_to_RGB
return f(clip, *a, **k)
moviepy/video/VideoClip.py:300: in write_videofile
ffmpeg_write_video(self, filename, fps, codec,
moviepy/video/io/ffmpeg_writer.py:213: in ffmpeg_write_video
with FFMPEG_VideoWriter(filename, clip.size, fps, codec = codec,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = 
filename = '/tmp/guix-build-python-moviepy-1.0.3.drv-0/ImageSequenceClip1.mp4'
size = (260, 77), fps = None, codec = 'libx264', audiofile = None
preset = 'medium', bitrate = None, withmask = False, logfile = -1
threads = None, ffmpeg_params = None

def __init__(self, filename, size, fps, codec="libx264", audiofile=None,
 preset="medium", bitrate=None, withmask=False,
 logfile=None, threads=None, ffmpeg_params=None):

if logfile is None:
logfile = sp.PIPE

self.filename = filename
self.codec = codec
self.ext = self.filename.split(".")[-1]

# order is important
cmd = [
get_setting("FFMPEG_BINARY"),
'-y',
'-loglevel', 'error' if logfile == sp.PIPE else 'info',
'-f', 'rawvideo',
'-vcodec', 'rawvideo',
'-s', '%dx%d' % (size[0], size[1]),
'-pix_fmt', 'rgba' if withmask else 'rgb24',
>   '-r', '%.02f' % fps,
'-an', '-i', '-'
]
E   TypeError: must be real number, not NoneType

moviepy/video/io/ffmpeg_writer.py:88: TypeError

--

Here's the Guix package for the curious:

;;; GNU Guix --- Functional package management for GNU
;;;
;;; Copyright © 2022 jgart 
;;; This file is not part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more 

Re: debug moviepy with jgart

2023-01-27 Thread Development of GNU Guix and the GNU System distribution.
> Hi,
> 
> I'm trying to get the tests to pass for a Guix package that I am writing for 
> moviepy.
> 
> Any thoughts on how to resolve the below failures?
> 
> I need to make some dir writeable?

Hello,

The non-writeable cache dir error seems to be coming from an imagemagick
subprocess. So yeah, we could look at what imagemagick needs for a
cache directory.

There are many errors so I'd try tackling them one by one. Starting
with those that are more obvious to be related to the environment and
IO (and hoping fixing them will also fix some of the non-obvious ones).

You could try using the approach described in [1] to enter the build
environment. Then you can rerun the Hypothesis tests by hand. I'd look
into Hypothesis documentation and check how to only run a sepcific test
to save time. I'd then also check the other options of the tool —
perhaps there's a way to increase verbosity in test output?

Good luck,
Wojtek

[1] https://guix.gnu.org/manual/en/html_node/Debugging-Build-Failures.html


pgpN5IhTmSymk.pgp
Description: OpenPGP digital signature