redis / redis-om-python

Object mapping, and more, for Redis and Python
MIT License
1.11k stars 111 forks source link

Pydantic 2.1.1 #546

Closed anton-petrov closed 5 months ago

anton-petrov commented 1 year ago

Need support for newest pydantic 2.1.1, just released 2023-07-25

redis-om (0.2.1) depends on pydantic (>=1.10.2,<2.1.0)

hudrazine commented 1 year ago

+1 Likewise, support for pydantic 2.1.x or higher is required but is blocked by redis-om (0.2.1).

anton-petrov commented 1 year ago

Everyone who doesn't want to wait can use my repository https://github.com/anton-petrov/redis-om-python and install package directly from github. I have already tested redis-om with pydantic 2.1.1 on a production project.

For example, for poetry project, add this line to pyproject.toml:

redis-om = {git = "https://github.com/anton-petrov/redis-om-python.git"}
PARKER-X commented 1 year ago

Hii Guys can u help me My code https://github.com/PARKER-X/Microservices-Fastapi @app.get('/products') def all(): return Product.all_pks() my code is not working give fastapi response model error!

PARKER-X commented 1 year ago

Error:===

raise fastapi.exceptions.FastAPIError(

fastapi.exceptions.FastAPIError: Invalid args for response field! Hint: check that <class 'inventory.schema.Product'> is a valid Pydantic field type. If you are using a return type annotation that is not a valid Pydantic field (e.g. Union[Response, dict, None]) you can disable generating the response model from the type annotation with the path operation decorator parameter response_model=None. Read more: https://fastapi.tiangolo.com/tutorial/response-model/

loureirorg commented 9 months ago

Overriding the dependency check worked for me:

pip install pydantic==2.5 --force-reinstall

The command triggered a dependency error, yet it successfully installed pydantic 2.5 alongside redis-om 0.2.1.

I use Conda/Mamba as my virtual environment manager. I believe it's worth trying this approach even if you don't use Conda/Mamba.

Note that it's not possible to force a version via Conda's environment.yml. However, if you're using Docker (e.g., in devcontainers), you can include the pip install ... command in the Dockerfile file after creating the Conda environment. That will install the latest versions of pydantic and redis-om.