Repository: towhee-io/towhee

Issue #347: [Enhancement]: Should be more elegant to handle exceptions
Created: 2021-12-25T08:07:57Z
Is there an existing issue for this?

 I have searched the existing issues

What would you like to be added?
This is not user friendly.
Downloading: "https://download.pytorch.org/models/resnet50-0676ba61.pth" to /Users/ryjiang/.cache/torch/hub/checkpoints/resnet50-0676ba61.pth
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 97.8M/97.8M [00:05<00:00, 18.1MB/s]
Traceback (most recent call last):
  File "index.py", line 9, in <module>
    output = embedding_pipeline('towhee_logo.png')
  File "/usr/local/lib/python3.7/site-packages/towhee/__init__.py", line 73, in __call__
    out_df = self._pipeline(in_df)
  File "/usr/local/lib/python3.7/site-packages/towhee/engine/pipeline.py", line 91, in __call__
    return graph_ctx.result()
  File "/usr/local/lib/python3.7/site-packages/towhee/engine/graph_context.py", line 75, in result
    raise RuntimeError(op.err_msg)
RuntimeError: preprocessing:0 runs failed, error msg: [Errno 2] No such file or directory: 'towhee_logo.png'


Why is this needed?

Prevents program from crashing if an error occurs
Better error message could save a lot of time for developers to debug

Anything else?
No response

Duplicate issue #360: [Bug]: Audio pipeline "towhee/audio-embedding-vggish" reporting not proper error when embedding with not existed file
Created: 2021-12-28T02:28:14Z
Is there an existing issue for this?

 I have searched the existing issues

Current Behavior
When embedding within audio pipeline "towhee/audio-embedding-vggish", it reports:
>>> embedding = embedding_pipeline("/Users/binbin/Towhee_projects/example_audio/queen_love_of_my_life.wav")
2021-12-28 10:23:12,160 - 140242476586752 - runner_base.py-runner_base:128 - ERROR: embedding_model:0 runs failed, error msg: Error opening '/Users/binbin/Towhee_projects/example_audio/queen_love_of_my_life.wav': System error., Traceback (most recent call last):
  File "/home/zong/binbin/towhee-test-env/lib/python3.9/site-packages/towhee/engine/operator_runner/runner_base.py", line 154, in _call_op
    outputs = self._op(**inputs)
  File "/home/zong/.towhee/operators/tf_vggish_audioset&towhee$main/tf_vggish_audioset.py", line 43, in __call__
    wav_data, sr = sf.read(filepath, dtype='int16')
  File "/home/zong/binbin/towhee-test-env/lib/python3.9/site-packages/soundfile.py", line 256, in read
    with SoundFile(file, 'r', samplerate, channels,
  File "/home/zong/binbin/towhee-test-env/lib/python3.9/site-packages/soundfile.py", line 629, in __init__
    self._file = self._open(file, mode_int, closefd)
  File "/home/zong/binbin/towhee-test-env/lib/python3.9/site-packages/soundfile.py", line 1183, in _open
    _error_check(_snd.sf_error(file_ptr),
  File "/home/zong/binbin/towhee-test-env/lib/python3.9/site-packages/soundfile.py", line 1357, in _error_check
    raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace'))
RuntimeError: Error opening '/Users/binbin/Towhee_projects/example_audio/queen_love_of_my_life.wav': System error.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/zong/binbin/towhee-test-env/lib/python3.9/site-packages/towhee/__init__.py", line 69, in __call__
    out_df = self._pipeline(in_df)
  File "/home/zong/binbin/towhee-test-env/lib/python3.9/site-packages/towhee/engine/pipeline.py", line 94, in __call__
    return graph_ctx.result()
  File "/home/zong/binbin/towhee-test-env/lib/python3.9/site-packages/towhee/engine/graph_context.py", line 77, in result
    raise OpFailedError(op.err_msg)
towhee.errors.OpFailedError: embedding_model:0 runs failed, error msg: Error opening '/Users/binbin/Towhee_projects/example_audio/queen_love_of_my_life.wav': System error., Traceback (most recent call last):
  File "/home/zong/binbin/towhee-test-env/lib/python3.9/site-packages/towhee/engine/operator_runner/runner_base.py", line 154, in _call_op
    outputs = self._op(**inputs)
  File "/home/zong/.towhee/operators/tf_vggish_audioset&towhee$main/tf_vggish_audioset.py", line 43, in __call__
    wav_data, sr = sf.read(filepath, dtype='int16')
  File "/home/zong/binbin/towhee-test-env/lib/python3.9/site-packages/soundfile.py", line 256, in read
    with SoundFile(file, 'r', samplerate, channels,
  File "/home/zong/binbin/towhee-test-env/lib/python3.9/site-packages/soundfile.py", line 629, in __init__
    self._file = self._open(file, mode_int, closefd)
  File "/home/zong/binbin/towhee-test-env/lib/python3.9/site-packages/soundfile.py", line 1183, in _open
    _error_check(_snd.sf_error(file_ptr),
  File "/home/zong/binbin/towhee-test-env/lib/python3.9/site-packages/soundfile.py", line 1357, in _error_check
    raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace'))
RuntimeError: Error opening '/Users/binbin/Towhee_projects/example_audio/queen_love_of_my_life.wav': System error.

Expected Behavior
Reporting like "file not found"
Steps To Reproduce
1. pip install towhee==0.4.0rc1
2. in python3 terminal:

from towhee import pipeline
embedding_pipeline = pipeline('towhee/audio-embedding-vggish')
embedding = embedding_pipeline("/Users/binbin/Towhee_projects/example_audio/arms_strikes.wav")
Environment
- Towhee version(e.g. v0.1.3 or 8b23a93): 0.4.0rc1
- OS(Ubuntu or CentOS):Ubuntu
- Python: 3.9.7
- CPU/Memory:
- GPU:
- Others:
Anything else?
No response

Closing comment (2021-12-28T08:46:43Z): duplicate #347