Repository: towhee-io/towhee

Issue #431: [Bug]: If dependency installation was interrupted, the dependencies won't be installed in the next run.
Created: 2022-01-07T08:35:31Z
Is there an existing issue for this?

 I have searched the existing issues

Current Behavior
There are serval similar issues, If op dependency installation was interrupted by internet connection, ctrl + c or something else, the dependencies are not installed properly. But the pip install -r requirements.txt command won't be triggered again in the next run unless there are updates on the repos' main branch. Therefore causing ModuleNotFound error.
Expected Behavior
If the dependency installation was interrupted, execute again in the next run.
Steps To Reproduce
from towhee import pipeline

p = pipeline('image-embedding')
img = 'path/to/image.jpg'
p(img)

When installing dependencies, press `ctrl + c`
Environment
- Towhee version(e.g. v0.1.3 or 8b23a93):
- OS(Ubuntu or CentOS):
- CPU/Memory:
- GPU:
- Others:
Anything else?
No response

Duplicate issue #402: [Bug]: Failed to run pieline after the first interruption
Created: 2022-01-05T07:02:55Z
Is there an existing issue for this?

 I have searched the existing issues

Current Behavior
According to the page: https://docs.towhee.io/tutorials/reverse-image-search

pip3 install towhee


 pip3 install gdown
 gdown "https://drive.google.com/uc?id=1bg1RtUjeZlOfV2BiA2nf7sn5Jec9b-9I"
 unzip -q image_dataset.zip


start a milvus server
pip3 install pymilvus==2.0.0rc9
run this script:

from towhee import pipeline
import numpy as np
import os
from pathlib import Path

embedding_pipeline = pipeline('towhee/image-embedding-resnet50')

dataset_path = './image_dataset/dataset/'
images = []
vectors = []

for img_path in Path(dataset_path).glob('*'):
    vec = embedding_pipeline(str(img_path))
    norm_vec = vec / np.linalg.norm(vec)
    vectors.append(norm_vec.tolist())
    images.append(str(img_path.resolve()))

I got the following errors, and the script hangs:
(venv) ➜  towhee_test python3 ./test.py  
2022-01-05 14:57:32,183 - 140555422004992 - thread_pool_task_executor.py-thread_pool_task_executor:77 - ERROR: Traceback (most recent call last):
  File "/home/yhmo/git-go/towhee_test/venv/lib/python3.6/site-packages/towhee/engine/thread_pool_task_executor.py", line 70, in execute
    runner.op_args)
  File "/home/yhmo/git-go/towhee_test/venv/lib/python3.6/site-packages/towhee/engine/operator_pool.py", line 105, in acquire_op
    op = self._op_loader.load_operator(hub_op_id, op_args)
  File "/home/yhmo/git-go/towhee_test/venv/lib/python3.6/site-packages/towhee/engine/operator_loader.py", line 82, in load_operator
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/yhmo/.towhee/operators/image_decoder&towhee$main/image_decoder.py", line 5, in <module>
    import cv2
ModuleNotFoundError: No module named 'cv2'

2022-01-05 14:57:32,184 - 140555405219584 - thread_pool_task_executor.py-thread_pool_task_executor:77 - ERROR: Traceback (most recent call last):
  File "/home/yhmo/git-go/towhee_test/venv/lib/python3.6/site-packages/towhee/engine/thread_pool_task_executor.py", line 70, in execute
    runner.op_args)
  File "/home/yhmo/git-go/towhee_test/venv/lib/python3.6/site-packages/towhee/engine/operator_pool.py", line 105, in acquire_op
    op = self._op_loader.load_operator(hub_op_id, op_args)
  File "/home/yhmo/git-go/towhee_test/venv/lib/python3.6/site-packages/towhee/engine/operator_loader.py", line 82, in load_operator
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/yhmo/.towhee/operators/resnet_image_embedding&towhee$main/resnet_image_embedding.py", line 16, in <module>
    import torch
ModuleNotFoundError: No module named 'torch'

2022-01-05 14:57:32,184 - 140555422004992 - thread_pool_task_executor.py-thread_pool_task_executor:78 - ERROR: No module named 'cv2'
2022-01-05 14:57:32,184 - 140555405219584 - thread_pool_task_executor.py-thread_pool_task_executor:78 - ERROR: No module named 'torch'
Traceback (most recent call last):
  File "./test.py", line 14, in <module>
    vec = embedding_pipeline(str(img_path))
  File "/home/yhmo/git-go/towhee_test/venv/lib/python3.6/site-packages/towhee/__init__.py", line 71, in __call__
    out_df = self._pipeline(in_df)
  File "/home/yhmo/git-go/towhee_test/venv/lib/python3.6/site-packages/towhee/engine/pipeline.py", line 97, in __call__
    graph_ctx.join()
  File "/home/yhmo/git-go/towhee_test/venv/lib/python3.6/site-packages/towhee/engine/graph_context.py", line 95, in join
    op.join()
  File "/home/yhmo/git-go/towhee_test/venv/lib/python3.6/site-packages/towhee/engine/operator_context.py", line 144, in join
    runner.join()
  File "/home/yhmo/git-go/towhee_test/venv/lib/python3.6/site-packages/towhee/engine/operator_runner/runner_base.py", line 196, in join
    self._end_event.wait()
  File "/usr/lib/python3.6/threading.py", line 551, in wait
    signaled = self._cond.wait(timeout)
  File "/usr/lib/python3.6/threading.py", line 295, in wait
    waiter.acquire()
KeyboardInterrupt


Expected Behavior
No response
Steps To Reproduce
No response
Environment
- Towhee version(e.g. v0.1.3 or 8b23a93):
- OS(Ubuntu or CentOS):
- CPU/Memory:
- GPU:
- Others:
Anything else?
No response

Closing comment (2022-01-21T02:27:45Z): Same as #431