temporalio / sdk-python

Temporal Python SDK
MIT License
457 stars 68 forks source link

[Feature Request] Some kind of registry for workflows and activities to get classes/function with their names #659

Open funkindy opened 14 hours ago

funkindy commented 14 hours ago

I'd like to instantiate a worker instance with CLI wrapper. In this scenario i can only provide workflow names and activity names as strings.

It would be nice to have an SDK option to get python objects with this names or even to instantiate Worker with lists of strings directly. Maybe register types somewhere in *.defn.

Whats your opinion?

cretz commented 13 hours ago

We try not to assume global use of workflows/activities in the SDK. Many users create many workflows/activities and only start some of them in some workers and others in other workers (some may even have the same name). I would recommend maintaining a dict of workflows/activities if you need a form of global lookup. This can be done with a custom decorator if needed.

funkindy commented 10 hours ago

I see, thank you. Maybe you have a recipe for production deployment of workers?

We are looking for deploying pods with workers with some text based configuration (e.g. environment variables)

Thank you

cretz commented 7 hours ago

We do not have a specific recipe. You can have a simple Python script that reads environment variables and builds the sets of workflows/activities based on what those values are (e.g. a dict lookup), but most people hardcode the sets of workflows/activities to a task queue because every worker on a task queue needs to have the same set of workflows/activities, so it often doesn't make much sense to have that be configurable at runtime.

(also feel free to join us on the forums or Slack if that's an easier way for you to discuss)