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.21k stars 247 forks source link

[Bug]: AutoPipes.pipeline('sentence_embedding', config=config) failed at pydantic 2.5.x #2676

Closed dove-young closed 8 months ago

dove-young commented 11 months ago

Is there an existing issue for this?

Current Behavior

application crash at AutoPipes.pipeline('sentence_embedding', config=config)

python towhee-test.py
/root/jupyter/pydantic/pydantic/_internal/_fields.py:149: UserWarning: Field "model_name" has conflict with protected namespace "model_".

You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.
  warnings.warn(
Traceback (most recent call last):
  File "/root/jupyter/instana-slack-app-dev/towhee-test.py", line 23, in <module>
    sentence_embedding = AutoPipes.pipeline('sentence_embedding', config=config)
  File "/root/jupyter/towhee-io/towhee/towhee/runtime/auto_pipes.py", line 83, in pipeline
    return AutoPipes._PIPES_DEF[name](*args, **kwargs)
  File "/root/jupyter/towhee-io/towhee/towhee/runtime/auto_pipes.py", line 68, in wrapper
    return pipe_def(*args, **kwargs)
  File "/root/jupyter/towhee-io/towhee/towhee/pipelines/sentence_embedding.py", line 77, in sentence_embedding
    pipe.input('text')
  File "/root/jupyter/towhee-io/towhee/towhee/runtime/pipeline.py", line 70, in input
    output_schema = cls._check_schema(schema)
  File "/root/jupyter/towhee-io/towhee/towhee/runtime/pipeline.py", line 517, in _check_schema
    return TupleForm(schema_data=schema).schema_data
  File "/root/jupyter/pydantic/pydantic/main.py", line 166, in __init__
    __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 1 validation error for TupleForm
data
  Field required [type=missing, input_value={'schema_data': ('text',)}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing

Expected Behavior

No response

Steps To Reproduce

1. run a scripit like this

from towhee import AutoPipes, AutoConfig
# get the built-in sentence_similarity pipeline
config = AutoConfig.load_config('sentence_embedding')
config.model = 'paraphrase-albert-small-v2'
config.device = 0
sentence_embedding = AutoPipes.pipeline('sentence_embedding', config=config)

# generate embedding for one sentence
embedding = sentence_embedding('how are you?').get()
# batch generate embeddings for multi-sentences
embeddings = sentence_embedding.batch(['how are you?', 'how old are you?'])
embeddings = [e.get() for e in embeddings]

print(embeddings)

### Environment

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

Anything else?

Pydantic 2.5.1

jaelgu commented 11 months ago

In the towhee requirements.txt: pydantic<2

dove-young commented 11 months ago

It's not a good idea since many other packages works with generative ai and vector dbs work with pydantic 2.x. You may not want those packages cannot work with towhee.

jaelgu commented 11 months ago

It's not a good idea since many other packages works with generative ai and vector dbs work with pydantic 2.x. You may not want those packages cannot work with towhee.

Then we should support both pydantic 1.x & 2.x 🤔

junjiejiangjjj commented 11 months ago

2677

stale[bot] commented 10 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.

Suhaib441 commented 10 months ago

Hello I have the same problem "ImportError: cannot import name 'AutoPipes' from 'towhee". python==3.7 towhee==1.1.3 pydantic==2.5.3

Any help please ?

Thank you

junjiejiangjjj commented 10 months ago

Hello I have the same problem "ImportError: cannot import name 'AutoPipes' from 'towhee". python==3.7 towhee==1.1.3 pydantic==2.5.3

Any help please ?

Thank you

Any other logs?

Suhaib441 commented 9 months ago

that's the only error i have got, i uninstalled towhee and install it again but still have the same error

junjiejiangjjj commented 9 months ago

You can find the towhee directory using this code, and check if it is normal.


>>> import towhee
>>> print(towhee.__file__)
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.