sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.38k stars 471 forks source link

ffmpeg/imagemagick features need feature checks #33092

Closed orlitzky closed 2 years ago

orlitzky commented 2 years ago

We have optional tests that make use of these packages, for example:

sage: a.show(format="webm", iterations=1)  # optional -- ffmpeg
sage: with open(td + 'wave.gif', 'rb') as f: print(b'!\xf9\x04\x08\x14\x00' in f.read())  # optional -- ImageMagick

These tests are run whenever the corresponding "feature" is available, but the feature checks look only for the convert and ffmpeg programs. Both imagemagick and ffmpeg can be built without support for (say) webm files, making the tests above fail. To avoid spurious failures, the features should test for the necessary file format support, likely in the is_functional() method.

CC: @seblabbe

Component: packages: optional

Author: Sébastien Labbé

Branch: 1678c7f

Reviewer: Julian Rüth, Michael Orlitzky

Issue created by migration from https://trac.sagemath.org/ticket/33092

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 3961423 to 9810e58

seblabbe commented 2 years ago
comment:43

It is not ready for review. In the current state, the doctest framework is stock in an infinite loop with the command sage -t src/sage/features/ffmpeg.py, but it is fine with sage -t src/sage/features/imagemagick.py?

seblabbe commented 2 years ago
comment:44

I still do not understand how the command sage -t src/sage/features/ffmpeg.py get stuck:

$ sage -t ffmpeg.py 
[...]
Doctesting 1 file.
sage -t --random-seed=168065381240033119635518975867815506494 ffmpeg.py

It comes from the optional tags because if I do:

diff --git a/src/sage/features/ffmpeg.py b/src/sage/features/ffmpeg.py
index a2661b33be..fdc638e1b9 100644
--- a/src/sage/features/ffmpeg.py
+++ b/src/sage/features/ffmpeg.py
@@ -21,7 +21,7 @@ class FFmpeg(Executable):
     EXAMPLES::

         sage: from sage.features.ffmpeg import FFmpeg
-        sage: FFmpeg().is_present()  # optional - ffmpeg
+        sage: FFmpeg().is_present()
         FeatureTestResult('ffmpeg', True)
     """
     def __init__(self):
@@ -43,7 +43,7 @@ class FFmpeg(Executable):
         EXAMPLES::

             sage: from sage.features.ffmpeg import FFmpeg
-            sage: FFmpeg().is_functional()   # optional - ffmpeg
+            sage: FFmpeg().is_functional()
             FeatureTestResult('ffmpeg', True)

         """

then, I get

$ sage -t ffmpeg.py 
[...]
Doctesting 1 file.
sage -t --random-seed=336902193762431828596947527190320053620 ffmpeg.py
    [6 tests, 0.11 s]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------

Can someone help understand the problem? The command sage -t ffmpeg.py sees there are optional tags ffmpeg which calls the method in the file ffmpeg.py and then what? This works for all other files in src/sage/features. Why doesn't it work for ffmpeg.py ?

seblabbe commented 2 years ago
comment:45

Regardless of the infinite loop bug while doctesting, the current state makes the following to work:

sage: from sage.features.ffmpeg import FFmpeg
sage: FFmpeg().is_present()
FeatureTestResult('ffmpeg', True)
sage: FFmpeg().is_functional()
FeatureTestResult('ffmpeg', True)
sage: FFmpeg().require()

@orlitzky: Can you provide the output of the above for your machine?

@orlitzky: Also, can you confirm you also have a infinite loop while testing sage -t src/sage/features/ffmpeg.py or maybe you won't have the infinite loop since the feature ffmpeg turns out not to be present and functional. If no infinite loop, you can also report whether sage -t src/sage/plot/animate.py looks better.

orlitzky commented 2 years ago
comment:46

Replying to @seblabbe:

@orlitzky: Can you provide the output of the above for your machine?

Looks like it should with the busted ffmpeg:

sage: from sage.features.ffmpeg import FFmpeg
sage: FFmpeg().is_present()
FeatureTestResult('ffmpeg', False)
sage: FFmpeg().is_functional()
FeatureTestResult('ffmpeg', False)
sage: FFmpeg().require()
---------------------------------------------------------------------------
FeatureNotPresentError                    Traceback (most recent call last)
...

