Closed iBuitron closed 6 months ago
Oops. I most probably should. What does it take to do so?
i'm trying to test my app but get an error
a simple api with FastAPI
router = APIRouter(
prefix="/data-store",
tags=["store"],
responses={404: {"description": "Not found"}},
)
class Test(Model):
_primary_key_field = "data"
data: str
@router.post("/post")
async def abundance_histogram(
data: Test,
):
store = Store(
name="some_name",
redis_config=RedisConfig(db=5, host="localhost", port=6379),
life_span_in_seconds=3600,
)
print(store)
# store.register_model(Test)
return {"ok"}
raise PydanticUserError(self._error_message, code=self._code)
pydantic.errors.PydanticUserError: `Store` is not fully defined; you should define `Model`, then call `Store.model_rebuild()`.
For further information visit https://errors.pydantic.dev/2.4/u/class-not-fully-defined
Full log:
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/home/reveur/python/environmental/quickBio/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/reveur/python/environmental/quickBio/.venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/reveur/python/environmental/quickBio/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 1106, in __call__
await super().__call__(scope, receive, send)
File "/home/reveur/python/environmental/quickBio/.venv/lib/python3.11/site-packages/starlette/applications.py", line 122, in __call__
await self.middleware_stack(scope, receive, send)
File "/home/reveur/python/environmental/quickBio/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in __call__
raise exc
File "/home/reveur/python/environmental/quickBio/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in __call__
await self.app(scope, receive, _send)
File "/home/reveur/python/environmental/quickBio/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
raise exc
File "/home/reveur/python/environmental/quickBio/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "/home/reveur/python/environmental/quickBio/.venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
raise e
File "/home/reveur/python/environmental/quickBio/.venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
await self.app(scope, receive, send)
File "/home/reveur/python/environmental/quickBio/.venv/lib/python3.11/site-packages/starlette/routing.py", line 718, in __call__
await route.handle(scope, receive, send)
File "/home/reveur/python/environmental/quickBio/.venv/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/home/reveur/python/environmental/quickBio/.venv/lib/python3.11/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
^^^^^^^^^^^^^^^^^^^
File "/home/reveur/python/environmental/quickBio/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 274, in app
raw_response = await run_endpoint_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/reveur/python/environmental/quickBio/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
return await dependant.call(**values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/reveur/python/environmental/quickBio/quickbio/core/validations/_errors.py", line 14, in wrapper
return await func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/reveur/python/environmental/quickBio/quickbio/api/endpoints/data_store.py", line 24, in abundance_histogram
store = Store(
^^^^^^
File "/home/reveur/python/environmental/quickBio/.venv/lib/python3.11/site-packages/pydantic_redis/_shared/store.py", line 59, in __init__
super().__init__(
File "/home/reveur/python/environmental/quickBio/.venv/lib/python3.11/site-packages/pydantic/main.py", line 164, in __init__
__pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/reveur/python/environmental/quickBio/.venv/lib/python3.11/site-packages/pydantic/_internal/_mock_val_ser.py", line 47, in __getattr__
raise PydanticUserError(self._error_message, code=self._code)
pydantic.errors.PydanticUserError: `Store` is not fully defined; you should define `Model`, then call `Store.model_rebuild()`.
For further information visit https://errors.pydantic.dev/2.4/u/class-not-fully-defined
Gonna update to Pydantic V2?