Custom REST API endpoints in recipe

Hi there, I would like to be able to change the current dataset and label via a dropdown in the sidebar. Getting the dropdown in the sidebar should be easy via the JavaScript config setting. But how can I listen to the dropdown changes on the Python side, i.e. in my recipe? Is there a way to add custom REST API endpoints?

The code for the REST server is actually provided in Prodigy, so you can edit it directly in your installation if you want: see the prodigy/_api folder. By default we use Hug, as we still support Python 3.5 in Prodigy v1.8. We're transitioning to FastAPI though, and there's also an experimental FastAPI implementation distributed with Prodigy, which you can enable by setting the PRODIGY_FASTAPI=1 environment variable.

I haven't tested this, but I expect you could also just define additional REST endpoints in your recipe. If you're using FastAPI, you would do from prodigy._api.fastapi_app import routes, and then you can use the @routes.get, routes.post etc decorators to add your endpoints.

You might need to do some unexpected hacking on the Controller object to support the feature you want, and make it work how you like. It's "unsupported", and your changes might break in future. I'm not saying you shouldn't do it; just, obviously, use at your own risk etc :slightly_smiling_face: