labthings / labthings/labthings-fastapi

An action with `NDArray` return type doesn't work over HTTP

Open
#231 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
9
Forks
4
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
An action with NDArray return type doesn't work over HTTP. It throws a the following error

pydantic_core._pydantic_core.PydanticSerializationError: Unable to serialize unknown type: <class 'numpy.ndarray'>

ArrayModel can be used, but then it is typehinted incorrectly when called on the server

To Reproduce
See unit test added in #230

Expected behaviour
It serialises just as ArrayModel would.

System:

  • OS: Kubuntu 24.04
  • Python version. 3.11
  • Version. 0.0.13

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the unit test added in #230 and trace the HTTP response serialization path for an action returning NDArray. The work is done when the test passes and NDArray responses serialize over HTTP in the same way as ArrayModel responses.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, numpy, python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.