Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jmank88
Copy link
Collaborator

@jmank88 jmank88 commented Sep 21, 2024

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff was comparing each as one single enormous line, so just pretty-printing for readability.

{{ else -}}
{{ range $out := .Inputs.Outputs -}}
{{ if $out.Name -}}
{{ $out.Ref }} -- {{ $out.Name }} --> {{ $ref}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is where we indicate that we're doing outputs.Value, right? If so, can we also represent the fact that we also shaping the incoming inputs?

Eg. for consensus we actually do:
{"observations": []any{"outputs.Value"}}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was worried about including everything, and it's not obvious to me where to draw the line 🤷
We also have other options for presenting the data, like triggering actions on click or tool-tips on hover.
Or something way different, like subgraphs for each step, with multiple internal nodes:

flowchart
	subgraph event-trigger
		trigger-->event-outputs[outputs]
	end
	subgraph compute-a-step[compute a]
		compute-a-inputs[TriggerOutputs] --> compute-a[Execute] --> compute-a-outputs[Value]
	end
	subgraph compute-b-step[compute b]
		compute-b-inputs[TriggerOutputs] --> compute-b[Execute] --> compute-b-outputs[Value]
	end
	subgraph report-step[report]
		report[Build Report]
		report-inputs-compute-a[Value] --> report
		report-inputs-compute-b[Value] --> report
		report --> report-outputs[Report]
	end
	subgraph write-step[write]
		write-inputs[Report] --> write
	end
	event-outputs --> compute-a-inputs
	event-outputs --> compute-b-inputs
	compute-a-outputs --> report-inputs-compute-a
	compute-b-outputs --> report-inputs-compute-b
	report-outputs --> write-inputs
Loading

This level of granularity would allow us to express more visually, and utilize tool tips for more information, since they work on nodes but not edges.

@jmank88 jmank88 force-pushed the workflowchart branch 4 times, most recently from b26ed1a to 7c3e9ff Compare October 7, 2024 23:02
@jmank88 jmank88 changed the title pkg/workflows/sdk: add WorkflowSpec.FormatChart for mermaid flowcharts pkg/workflows/sdk: add DependencyGraph.FormatChart for mermaid flowcharts Oct 7, 2024
@jmank88 jmank88 requested a review from a team as a code owner October 16, 2024 01:00
@jmank88 jmank88 marked this pull request as draft October 16, 2024 02:10
@jmank88
Copy link
Collaborator Author

jmank88 commented Oct 16, 2024

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 jmank88 removed the request for review from a team October 17, 2024 16:11
@shileiwill
Copy link
Collaborator

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

@jmank88
Copy link
Collaborator Author

jmank88 commented Oct 17, 2024

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 😢

@shileiwill
Copy link
Collaborator

shileiwill commented Oct 17, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants