I am building an operations workflow orchestration tool using the Temporal platform and Python SDK. For this I need to translate a workflow built on the front end application (using React Flow) into a Temporal workflow definition. I have been trying to do this by converting the front end workflow into a JSON in the serverlessworkflow specification and converting the JSON to a Temporal workflow definition.
I haven’t been able to build or find a robust solution that can translate serverless workflow definitions into a Temporal workflow definition. Any suggestions on approach or references to libraries would be super helpful.
While I do not have anything specific to serverless, it is quite normal for people to pass in the entire DSL structure as a workflow parameter and evaluate it in the workflow. Most people represent this as a typed dataclass structure, but it could be JSON/YAML, etc. Then in the workflow if you need to loop and call activities or children or timers or add signal handlers or whatever, you can. The things you call from a workflow do not have to be predefined (e.g. calling an activity by its string name is very normal in these cases).
Just to add, you can use the serverless workflow sdk-python to parse the workflow definition json/yaml into an object model and then follow the workflow states to build out your activity calls etc.
There is a sample for Java SDK using that DSL here if it can help for references.
Adding on to this. @tihomir I want to persist multiple serverless workflow definitions as json in a central context (using PostgreSQL probably), and then retrieve the required DSL workflow definition according to some key and convert it into a Workflow to run it.
However, while doing so, I am getting an error that the string is not able to parse as Workflow
This is the error:
Caused by: io.temporal.common.converter.DataConverterException: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of io.serverlessworkflow.api.interfaces.State (no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information