@orlitzky: Also, can you confirm you also have a infinite loop while testing sage -t src/sage/features/ffmpeg.py

But I also get the infinite loop. Should be a fun mystery since I don't see anything obviously wrong in ffmpeg.py.

seblabbe commented 2 years ago
comment:47

Replying to @orlitzky:

FeatureNotPresentError                    Traceback (most recent call last)
...

Actually, could you paste the full output of FFmpeg().require()? I have been trying to improve the way the error is printed. In ffmpeg.log, an error is reported, but we can't see what exactly. This should be better now.

But I also get the infinite loop. Should be a fun mystery since I don't see anything obviously wrong in ffmpeg.py.

Do you have an infinite loop when you run sage -t src/sage/plot/animate.py ?

orlitzky commented 2 years ago
comment:48

Ok:

sage: from sage.features.ffmpeg import FFmpeg
sage: FFmpeg().require()
---------------------------------------------------------------------------
FeatureNotPresentError                    Traceback (most recent call last)
<ipython-input-2-e403f9ac9adf> in <module>
----> 1 FFmpeg().require()

~/src/sage.git/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/features/__init__.py in require(self)
    204         presence = self.is_present()
    205         if not presence:
--> 206             raise FeatureNotPresentError(self, presence.reason, presence.resolution)
    207 
    208     def __repr__(self):

FeatureNotPresentError: ffmpeg is not available.
Running command "['ffmpeg', '-y', '-f', 'image2', '-r', '5', '-i', 'tmp_w2ac36zy.png', '-pix_fmt', 'rgb24', '-loop', '0', 'tmp_w2ac36zy.gif']" returned non-zero exit status "1" with stderr "ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 11.2.0 (Gentoo Hardened 11.2.0 p1)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --docdir=/usr/share/doc/ffmpeg-4.4.1-r1/html --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --nm=x86_64-pc-linux-gnu-nm --ranlib=x86_64-pc-linux-gnu-ranlib --pkg-config=x86_64-pc-linux-gnu-pkg-config --optflags='-O2 -pipe -march=native -fuse-ld=mold' --extra-libs= --disable-static --enable-avfilter --enable-avresample --disable-stripping --disable-optimizations --disable-libcelt --disable-encoders --disable-indev=v4l2 --disable-outdev=v4l2 --disable-indev=alsa --disable-indev=oss --disable-indev=jack --disable-indev=sndio --disable-outdev=alsa --disable-outdev=oss --disable-outdev=sndio --disable-bzlib --disable-runtime-cpudetect --disable-debug --disable-gcrypt --disable-gnutls --disable-gmp --disable-gpl --disable-hardcoded-tables --disable-iconv --disable-libxml2 --disable-lzma --disable-network --disable-opencl --disable-openssl --disable-postproc --disable-libsmbclient --disable-ffplay --disable-sdl2 --disable-vaapi --disable-vdpau --disable-vulkan --disable-xlib --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --disable-zlib --disable-libcdio --disable-libiec61883 --disable-libdc1394 --disable-libcaca --disable-openal --disable-opengl --disable-libv4l2 --disable-libpulse --disable-libdrm --disable-libjack --disable-libopencore-amrwb --disable-libopencore-amrnb --disable-libcodec2 --disable-libdav1d --disable-libfdk-aac --disable-libopenjpeg --disable-libbluray --disable-libgme --disable-libgsm --disable-libaribb24 --disable-mmal --disable-libmodplug --disable-libopus --disable-libilbc --disable-librtmp --disable-libssh --disable-libspeex --disable-libsrt --disable-librsvg --disable-ffnvcodec --disable-libvorbis --disable-libvpx --disable-libzvbi --disable-appkit --disable-libbs2b --disable-chromaprint --disable-cuda-llvm --disable-libflite --disable-frei0r --disable-libfribidi --disable-fontconfig --disable-ladspa --disable-libass --disable-libtesseract --disable-lv2 --disable-libfreetype --disable-libvidstab --disable-librubberband --disable-libzmq --disable-libzimg --disable-libsoxr --disable-pthreads --disable-armv5te --disable-armv6 --disable-armv6t2 --disable-neon --disable-vfp --disable-vfpv3 --disable-armv8 --disable-mipsdsp --disable-mipsdspr2 --disable-mipsfpu --disable-altivec --disable-vsx --disable-power8 --disable-amd3dnow --disable-amd3dnowext --disable-aesni --disable-avx --disable-avx2 --disable-fma3 --disable-fma4 --disable-mmx --disable-mmxext --disable-sse --disable-sse2 --disable-sse3 --disable-ssse3 --disable-sse4 --disable-sse42 --disable-xop --cpu=host --disable-doc --disable-htmlpages --enable-manpages
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
[image2 @ 0x55f828dd4680] Could not find codec parameters for stream 0 (Video: png, none): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Input #0, image2, from 'tmp_w2ac36zy.png':
  Duration: 00:00:00.20, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: png, none, 5 fps, 5 tbr, 5 tbn, 5 tbc
