Parisson / TimeSide

scalable audio processing framework and server written in Python
https://timeside.ircam.fr/docs/
GNU Affero General Public License v3.0
369 stars 59 forks source link

[server and core] TypeError on any Encoders with experience `all` #157

Open Tointoin opened 4 years ago

Tointoin commented 4 years ago

While applying the experience all on the selection Tests, empty results for encoders are created with draft status. No other experience are created. Worker's logs give this error:

[2020-03-09 12:52:55,766: ERROR/ForkPoolWorker-9] Task timeside.server.tasks.experience_run[4175ee46-0ea9-43ba-8fbd-513a2e948e25] raised unexpected: TypeError('slice indices must be integers or None or have an __index__ method')
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/celery/app/trace.py", line 385, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/celery/app/trace.py", line 650, in __protected_call__
    return self.run(*args, **kwargs)
  File "/srv/lib/timeside/timeside/server/tasks.py", line 39, in experience_run
    item.run(experience)
  File "/srv/lib/timeside/timeside/server/models.py", line 523, in run
    pipe.run()
  File "/srv/lib/timeside/timeside/core/processor.py", line 554, in run
    frames, eod = item.process(frames, eod)
  File "/srv/lib/timeside/timeside/core/preprocessors.py", line 74, in wrapper
    process_func(analyzer, downmix_frames, eod)
  File "/srv/lib/timeside/timeside/core/preprocessors.py", line 186, in wrapper
    for adapted_frames, adapted_eod in analyzer.frames_buffer.frames(frames, eod):
  File "/srv/lib/timeside/timeside/core/preprocessors.py", line 160, in frames
    self.buffer = stack[nb_frames * self.stepsize:]
TypeError: slice indices must be integers or None or have an __index__ method

It seems to be the case since use of AubioDecoder. This error does not occure while applying all encoders at the same time on Tests selection (or all analyzers on the same selection). This occures only with all experience.

Tointoin commented 4 years ago
diff --git a/timeside/core/preprocessors.py b/timeside/core/preprocessors.py
index d16ceeaa..8a84f3e2 100644
--- a/timeside/core/preprocessors.py
+++ b/timeside/core/preprocessors.py
@@ -151,19 +151,19 @@ def frames_adapter(process_func):
             if eod:
                 # Final zeropadding
                 pad_shape = tuple(
-                    self.blocksize - last_block_size if i == 0 else x
+                    int(self.blocksize - last_block_size) if i == 0 else x
                     for i, x in enumerate(frames.shape))
                 stack = np.concatenate([stack, np.zeros(pad_shape,
                                                         dtype=frames.dtype)])
                 nb_frames += 1

-            self.buffer = stack[nb_frames * self.stepsize:]
+            self.buffer = stack[int(nb_frames * self.stepsize):]

             eod_list = np.repeat(False, nb_frames)
             if eod and len(eod_list):
                 eod_list[-1] = eod

-            for index, eod in zip(range(0, nb_frames * self.stepsize, self.stepsize), eod_list):
+            for index, eod in zip(range(0, int(nb_frames * self.stepsize), int(self.stepsize)), eod_list):
                 yield (stack[index:index + self.blocksize], eod)

     aubio_analyzers = ['aubio_melenergy', 'aubio_mfcc', 'aubio_pitch', 'aubio_specdesc', 'aubio_temporal']

After applying this diff to the concerned preprocessor.py file, the given traceback is:

[2020-03-09 17:04:03,034: ERROR/ForkPoolWorker-4] Task timeside.server.tasks.experience_run[69ee447f-8c77-4e59-8cfa-cc3687a92403] raised unexpected: TypeError("string argument expected, got 'bytes'")
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/celery/app/trace.py", line 385, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/celery/app/trace.py", line 650, in __protected_call__
    return self.run(*args, **kwargs)
  File "/srv/lib/timeside/timeside/server/tasks.py", line 39, in experience_run
    item.run(experience)
  File "/srv/lib/timeside/timeside/server/models.py", line 523, in run
    pipe.run()
  File "/srv/lib/timeside/timeside/core/processor.py", line 562, in run
    item.post_process()
  File "/srv/lib/timeside/timeside/core/grapher.py", line 354, in post_process
    self.image_height), self.dpi)
  File "/srv/lib/timeside/timeside/core/analyzer.py", line 696, in _render_PIL
    canvas.print_png(imgdata, dpi=dpi)
  File "/usr/local/lib/python3.7/dist-packages/matplotlib/backends/backend_agg.py", line 532, in print_png
    self.figure.dpi, metadata=metadata)
TypeError: string argument expected, got 'bytes'

empty results for encoders are created with draft status. No other experience are created.

same result.