Skip to content

Display flow run outputs in Python script node editor#340

Open
Edwardvaneechoud wants to merge 1 commit intofeauture/kernel-implementationfrom
claude/show-notebook-display-output-KEWjh
Open

Display flow run outputs in Python script node editor#340
Edwardvaneechoud wants to merge 1 commit intofeauture/kernel-implementationfrom
claude/show-notebook-display-output-KEWjh

Conversation

@Edwardvaneechoud
Copy link
Owner

Summary

This PR adds functionality to retrieve and display output artifacts (images, HTML, text) from the last flow execution in the Python script node editor. When a flow run completes, the frontend now automatically fetches display outputs and attaches them to the last notebook cell for visualization.

Key Changes

  • Frontend (PythonScript.vue):

    • Added watch to monitor flow run completion via editorStore.isRunning
    • Implemented loadFlowRunDisplayOutputs() to fetch display outputs from the backend
    • Attaches display outputs to the last cell's output when flow execution completes
    • Integrated display output loading into the node data initialization flow
  • Frontend API (node.api.ts):

    • Added getDisplayOutputs() method to retrieve display outputs from backend
    • Gracefully handles errors by returning empty array
  • Backend Routes (routes.py):

    • Added /node/display_outputs GET endpoint to retrieve display outputs for a specific node
    • Validates flow and node existence before returning results
  • Backend Models (flow_graph.py & flow_node/models.py):

    • Extended NodeResults class with display_outputs field to store output artifacts
    • Added logic to capture and store display outputs after kernel execution
    • Converts display output objects to serializable dictionaries for API response

Implementation Details

  • Display outputs are stored on the node's results object during flow execution, making them available for retrieval after the run completes
  • The frontend uses a watcher on editorStore.isRunning to detect when a flow run finishes and automatically refreshes both display outputs and artifacts
  • Display outputs are attached to the last cell in the notebook, allowing users to see execution results directly in the editor
  • Error handling is graceful—if display outputs cannot be retrieved, the operation fails silently without disrupting the user experience

https://claude.ai/code/session_01LxQSB6d2gGPRCG9wGcmRnH

When running a flow with python_script nodes, display outputs (matplotlib
plots, plotly charts, images, HTML, text) from flowfile.display() calls
were captured by the kernel but discarded by the flow execution engine.
Now they are stored on the node and exposed via a new API endpoint so
the notebook editor can show them automatically.

Backend:
- Store display_outputs on NodeResults after kernel execution
- Add GET /node/display_outputs endpoint to retrieve them

Frontend:
- Add NodeApi.getDisplayOutputs() method
- Fetch display outputs when PythonScript panel loads and after flow
  run completes, attaching them to the last notebook cell

https://claude.ai/code/session_01LxQSB6d2gGPRCG9wGcmRnH
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 26.31579% with 14 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
flowfile_core/flowfile_core/routes/routes.py 16.66% 10 Missing ⚠️
flowfile_core/flowfile_core/flowfile/flow_graph.py 0.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

3 participants