chainlink-common icon indicating copy to clipboard operation
chainlink-common copied to clipboard

pkg/workflows/sdk: add DependencyGraph.FormatChart for mermaid flowcharts

Open jmank88 opened this issue 1 year ago • 1 comments

This PR adds DependencyGraph.FormatChart for visualizing workflows as mermaid flowcharts.

jmank88 avatar Sep 21 '24 16:09 jmank88

I split out the builder changes to #821, so this PR is now just flowcharts for the existing types.

jmank88 avatar Oct 01 '24 22:10 jmank88

I swapped over to using the DependencyGraph.Graph, but it appears to be incomplete so I need to figure out how to augment it with the trigger dependencies. Back to draft for now.

jmank88 avatar Oct 16 '24 02:10 jmank88

Hey @jmank88 , I am trying to figure out how we provide the visual to users via CLI. From the dev platform CLI perspective,

  • We get the paths of local files from users and get the wasm binary and config as byte[]
  • We can get an instance of WorkflowSpec via GetWorkflowSpec
  • We can call something like GetChart() to get the visual? Is the visual a SVG or image to the local?

Want to hear your thoughts on the flow, and how to integrate. Thanks! This comment is a copy-pasta from link

shileiwill avatar Oct 17 '24 16:10 shileiwill

Hey @jmank88 , I am trying to figure out how we provide the visual to users via CLI. From the dev platform CLI perspective,

  • We get the paths of local files from users and get the wasm binary and config as byte[]
  • We can get an instance of WorkflowSpec via GetWorkflowSpec
  • We can call something like GetChart() to get the visual? Is the visual a SVG or image to the local?

Want to hear your thoughts on the flow, and how to integrate. Thanks! This comment is a copy-pasta from link

I refactored the method to be on DependencyGraph instead, but yes you can just call FormatChart(). However, it returns text to be interpreted by Mermaid for visualization, so we'd have to call in to that library for rendering to SVG or anything else. Edit: But we might not be pursuing this direction any longer :cry:

jmank88 avatar Oct 17 '24 17:10 jmank88

Returning text and we (client) render with Mermaid sounds great to me. This is gonna be a very useful feature from Dev Platform side.

But we might not be pursuing this direction any longer

May I know the new direction?

shileiwill avatar Oct 17 '24 21:10 shileiwill