Automatic encoder selection failed for output stream #0:0. Default encoder for format gif (codec gif) is probably disabled. Please choose an encoder manually.
Error selecting an encoder for stream 0:0" and stdout "".
No equivalent system packages for gentoo are known to Sage.
To install ffmpeg using the Sage package manager, you can try to run:
  !sage -i ffmpeg
No equivalent system packages for pip are known to Sage.
Further installation instructions might be available at https://www.ffmpeg.org/.
orlitzky commented 2 years ago
comment:49

You can eliminate the hang with,

diff --git a/src/sage/features/ffmpeg.py b/src/sage/features/ffmpeg.py
index a2661b33be..aa818a9e79 100644
--- a/src/sage/features/ffmpeg.py
+++ b/src/sage/features/ffmpeg.py
@@ -75,9 +75,8 @@ class FFmpeg(Executable):

         # running the command (taken from sage/plot/animate.py)
         from subprocess import run
-        cmd = ['ffmpeg', '-y', '-f', 'image2', '-r', '5', '-i',
-               filename_png, '-pix_fmt', 'rgb24', '-loop', '0',
-               filename_gif]
+        cmd = ['convert', '-dispose', 'Background', '-delay', '20',
+                '-loop', '0', filename_png, filename_gif]
         result = run(cmd, cwd=base, capture_output=True, text=True)

         # If an error occured, return False

which is pretty amazing to me.

seblabbe commented 2 years ago
comment:50

Ok, I think I have found the loop which loops over and over. With the following change

diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py
index 6f49a48021..b9c6544584 100644
--- a/src/sage/doctest/forker.py
+++ b/src/sage/doctest/forker.py
@@ -1787,6 +1787,7 @@ class DocTestDispatcher(SageObject):
                     sel.__exit__(None, None, None)

                 while True:
+                    print('infinite loop is here')
                     # To avoid calling time.time() all the time while
                     # checking for timeouts, we call it here, once per
                     # loop. It's not a problem if this isn't very

then, I get:

$ sage -t src/sage/features/ffmpeg.py 
[...]
Doctesting 1 file.
infinite loop is here
infinite loop is here
sage -t --random-seed=86298206900732853338809268896610660473 ../features/ffmpeg.py
infinite loop is here
infinite loop is here
infinite loop is here
infinite loop is here
infinite loop is here
infinite loop is here
infinite loop is here
infinite loop is here
infinite loop is here
...

Also, the log of forker.py indicates that a recent change was made on it at #33032. I don't know if it is related.

seblabbe commented 2 years ago
comment:51

Replying to @seblabbe:

Also, the log of forker.py indicates that a recent change was made on it at #33032. I don't know if it is related.

Undoing #33032 does not change anything. It is unrelated.

seblabbe commented 2 years ago
comment:52

Replying to @orlitzky:

You can eliminate the hang with, [...] which is pretty amazing to me.

Conversely, the following creates an hang for sage -t src/sage/features/imagemagick.py:

diff --git a/src/sage/features/imagemagick.py b/src/sage/features/imagemagick.py
index 0b58946919..5de9ef679d 100644
--- a/src/sage/features/imagemagick.py
+++ b/src/sage/features/imagemagick.py
@@ -79,8 +79,9 @@ class convert(Executable):

         # running command convert (taken from sage/plot/animate.py)
         from subprocess import run
