-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
.Net: Process mermaid flowchart code generation, image generation on flowchart and sample usage. #9705
Open
joslat
wants to merge
10
commits into
microsoft:main
Choose a base branch
from
joslat:joslat-process-framework-markdown-renderer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
.Net: Process mermaid flowchart code generation, image generation on flowchart and sample usage. #9705
joslat
wants to merge
10
commits into
microsoft:main
from
joslat:joslat-process-framework-markdown-renderer
+263
−0
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alliscode
reviewed
Nov 14, 2024
alliscode
reviewed
Nov 14, 2024
dotnet/src/Experimental/Process.Core/ProcessVisualizationExtensions.cs
Outdated
Show resolved
Hide resolved
crickman
added
PR: ready for review
All feedback addressed, ready for reviews
experimental
Associated with an experimental feature
enhancement
processes
labels
Nov 15, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
experimental
Associated with an experimental feature
.NET
Issue or Pull requests regarding .NET code
PR: ready for review
All feedback addressed, ready for reviews
processes
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I propose adding functionality to render workflows/processes as visual diagrams, using Markdown (Mermaid syntax) and generating images. This feature would greatly aid in documenting and communicating process flows within the framework.
Motivation and Context
Why: Improved visualization and understanding of the workflow, reduce cognitive load and also it makes it cooler.
So we can visualize the Process Workflow in Step 01 (Step01_Processes) like this
Source and example (once merged): https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/GettingStartedWithProcesses/Step01/Step01_Processes.cs
And the "Fried Fish Preparation Process" looks like this:
And like this if we set the nesting to 1 (no nesting), so it does not go into a subprocess (a step which is a KernelProcess):
Source and example: https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/GettingStartedWithProcesses/Step03/Step03a_FoodPreparation.cs
Problem solved:
Eases understanding complex workflows, helps to validate your workflow and to improve it. Makes understanding FASTER.
Scenario: All scenarios
Related issue: #9514
Existing issue:
Usually a Step (node) has edges to other Steps which is OK.
But, in case of a Step which is a Process (ie, composed of other steps), This Step can have an Edge to an Inner Step, which makes no sense. After a great discussion with the team, @alliscode and @esttenorio (thanks a ton for the great interaction and discussion) this is done at the moment to represent Entry Steps, where the workflow is starting on the Process Step.
This made it impossible to draw this properly and is ignored, but upon discovery it was rendered like this for reference:
And if we debug the Edges of the Step which is a Process, we see it has two, the second one properly formed is the exit Edge but the first one on the Edge Key it does not have a properly formed EventId but a simple name:
This comes from the entry point defined next (Thanks @esttenorio for finding it):
Here is there the root process steps "links" with the internal steps of the nested process.
Which works, but we end up with a Edge from an "event" (FriedFishProcess.ProcessEvents.PrepareFriedFish) to an Internal Step.
The biggest problem here is that the Event is parentless, not associated to a Step. So, we cannot "paint" the graph to depict where does it come from.
The technical solution is to attach the Edge to the target Step, but it has no parent.
Proposal: Make all Events with a Single Parent. One Event, One Parent, point. And associate the events to that parent through an Edge. so we know where it starts and where it ends(goes). This way will enable proper tooling and accurate rendering - and the inherent graph will not try to "trick us".
(I will create an issue for this)
Solution:
At the moment we are identifying and ignoring those Edges.
Description
Added ProcessVisualizationExtensions.cs in Process.Core to render the markdown at the core, next to the ProcessBuilder, as an extension method to it.
Updated Sample 01 to showcase example, also added the MermaidRenderer.cs to render an image of this mermaid code by using PuppeteerSharp, which had to be added to the GettingStartedWithProcesses.
Contribution Checklist