towhee-io / towhee

Towhee is a framework that is dedicated to making neural data processing pipelines simple and fast.
https://towhee.io
Apache License 2.0
3.16k stars 246 forks source link

[Bug]: application cannot start. `from towhee import AutoPipes` crashes #2674

Closed dove-young closed 8 months ago

dove-young commented 9 months ago

Is there an existing issue for this?

Current Behavior

application cannot start. from towhee import AutoPipes crashes

 python towhee-test.py
Traceback (most recent call last):
  File "/root/jupyter/instana-slack-app-dev/towhee-test.py", line 1, in <module>
    from towhee import AutoPipes
  File "/root/jupyter/virtualenv/slack-dev-3.10/lib/python3.10/site-packages/towhee/__init__.py", line 20, in <module>
    from towhee.runtime import register, pipe, ops, accelerate, AutoConfig, AutoPipes
  File "/root/jupyter/virtualenv/slack-dev-3.10/lib/python3.10/site-packages/towhee/runtime/__init__.py", line 17, in <module>
    from .pipeline import Pipeline as pipe
  File "/root/jupyter/virtualenv/slack-dev-3.10/lib/python3.10/site-packages/towhee/runtime/pipeline.py", line 18, in <module>
    from towhee.runtime.check_utils import TupleForm
  File "/root/jupyter/virtualenv/slack-dev-3.10/lib/python3.10/site-packages/towhee/runtime/check_utils.py", line 36, in <module>
    class TupleForm(BaseModel):
  File "/root/jupyter/virtualenv/slack-dev-3.10/lib/python3.10/site-packages/towhee/runtime/check_utils.py", line 38, in TupleForm
    schema_data: Optional[Tuple[constr(regex='^[a-z][a-z0-9_]*$'), ...]]
TypeError: constr() got an unexpected keyword argument 'regex'

Expected Behavior

application runs

Steps To Reproduce

1. in Python 3.10 env
2. `pip install towhee pydantic_core`
3. run a python script with `from towhee import AutoPipes`
4. see error

pip list | grep pydantic
pydantic                 1.10.13
pydantic_core            2.14.4

### Environment

```markdown
- Towhee version(e.g. v0.1.3 or 8b23a93): 1.1.2
- OS(Ubuntu or CentOS): RHEL 8
- CPU/Memory: 8 CPU 32G Memory
- GPU:
- Others: Python 3.10

Anything else?

And actually after install with pip install towhee towhee.models, it does not run.

Traceback (most recent call last):
  File "/root/jupyter/instana-slack-app-dev/towhee-test.py", line 1, in <module>
    from towhee import AutoPipes
  File "/root/jupyter/virtualenv/slack-dev-3.10-bug/lib/python3.10/site-packages/towhee/__init__.py", line 20, in <module>
    from towhee.runtime import register, pipe, ops, accelerate, AutoConfig, AutoPipes
  File "/root/jupyter/virtualenv/slack-dev-3.10-bug/lib/python3.10/site-packages/towhee/runtime/__init__.py", line 17, in <module>
    from .pipeline import Pipeline as pipe
  File "/root/jupyter/virtualenv/slack-dev-3.10-bug/lib/python3.10/site-packages/towhee/runtime/pipeline.py", line 18, in <module>
    from towhee.runtime.check_utils import TupleForm
  File "/root/jupyter/virtualenv/slack-dev-3.10-bug/lib/python3.10/site-packages/towhee/runtime/check_utils.py", line 16, in <module>
    from pydantic import BaseModel, constr, validator
  File "/root/jupyter/pydantic/pydantic/__init__.py", line 370, in __getattr__
    module = import_module(module_name, package=package)
  File "/opt/python-3.10.12/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/root/jupyter/pydantic/pydantic/main.py", line 11, in <module>
    import pydantic_core

after install pydantic_core

pip install pydantic_core
Collecting pydantic_core
  Using cached pydantic_core-2.14.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.5 kB)
Requirement already satisfied: typing-extensions!=4.7.0,>=4.6.0 in ./slack-dev-3.10-bug/lib/python3.10/site-packages (from pydantic_core) (4.8.0)
Using cached pydantic_core-2.14.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB)
Installing collected packages: pydantic_core
Successfully installed pydantic_core-2.14.4

it failed at

Traceback (most recent call last):
  File "/root/jupyter/instana-slack-app-dev/towhee-test.py", line 1, in <module>
    from towhee import AutoPipes
  File "/root/jupyter/virtualenv/slack-dev-3.10-bug/lib/python3.10/site-packages/towhee/__init__.py", line 20, in <module>
    from towhee.runtime import register, pipe, ops, accelerate, AutoConfig, AutoPipes
  File "/root/jupyter/virtualenv/slack-dev-3.10-bug/lib/python3.10/site-packages/towhee/runtime/__init__.py", line 17, in <module>
    from .pipeline import Pipeline as pipe
  File "/root/jupyter/virtualenv/slack-dev-3.10-bug/lib/python3.10/site-packages/towhee/runtime/pipeline.py", line 18, in <module>
    from towhee.runtime.check_utils import TupleForm
  File "/root/jupyter/virtualenv/slack-dev-3.10-bug/lib/python3.10/site-packages/towhee/runtime/check_utils.py", line 16, in <module>
    from pydantic import BaseModel, constr, validator
  File "/root/jupyter/pydantic/pydantic/__init__.py", line 370, in __getattr__
    module = import_module(module_name, package=package)
  File "/opt/python-3.10.12/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/root/jupyter/pydantic/pydantic/types.py", line 28, in <module>
    import annotated_types
ModuleNotFoundError: No module named 'annotated_types'

after installed 'annotated_types', it failed at the TypeError: constr() got an unexpected keyword argument 'regex' error.

dove-young commented 9 months ago

In latest version of pydantic, the param regex is removed.

grep -A 10 'def constr' /root/jupyter/virtualenv/slack-dev-3.10/lib/python3.10/site-packages/pydantic/types.py
def constr(
    *,
    strip_whitespace: bool | None = None,
    to_upper: bool | None = None,
    to_lower: bool | None = None,
    strict: bool | None = None,
    min_length: int | None = None,
    max_length: int | None = None,
    pattern: str | None = None,
) -> type[str]:
    """
pydantic                 2.5.1
pydantic_core            2.14.3
dove-young commented 9 months ago

Here is a PR for this issue https://github.com/towhee-io/towhee/pull/2675

junjiejiangjjj commented 9 months ago

2678

stale[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Rotten issues close after 30d of inactivity. Close the stale issues and pull requests after 7 days of inactivity. Reopen the issue with /reopen.