-        cmd = ['convert', '-dispose', 'Background', '-delay', '20',
-                '-loop', '0', filename_png, filename_gif]
+        cmd = ['ffmpeg', '-y', '-f', 'image2', '-r', '5', '-i',
+               filename_png, '-pix_fmt', 'rgb24', '-loop', '0',
+               filename_gif]
         result = run(cmd, cwd=base, capture_output=True, text=True)

         # If an error occured, return False

What does it mean?

seblabbe commented 2 years ago
comment:53

Something seems to be wrong in the parallel_dispatch method of the doctest/forker.py file because using serial_dispatch works fine:

$ sage -t --serial src/sage/features/ffmpeg.py 
[...]
Doctesting 1 file.
sage -t --random-seed=282697849359684697319918281520742422437 src/sage/features/ffmpeg.py
    [6 tests, 0.06 s]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Features detected for doctesting: ffmpeg

Note that the --serial option is not mentionned in the doc of sage -t -h, but it is mentionned in the dispatch method in the forker.py file.

I still don't know how the ffmpeg.py file produces the infinite loop for sage -t.

seblabbe commented 2 years ago
comment:54

Doing small progres... It seems the chosen command to test ffmpeg hangs when called within the doctest framework in a non serial way (which is the default):

i.e., with

diff --git a/src/sage/features/ffmpeg.py b/src/sage/features/ffmpeg.py
index a2661b33be..105572849d 100644
--- a/src/sage/features/ffmpeg.py
+++ b/src/sage/features/ffmpeg.py
@@ -78,7 +78,9 @@ class FFmpeg(Executable):
         cmd = ['ffmpeg', '-y', '-f', 'image2', '-r', '5', '-i',
                filename_png, '-pix_fmt', 'rgb24', '-loop', '0',
                filename_gif]
+        print('before')
         result = run(cmd, cwd=base, capture_output=True, text=True)
+        print('after')

         # If an error occured, return False
         if result.returncode:

it gives:

$ sage -t --serial src/sage/features/ffmpeg.py 
...
Doctesting 1 file.
sage -t --random-seed=307360575550711922927379583574768772711 src/sage/features/ffmpeg.py
before
after
**********************************************************************
File "src/sage/features/ffmpeg.py", line 46, in sage.features.ffmpeg.FFmpeg.is_functional
Failed example:
    FFmpeg().is_functional()   # optional - ffmpeg
Expected:
    FeatureTestResult('ffmpeg', True)
Got:
    before
    after
    FeatureTestResult('ffmpeg', True)
**********************************************************************
1 item had failures:
   1 of   3 in sage.features.ffmpeg.FFmpeg.is_functional
    [6 tests, 1 failure, 0.06 s]

but

$ sage -t src/sage/features/ffmpeg.py 
...
Doctesting 1 file.
before
sage -t --random-seed=9443241230115374037438588873102610711 src/sage/features/ffmpeg.py
^CKilling test src/sage/features/ffmpeg.py
----------------------------------------------------------------------
Doctests interrupted: 0/1 files tested
----------------------------------------------------------------------

only prints before.

seblabbe commented 2 years ago
comment:55

Replacing the ffmpeg test command by something simpler like cmd = ['ffmpeg', '-i', filename_png, filename_gif] still hangs.

seblabbe commented 2 years ago
comment:56

The documentation of subprocess.run says that it "run the command described by args. Wait for command to complete, then return a CompletedProcess instance."

Maybe the fact of running the doctests within parallel threads makes it so that the ffmpeg command run by run does not complete?

seblabbe commented 2 years ago
comment:57

Got it!

https://stackoverflow.com/questions/16523746/ffmpeg-hangs-when-run-in-background

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 9810e58 to 34c2bb3

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

34c2bb333092: ffmpeg-hangs-when-run-in-background
seblabbe commented 2 years ago
comment:59

@orlitzky: Are the only remainings issues the one reported in #33092 comment:33 ?

orlitzky commented 2 years ago
comment:60

Replying to @seblabbe:

Got it! https://stackoverflow.com/questions/16523746/ffmpeg-hangs-when-run-in-background

Congrats =)

I spent a long time on that today before I got dragged away on work.

@orlitzky: Are the only remainings issues the one reported in #33092 comment:33 ?

There are still some ffmpeg issues. Unlike with imagemagick, we try several different formats with ffmpeg and all need to be supported. For example, having re-enabled whatever I needed to get is_functional() to pass,

