Skip to content

Error querying worker task via REST API #369

Closed

Description

@callumforrester

When querying /worker/task via the API, the server returns 500 internal server error.

This is because the currently active task object holds a cached copy of the dynamically generated pydantic model of the plan's parameters. See blueapi.worker.task.Task. Pickling does not work on dynamically generated classes by default.

There are a couple of options for solving:

  1. Make the dynamically generated classes pickable. It seems to do so we need to define a __reduce__ dunder for them: https://docs.python.org/3/library/pickle.html#object.__reduce__
  2. Cache the dynamically generated class somewhere else

I'm in favour of 2 since Task was only ever supposed to be a data class

Activity

  1. added
    bug
    c: rest api
    on Feb 7, 2024
  2. callumforrester commented on Feb 7, 2024

    @callumforrester
    ContributorAuthor

    This also happens if trying to run more than one plan, as the previous task is pickled as part of the information displayed to the user, making the bug more severe

  3. callumforrester commented on Feb 7, 2024

    @callumforrester
    ContributorAuthor

    I suggest for now we stop caching, since that's a simple change and the overhead of generating the parameters twice is tiny: #370

  4. added a commit that references this issue on Feb 7, 2024
    598d789
  5. added a commit that references this issue on May 7, 2024
    9e214d6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugc: rest api

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions