NdArray['x'] is not compatible with fastAPI schema.
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/home/sami/.cache/pypoetry/virtualenvs/docarray-OI1ry5x2-py3.8/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/home/sami/.cache/pypoetry/virtualenvs/docarray-OI1ry5x2-py3.8/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
return await self.app(scope, receive, send)
File "/home/sami/.cache/pypoetry/virtualenvs/docarray-OI1ry5x2-py3.8/lib/python3.8/site-packages/fastapi/applications.py", line 289, in __call__
await super().__call__(scope, receive, send)
File "/home/sami/.cache/pypoetry/virtualenvs/docarray-OI1ry5x2-py3.8/lib/python3.8/site-packages/starlette/applications.py", line 122, in __call__
await self.middleware_stack(scope, receive, send)
File "/home/sami/.cache/pypoetry/virtualenvs/docarray-OI1ry5x2-py3.8/lib/python3.8/site-packages/starlette/middleware/errors.py", line 184, in __call__
raise exc
File "/home/sami/.cache/pypoetry/virtualenvs/docarray-OI1ry5x2-py3.8/lib/python3.8/site-packages/starlette/middleware/errors.py", line 162, in __call__
await self.app(scope, receive, _send)
File "/home/sami/.cache/pypoetry/virtualenvs/docarray-OI1ry5x2-py3.8/lib/python3.8/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
raise exc
File "/home/sami/.cache/pypoetry/virtualenvs/docarray-OI1ry5x2-py3.8/lib/python3.8/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "/home/sami/.cache/pypoetry/virtualenvs/docarray-OI1ry5x2-py3.8/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
raise e
File "/home/sami/.cache/pypoetry/virtualenvs/docarray-OI1ry5x2-py3.8/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
await self.app(scope, receive, send)
File "/home/sami/.cache/pypoetry/virtualenvs/docarray-OI1ry5x2-py3.8/lib/python3.8/site-packages/starlette/routing.py", line 718, in __call__
await route.handle(scope, receive, send)
File "/home/sami/.cache/pypoetry/virtualenvs/docarray-OI1ry5x2-py3.8/lib/python3.8/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/home/sami/.cache/pypoetry/virtualenvs/docarray-OI1ry5x2-py3.8/lib/python3.8/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
File "/home/sami/.cache/pypoetry/virtualenvs/docarray-OI1ry5x2-py3.8/lib/python3.8/site-packages/fastapi/applications.py", line 244, in openapi
return JSONResponse(self.openapi())
File "/home/sami/.cache/pypoetry/virtualenvs/docarray-OI1ry5x2-py3.8/lib/python3.8/site-packages/fastapi/applications.py", line 217, in openapi
self.openapi_schema = get_openapi(
File "/home/sami/.cache/pypoetry/virtualenvs/docarray-OI1ry5x2-py3.8/lib/python3.8/site-packages/fastapi/openapi/utils.py", line 458, in get_openapi
field_mapping, definitions = get_definitions(
File "/home/sami/.cache/pypoetry/virtualenvs/docarray-OI1ry5x2-py3.8/lib/python3.8/site-packages/fastapi/_compat.py", line 458, in get_definitions
return {}, get_model_definitions(
File "/home/sami/.cache/pypoetry/virtualenvs/docarray-OI1ry5x2-py3.8/lib/python3.8/site-packages/fastapi/_compat.py", line 359, in get_model_definitions
m_schema, m_definitions, m_nested_models = model_process_schema(
File "pydantic/schema.py", line 582, in pydantic.schema.model_process_schema
File "pydantic/schema.py", line 623, in pydantic.schema.model_type_schema
File "pydantic/schema.py", line 251, in pydantic.schema.field_schema
File "pydantic/schema.py", line 319, in pydantic.schema.get_field_schema_validations
File "pydantic/schema.py", line 106, in pydantic.schema._apply_modify_schema
File "./docarray/typing/tensor/abstract_tensor.py", line 282, in __modify_schema__
reduce(mul, cls.__docarray_target_shape__, 1)
TypeError: '<=' not supported between instances of 'str' and 'int'
Initial Checks
Description
NdArray['x'] is not compatible with fastAPI schema.
in a main.py file do:
then do
uvicorn main:appand from your browser try to access
localhost:8000/docsif I used
NdArrayinstead ofNdArray['x']it is working tho.Example Code
belowPython, DocArray & OS Version
Affected Components