File "src/sage/plot/animate.py", line 806, in sage.plot.animate.Animation.show
Failed example:
    a.show(format="webm")        # optional -- ffmpeg
Exception raised:
    Traceback (most recent call last):
      File "/home/mjo/src/sage.git/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/doctest/forker.py", line 694, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/mjo/src/sage.git/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/doctest/forker.py", line 1088, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.plot.animate.Animation.show[2]>", line 1, in <module>
        a.show(format="webm")        # optional -- ffmpeg
      File "/home/mjo/src/sage.git/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/plot/animate.py", line 845, in show
        dm.display_immediately(self, **kwds)
      File "/home/mjo/src/sage.git/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/repl/rich_output/display_manager.py", line 851, in display_immediately
        plain_text, rich_output = self._rich_output_formatter(obj, rich_repr_kwds)
      File "/home/mjo/src/sage.git/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/repl/rich_output/display_manager.py", line 643, in _rich_output_formatter
        rich_output = self._call_rich_repr(obj, rich_repr_kwds)
      File "/home/mjo/src/sage.git/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/repl/rich_output/display_manager.py", line 601, in _call_rich_repr
        return obj._rich_repr_(self, **rich_repr_kwds)
      File "/home/mjo/src/sage.git/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/plot/animate.py", line 747, in _rich_repr_
        self.save(filename, **kwds)
      File "/home/mjo/src/sage.git/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/plot/animate.py", line 1139, in save
        self.ffmpeg(savefile=filename, show_path=show_path, **kwds)
      File "/home/mjo/src/sage.git/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/plot/animate.py", line 984, in ffmpeg
        check_call(cmd, shell=True, stderr=set_stderr)
      File "/usr/lib/python3.9/subprocess.py", line 373, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command 'cd "/home/mjo/.sage/temp/gantu/18412/dir_674m51c2/"; sage-native-execute ffmpeg -y -f image2  -i /home/mjo/.sage/temp/gantu/18412/dir_674m51c2/%08d.png  /home/mjo/.sage/temp/gantu/18412/tmp_9iod6cgx.webm' returned non-zero exit status 1.

I would imagine we need similar checks for

sage: a.show(format="ogg")         # optional -- ffmpeg
sage: a.show(format="mp4")         # optional -- ffmpeg

and I'll try to confirm that.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

9287a8733092: testing all possible outputs for ffmpeg in is_functional
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 34c2bb3 to 9287a87

seblabbe commented 2 years ago
comment:62

I added all outputs that I can see in the ffmpeg.log in which we can see two different kind of commands invoking ffmpeg. Only the format '.mpg' is incompatible with rbg24 parameter.

On my machine, require() now takes 1s, but it is cached:

sage: from sage.features.ffmpeg import FFmpeg
sage: %time FFmpeg().require()
CPU times: user 15.5 ms, sys: 69.2 ms, total: 84.7 ms
Wall time: 1.02 s
sage: %time FFmpeg().require()
CPU times: user 16 µs, sys: 0 ns, total: 16 µs
Wall time: 17.6 µs
orlitzky commented 2 years ago
comment:63

The latest commit is working for me (at least as far as ffmpeg is concerned). The only other test that I was able to make fail was the ogg one. The others like flash and wmv seem to pass anyway even though I definitely don't have support for those formats.

orlitzky commented 2 years ago
comment:64

I would rather have this once during ./configure than in each invocation of sage -t, but that's a problem for another day:

sage: from sage.features.ffmpeg import FFmpeg
sage: %time FFmpeg().require()
CPU times: user 89.6 ms, sys: 288 ms, total: 378 ms
Wall time: 3 s

In other news, I finally figured out how to get ffmpeg to write a webm file.

orlitzky commented 2 years ago
comment:65

One more thing. If I build both a working ffmpeg AND a working imagemagick... the whole thing times out because the file takes ~440s and the default timeout is 300s:

