Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Upgrade pydantic to 2.x #1428

Merged
merged 4 commits into from
Apr 20, 2024
Merged

Conversation

fangyinc
Copy link
Collaborator

@fangyinc fangyinc commented Apr 18, 2024

Description

Closes #1411

The main upgrades are as follows

  • "pydantic<2,>=1" to "pydantic>=2.6.0"
  • "fastapi==0.98.0" to "fastapi>=0.100.0"
  • "spacy==3.5.3" to "spacy>=3.7"
  • "chromadb==0.4.10" to "chromadb>=0.4.22"

Note:
Please create a new conda environment, and then use the commandpip install -e ".[default]" to reinstall the dependencies.

How Has This Been Tested?

We need comprehensive regression testing!!!

Snapshots:

Include snapshots for easier review.

Checklist:

  • My code follows the style guidelines of this project
  • I have already rebased the commits and make the commit message conform to the project standard.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • Any dependent changes have been merged and published in downstream modules

@github-actions github-actions bot added core Module: core enhancement New feature or request labels Apr 18, 2024
@csunny
Copy link
Collaborator

csunny commented Apr 18, 2024

When i test this feature use MacOS, some error occur

Traceback (most recent call last):
  File "/Users/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/app/dbgpt_server.py", line 242, in <module>
    run_webserver()
  File "/Users/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/app/dbgpt_server.py", line 237, in run_webserver
    param = initialize_app(param)
  File "/Users/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/app/dbgpt_server.py", line 152, in initialize_app
    initialize_components(param, system_app, embedding_model_name, embedding_model_path)
  File "/Users/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/app/component_configs.py", line 45, in initialize_components
    _initialize_embedding_model(
  File "/Users/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/app/initialization/embedding_component.py", line 28, in _initialize_embedding_model
    system_app.register(
  File "/Users/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/component.py", line 191, in register
    instance = component(self, *args, **kwargs)
  File "/Users/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/app/initialization/embedding_component.py", line 72, in __init__
    self._model = self._load_model()
  File "/Users/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/app/initialization/embedding_component.py", line 107, in _load_model
    return loader.load(self._default_model_name, model_params)
  File "/Users/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/model/adapter/embeddings_loader.py", line 57, in load
    return HuggingFaceEmbeddings(**kwargs)
  File "/Users/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/rag/embedding/embeddings.py", line 84, in __init__
    super().__init__(**kwargs)
  File "/Users/magic/miniconda3/envs/dbgpt_env/lib/python3.10/site-packages/pydantic/main.py", line 175, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for HuggingFaceEmbeddings
client
  Field required [type=missing, input_value={'model_name': '/Users/ma...rgs': {'device': 'mps'}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing

The same error about CPU

Traceback (most recent call last):
  File "/home/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/app/dbgpt_server.py", line 242, in <module>
    run_webserver()
  File "/home/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/app/dbgpt_server.py", line 237, in run_webserver
    param = initialize_app(param)
  File "/home/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/app/dbgpt_server.py", line 152, in initialize_app
    initialize_components(param, system_app, embedding_model_name, embedding_model_path)
  File "/home/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/app/component_configs.py", line 45, in initialize_components
    _initialize_embedding_model(
  File "/home/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/app/initialization/embedding_component.py", line 28, in _initialize_embedding_model
    system_app.register(
  File "/home/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/component.py", line 191, in register
    instance = component(self, *args, **kwargs)
  File "/home/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/app/initialization/embedding_component.py", line 72, in __init__
    self._model = self._load_model()
  File "/home/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/app/initialization/embedding_component.py", line 107, in _load_model
    return loader.load(self._default_model_name, model_params)
  File "/home/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/model/adapter/embeddings_loader.py", line 57, in load
    return HuggingFaceEmbeddings(**kwargs)
  File "/home/magic/workspace/github/eosphoros-ai/DB-GPT/dbgpt/rag/embedding/embeddings.py", line 84, in __init__
    super().__init__(**kwargs)
  File "/home/magic/miniconda3/envs/dbgpt_env/lib/python3.10/site-packages/pydantic/main.py", line 175, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for HuggingFaceEmbeddings
client
  Field required [type=missing, input_value={'model_name': '/home/mag...rgs': {'device': 'cpu'}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing

@csunny
Copy link
Collaborator

csunny commented Apr 18, 2024

Also cuda

pydantic_core._pydantic_core.ValidationError: 1 validation error for HuggingFaceEmbeddings
client
  Field required [type=missing, input_value={'model_name': '/home/mag...gs': {'device': 'cuda'}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing

@fangyinc
Copy link
Collaborator Author

@csunny @Aries-ckt fixed.

@fangyinc fangyinc requested a review from csunny April 18, 2024 17:13
@Aries-ckt
Copy link
Collaborator

Test success!
image

Copy link
Collaborator

@Aries-ckt Aries-ckt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+

Copy link
Collaborator

@Aralhi Aralhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+

@Aralhi Aralhi merged commit 57be1ec into eosphoros-ai:main Apr 20, 2024
4 checks passed
Hopshine pushed a commit to Hopshine/DB-GPT that referenced this pull request Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Module: core enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please update pydantic from 1.x to 2.x
4 participants