See workflow as a DAG

I check the UI exposed by the temporal but i am not able to see if temporal surface the workflow as DAG or am i missing something?

1 Like

The short answer is no, but the long answer is that workflows in temporal are more like plain old code and don’t need to be limited to DAGs - you can absolutely have cycles!

Temporal workflows are really just code.

Interestingly, this means it’s possible to generate a call graph of workflow code to visualize things.

We do provide a stack trace view for running workflows. Digging into temporal workflows is much more like attaching a debugger to running code than DAG based workflow solutions.

We’re definitely open to ideas about how to make it easier to understand what’s happening in workflows though! Please feel free to share your thoughts!

1 Like

You have few options.

First, write your pipeline using a DAG library, or a general state machine library, which will then allow you to statically analyze the workflow and visualize it, without executing. This is nicely demonstrated in blog How to visualize Temporal.io workflows | by Konstantin Ignatyev | Medium. They are using GitHub - nsk90/kstatemachine: KStateMachine is a Kotlin DSL library for creating state machines and statecharts., which has an ability to export the state machine definition to UML.

Second, you can visualize the execution after it happened, like @derek mentioned. The only challenging part I can think of right now would be to detect and handle visualization of cycles. Otherwise it should be straightforward. This is how scripted pipeline visualization in Jenkins works. The server observes previous executions and learns what steps are contained in the pipeline. You’d probably have to implement an ability to merge multiple previous traces together into a single visualization, because unlike a typical Jenkins pipeline, your workflow might not execute all its relevant paths in a single execution.

Third, you can try to statically analyze the workflow code. This should be doable in most languages, but it is not something I’d want to be doing. Go should be probably the easiest, and Python the hardest.

NB. also see this recent blog https:// temporal io/blog/lets-visualize-a-workflow

1 Like

This post can be useful: Workflow definitions visuliazations - #7 by Oleg_Shilo