$ sage -t src/sage/plot/animate.py 
Running doctests with ID 2022-01-05-17-59-38-b1f4a523.
Git branch: u/slabbe/33092
Using --optional=build,dochtml,gentoo,pip,sage,sage_spkg
Features to be detected: 4ti2,benzene,bliss,buckygen,conway_polynomials,csdp,database_cremona_ellcurve,database_cremona_mini_ellcurve,database_jones_numfield,database_knotinfo,dvipng,ffmpeg,graphviz,imagemagick,jupymake,kenzo,latte_int,lrslib,mcqd,meataxe,pandoc,pdf2svg,plantri,pynormaliz,rubiks,sage.combinat,sage.geometry.polyhedron,sage.graphs,sage.plot,sage.rings.number_field,sage.rings.real_double,sage.symbolic,sage_numerical_backends_coin,tdlib
Doctesting 1 file.
sage -t --warn-long 318.1 --random-seed=248859399066678770036022680812692330020 src/sage/plot/animate.py
    Timed out
...
Total time for all tests: 300.8 seconds

32973 is a quick band-aid.

seblabbe commented 2 years ago
comment:66

ffmpeg tests that times out are tracked at #33045. Should these be dealt here or there?

seblabbe commented 2 years ago
comment:67

Replying to @orlitzky:

I would rather have this once during ./configure than in each invocation of sage -t, but that's a problem for another day:

sage: from sage.features.ffmpeg import FFmpeg
sage: %time FFmpeg().require()
CPU times: user 89.6 ms, sys: 288 ms, total: 378 ms
Wall time: 3 s

Maybe the current is_functional() for ffmpeg is exagerated. Maybe we can simplify and test only few well-chosen formats? If so, which formats do you think?

Or make them choose some at random? But, I guess this is not good as we may want is_functional to be consistent and reproducible.

orlitzky commented 2 years ago
comment:68

Replying to @seblabbe:

Maybe the current is_functional() for ffmpeg is exagerated. Maybe we can simplify and test only few well-chosen formats? If so, which formats do you think?

It's OK, we have to test everything we use in a doctest. It's possible that on a machine with e.g. wmv support, show(format="wmv") will actually try to use it, so we should leave those feature check in. At least until someone takes the time to evaluate if those doctests/examples are actually useful.

sheerluck commented 2 years ago
comment:69

ffmpeg without theora fails with Default encoder for format ogg (codec theora) is probably disabled

ffmpeg with theora passes all tests

sage -t --random-seed=35 src/sage/combinat/crystals/mv_polytopes.py
    [67 tests, 35.32 s]
sage -t --random-seed=35 src/sage/combinat/tiling.py
    [466 tests, 523.42 s]
sage -t --random-seed=35 src/sage/combinat/words/paths.py
    [513 tests, 130.42 s]
sage -t --random-seed=35 src/sage/doctest/external.py
    [41 tests, 2.32 s]
sage -t --random-seed=35 src/sage/features/ffmpeg.py
    [6 tests, 2.93 s]
sage -t --random-seed=35 src/sage/features/imagemagick.py
    [11 tests, 0.12 s]
sage -t --random-seed=35 src/sage/features/latex.py
    [19 tests, 0.06 s]
sage -t --random-seed=35 src/sage/plot/animate.py
    [232 tests, 183.16 s]
sage -t --random-seed=35 src/sage/plot/plot3d/tachyon.py
    [404 tests, 15.03 s]
seblabbe commented 2 years ago
comment:70

Replying to @sheerluck:

ffmpeg without theora fails with Default encoder for format ogg (codec theora) is probably disabled

Ok, this shows good things. For example, with the changes made, it does not swallow the error message anymore, so now we know why.

Also, something looks weird to me. Let me copy-paste the following part to explain:

sage -t --random-seed=262088897290595662578101588392178009818 src/sage/features/ffmpeg.py
**********************************************************************
File "src/sage/features/ffmpeg.py", line 24, in sage.features.ffmpeg.FFmpeg
Failed example:
    FFmpeg().is_present()
Expected:
    FeatureTestResult('ffmpeg', True)
Got:
    FeatureTestResult('ffmpeg', False)
**********************************************************************
File "src/sage/features/ffmpeg.py", line 46, in sage.features.ffmpeg.FFmpeg.is_functional
Failed example:
    FFmpeg().is_functional()
Expected:
    FeatureTestResult('ffmpeg', True)
Got:
    FeatureTestResult('ffmpeg', False)
**********************************************************************
2 items had failures:
   1 of   3 in sage.features.ffmpeg.FFmpeg
   1 of   3 in sage.features.ffmpeg.FFmpeg.is_functional
    [6 tests, 2 failures, 0.76 s]

