get session id within a recipe


How do I retrieve the current session id (as in the URL) within a recipe to then use it in said recipe?


I'm traying to access the session_id via the controller but the import from your docs doesn't work

from prodigy.controller import Controller

I'm using 1.8.5



Hi! The session ID is only assigned when a user opens the app and makes a request to the server requesting a new batch of questions. There's not currently an in-recipe way to access it, because it's only available once the stream is already executing. So if you want fine-grained control like this within the recipe script, you'd currently have to use separate instances of Prodigy with different datasets, or the same dataset and sessions / annotator names / etc. set via the command line. This thread shows a flexible solution for this:

(I've been thinking about ways to make session-aware streams work without breaking backwards compatibility. Maybe we could introduce another callback that's executed when a session ID is assigned.)

Ah, this should be from prodigy.core import Controller. Will fix that. However, using it like this wouldn't work for your use case, since the Controller is the base class, and what you're looking for is the instance of the controller used for your current Prodigy session.

1 Like

Do I need separate ports opened for it?

Yes, running different instances of different ports is the easiest way. (In theory, you could also use different hosts / different subdomains routed via a reverse proxy, but that's more work if you haven't set that up yet.)

1 Like

Thank you

1 Like