hatchet-dev/hatchet-python

Make the workflow and step decorators not depend on the creation of a Hatchet instance

Closed this issue · 0 comments

As it stands, the workflow and step decorators have to be defined using a Hatchet App instance:

workflow

step

As far as I can tell, the only place where the client attribute that is set on the workflow meta is actually used is here where it is actually just used to access the configuration namespace.

namespace = attrs["client"].config.namespace

Since workflows have to be registered with the worker ANYWAY, I don't see why all the things that might need the client or additional configuration can't be handled at that point:

def register_workflow(self, workflow: WorkflowMeta):

It seems to me that it would be much cleaner if Workflows could be defined declarative apart from any dynamic configuration that is needed to actually talk to a particular hatchet instance.

one idea for how to pull this off is to make everything that is calculated eagerly in the new of workflow meta, instead be calculated dynamically/lazily as part of the call to get_actions, here:

for action_name, action_func in workflow.get_actions():