So FFmpeg().require() works well in the sense that it detects that something does not work well with ffmpeg (related to ogg format). But then, this status should imply that doctests with optional tag ffmpeg are not run. Related to that, I observe above that the optional tag ffmpeg has disappeared:

    FFmpeg().is_present()

as opposed to

    FFmpeg().is_present() # optional -- ffmpeg

This may explain that those tests are run while they should not. So why are the optional ffmpeg tags gone?

sheerluck commented 2 years ago
comment:71

Replying to @seblabbe:

So why are the optional ffmpeg tags gone?

I deleted them I wanted to run all tests.

seblabbe commented 2 years ago
comment:72

Replying to @sheerluck:

Replying to @seblabbe:

So why are the optional ffmpeg tags gone?

I deleted them I wanted to run all tests.

Note that you can use --optional=sage,ffmpeg if you want to test all doctests with no tags + doctests with tag ffmpeg. Also you can use --optional=sage,optional,ffmpeg to also test all optional features available on the machine while still forcing the test of doctests tagged with ffmpeg. I think this allows you to do the same thing without editing/removing the tags in the source code.

sheerluck commented 2 years ago
comment:73

Thank you, with very long

--optional=arch,mathics,argcomplete,build,dochtml,pip,sage,sage_spkg,polymake,ffmpeg,imagemagick,latex,pandoc

for src/sage/combinat/tiling.py I got 489 tests passed, even more than 466 tests in comment 69.

I'm positive this ticket is ready for positive review :)

orlitzky commented 2 years ago
comment:74

Replying to @sheerluck:

I'm positive this ticket is ready for positive review :)

I still have the failures in comment:33 with my "normal" imagemagick. I would try b"GIF8" in f.read() rather than looking for a specific binary sequence.

seblabbe commented 2 years ago
comment:75

Replying to @sheerluck:

Thank you, with very long

--optional=arch,mathics,argcomplete,build,dochtml,pip,sage,sage_spkg,polymake,ffmpeg,imagemagick,latex,pandoc

for src/sage/combinat/tiling.py I got 489 tests passed, even more than 466 tests in comment 69.

I also get 489 tests passed (with --long) for that file. Note that you can use --show-skipped to list how many tests of each tag were skipped.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

7cb0ea333092: in few doctests, only check that GIF8 appears in a generated gif file
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 9287a87 to 7cb0ea3

seblabbe commented 2 years ago
comment:77

Replying to @orlitzky:

I still have the failures in comment:33 with my "normal" imagemagick. I would try b"GIF8" in f.read() rather than looking for a specific binary sequence.

Thanks for suggesting an alternative. I did just that in a commit. I hope I fixed the good lines.

orlitzky commented 2 years ago
comment:78

All passing now, thank you!

I have one last nit: I think class convert(Executable) should be capitalized for PEP8. And this new code is commented-out, but I don't mind if you want to keep it:

+        # Alternate way of raising the error (less verbose)
+        #result.check_returncode()
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 7cb0ea3 to 1678c7f

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

e15197f33092: capitalize class name to respect PEP8
1678c7f33092: removed unnecessary comment
seblabbe commented 2 years ago
comment:80

Thanks for catching these. I did 2 commits.

orlitzky commented 2 years ago
comment:81

Thanks again.

orlitzky commented 2 years ago

Changed reviewer from Julian Rüth to Julian Rüth, Michael Orlitzky

seblabbe commented 2 years ago
comment:82

I think this ticket should go to 9.5, but it seems for the 9.5 cycle, there was no period within the early rc candidates which was devoted to merging a bunch of tickets fixing just "defects". I think the 9.5 version would be better if more tickets of type "defect" with positive review were merged.

orlitzky commented 2 years ago
comment:83

Yes, otherwise the 9.5 test suite is going to fail all over the place. Same for the lrslib ticket.

orlitzky commented 2 years ago
comment:84

(and it's a regression, since ffmpeg tests weren't enabled in 9.4 when ffmpeg was disabled)

vbraun commented 2 years ago

Changed branch from u/slabbe/33092 to 1678c7f

vbraun commented 2 years ago
comment:86

Probably an improvement but still broken on the buildbot: followup at #33219