[PR #292] [MERGED] Draw nested workflow mermaid #298

Closed
opened 2026-02-16 02:17:10 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/run-llama/workflows-py/pull/292
Author: @hippopond
Created: 1/21/2026
Status: Merged
Merged: 1/27/2026
Merged by: @adrianlyjak

Base: mainHead: draw_nested_workflow_mermaid


📝 Commits (10+)

  • 0380590 Draw Nested Workflow. (not execution). With the corresponding test
  • c2381ec Works now. using _get_workflow_representation. Previous
  • 2779310 Added the Callable in the import statements.
  • 48e9d1d Changeset file
  • dfb560c Nested Workflows: Combined functions to
  • d495f26 Nested Workflows. Made the draw_all_possible_flows_mermaid a bit more
  • 5229c65 Nested Workflows: Makes _get_workflow_classes_from_step more robust,
  • 22e9dcb Nested Workflow: with reorganized location of helper functions
  • 47aee6d Merge branch 'main' into draw_nested_workflow_mermaid
  • 61cf273 Merge branch 'main' into draw_nested_workflow_mermaid

📊 Changes

4 files changed (+333 additions, -13 deletions)

View changed files

.changeset/new-hairs-follow.md (+5 -0)
📝 packages/llama-index-utils-workflow/src/llama_index/utils/workflow/__init__.py (+207 -13)
📝 packages/llama-index-utils-workflow/tests/conftest.py (+28 -0)
📝 packages/llama-index-utils-workflow/tests/test_drawing.py (+93 -0)

📄 Description

Previously, when a user has a nested workflow (childworkflow is instantiated in one of the Steps in a Parent Workflow): e.g.

####################################################################
class ChildWorkflowA(Workflow):
    @step()
    async def child_start(self, ev: StartEvent) -> StopEvent:
        return StopEvent(result="Child processed")


class ParentWorkflow(Workflow):
    @step()
    async def parent_start(self, ev: StartEvent) -> Event:
        # Instantiate the nested workflow. The drawing function will inspect this.
        child_wf = ChildWorkflowA()
        # The actual run logic is not important for drawing.
        _ = await child_wf.run(input="dummy")
        return Event(result="some result")

    @step()
    async def parent_end(self, ev: Event) -> StopEvent:
        return StopEvent(result="Final Result")
####################################################################

The utility function: draw_all_possible_flows_mermaid
draws only the parent workflow with no indication of the child.

This PR introduces a new function (with the corresponding test case) : draw_all_possible_flows_nested_mermaid
that draws the second level nested Workflow.

NOTE:

  • 1 Nested Level. (currently not recursive)
  • If the same ChildWorkflow is used in a separate Parent Step, it is treated separately (I can make it the same)

Here is a side by side of what the difference in output is for the 2 utility functions (existing and new addition):

side_by_side

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/run-llama/workflows-py/pull/292 **Author:** [@hippopond](https://github.com/hippopond) **Created:** 1/21/2026 **Status:** ✅ Merged **Merged:** 1/27/2026 **Merged by:** [@adrianlyjak](https://github.com/adrianlyjak) **Base:** `main` ← **Head:** `draw_nested_workflow_mermaid` --- ### 📝 Commits (10+) - [`0380590`](https://github.com/run-llama/workflows-py/commit/0380590d7d0d2aab6a18d5bfa5c7f44919e1167e) Draw Nested Workflow. (not execution). With the corresponding test - [`c2381ec`](https://github.com/run-llama/workflows-py/commit/c2381eced07695b440bbf5dcdc16a7e15882a4ab) Works now. using _get_workflow_representation. Previous - [`2779310`](https://github.com/run-llama/workflows-py/commit/27793109dde7e04dd091b07bfdc9214ae0e83b91) Added the Callable in the import statements. - [`48e9d1d`](https://github.com/run-llama/workflows-py/commit/48e9d1d96544224a8c1ba78b516da3cd509a62ef) Changeset file - [`dfb560c`](https://github.com/run-llama/workflows-py/commit/dfb560cc7888f15534a4ed58588f62a2d6a40a57) Nested Workflows: Combined functions to - [`d495f26`](https://github.com/run-llama/workflows-py/commit/d495f26ac3690d717d43c5584b9031003ff40f4a) Nested Workflows. Made the draw_all_possible_flows_mermaid a bit more - [`5229c65`](https://github.com/run-llama/workflows-py/commit/5229c65bb3320d90c6b483eec480940b36bf404e) Nested Workflows: Makes _get_workflow_classes_from_step more robust, - [`22e9dcb`](https://github.com/run-llama/workflows-py/commit/22e9dcb01aa8ba719ccf14d8c248ba8b9618bad4) Nested Workflow: with reorganized location of helper functions - [`47aee6d`](https://github.com/run-llama/workflows-py/commit/47aee6da023dcf915e4f21f65863272fed9e2df8) Merge branch 'main' into draw_nested_workflow_mermaid - [`61cf273`](https://github.com/run-llama/workflows-py/commit/61cf27383c7674378d28e111cdfbc8e8f670645d) Merge branch 'main' into draw_nested_workflow_mermaid ### 📊 Changes **4 files changed** (+333 additions, -13 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/new-hairs-follow.md` (+5 -0) 📝 `packages/llama-index-utils-workflow/src/llama_index/utils/workflow/__init__.py` (+207 -13) 📝 `packages/llama-index-utils-workflow/tests/conftest.py` (+28 -0) 📝 `packages/llama-index-utils-workflow/tests/test_drawing.py` (+93 -0) </details> ### 📄 Description Previously, when a user has a nested workflow (childworkflow is instantiated in one of the Steps in a Parent Workflow): e.g. ``` #################################################################### class ChildWorkflowA(Workflow): @step() async def child_start(self, ev: StartEvent) -> StopEvent: return StopEvent(result="Child processed") class ParentWorkflow(Workflow): @step() async def parent_start(self, ev: StartEvent) -> Event: # Instantiate the nested workflow. The drawing function will inspect this. child_wf = ChildWorkflowA() # The actual run logic is not important for drawing. _ = await child_wf.run(input="dummy") return Event(result="some result") @step() async def parent_end(self, ev: Event) -> StopEvent: return StopEvent(result="Final Result") #################################################################### ``` The utility function: draw_all_possible_flows_mermaid draws only the parent workflow with no indication of the child. This PR introduces a new function (with the corresponding test case) : draw_all_possible_flows_nested_mermaid that draws the second level nested Workflow. NOTE: - 1 Nested Level. (currently not recursive) - If the same ChildWorkflow is used in a separate Parent Step, it is treated separately (I can make it the same) Here is a side by side of what the difference in output is for the 2 utility functions (existing and new addition): <img width="1323" height="734" alt="side_by_side" src="https://github.com/user-attachments/assets/43a7b504-209e-4b6c-ac70-1850daa4b2c0" /> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 02:17:10 -05:00
yindo closed this issue 2026-02-16 02:17:10 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/workflows-py#298