Skip to content

Add named inputs/outputs and edge labels for Python script nodes#344

Merged
Edwardvaneechoud merged 15 commits intomainfrom
claude/named-node-inputs-outputs-SIjmK
Mar 14, 2026
Merged

Add named inputs/outputs and edge labels for Python script nodes#344
Edwardvaneechoud merged 15 commits intomainfrom
claude/named-node-inputs-outputs-SIjmK

Conversation

@Edwardvaneechoud
Copy link
Copy Markdown
Owner

Summary

This PR adds support for named inputs and outputs in Python script nodes, along with visual edge labels to improve data flow clarity in the canvas. Users can now configure multiple named outputs, see available inputs from connected nodes, and optionally display edge labels showing data flow names.

Key Changes

Named Inputs & Outputs

  • Python Script UI: Added "Available Inputs" panel showing inputs derived from connected source nodes with their types, and "Output Names" editor allowing users to configure multiple named outputs
  • Backend Support: Modified write_inputs_to_parquet() to support named input keys (e.g., orders, customers) while maintaining backward compatibility with "main" as a fallback
  • Output Handling: Updated flow graph execution to read and store multiple named outputs from parquet files, mapping them to output handles
  • API Endpoint: Added /node/input_names endpoint to retrieve available inputs for a node with source node info

Edge Labels

  • Canvas Display: Implemented edge label computation prioritizing output handle labels (for multi-output nodes) > node_reference > default df_{nodeId} format
  • Label Management: Added refreshAllEdgeLabels() and updateEdgeLabelsForNode() functions to sync labels when node references or output names change
  • Toggle Setting: Added "Show edge labels" checkbox in flow settings (defaults to true) to control label visibility
  • Node Wrapper: Added visual handle labels for multi-input/output nodes showing the specific input/output name

Code Generation & Help

  • Completions: Added dynamic input completions in code editor for available named inputs with boost priority
  • Documentation: Updated API help examples to show named input/output patterns with realistic examples (orders, customers, clean/rejected)

Data Flow

  • Node Reference Integration: Updated node store to reactively update edge labels when node references change
  • Multi-Copy Support: Enhanced copy/paste to preserve output labels and names for duplicated nodes
  • Kernel Manager: Updated path resolution to group parquet files by input name from filename pattern

Notable Implementation Details

  • Input names are derived from source node's node_reference field or fallback to df_{source_node_id}
  • All inputs remain accessible via flowfile.read_input("main") for backward compatibility
  • Output names are stored in NodePythonScript.output_names and synchronized with VueFlow node output handles
  • Edge labels respect the showEdgeLabels toggle and update reactively when node properties change
  • Handle labels only display when there are multiple inputs/outputs to avoid clutter

Extend kernel execution to support named input keys derived from source
node references (e.g., flowfile.read_input("orders")) while keeping
backward compatibility via the "main" key. Add multi-output support to
Python Script nodes mirroring the existing UserDefinedNode pattern, with
a UI editor for configuring output names and dynamic handle rendering.

Backend:
- write_inputs_to_parquet accepts optional input_names for per-source keys
- add_python_script resolves input names from source node_reference
- Multi-output loop reads named parquets into _named_outputs dict
- NodePythonScript gains output_names field (default: ["main"])
- New GET /node/input_names endpoint for frontend discovery
- NodeInput schema carries output_names for frontend serialization

Frontend:
- NodeWrapper renders handle labels when nodes have multiple handles
- PythonScript settings panel: output names editor + available inputs display
- Dynamic autocomplete for read_input("name") in code editor
- API client method for input names endpoint
- Updated FlowfileApiHelp with named I/O documentation
- TypeScript types and defaults updated across flow/node types

https://claude.ai/code/session_01M94qqeYWUGVGG7cpJ7z7G3
When a node has multiple named outputs, the connection lines (edges)
leaving each output handle now display the output name as a label.
Labels are applied in all edge creation paths: manual connections,
flow import, and multi-node copy-paste. Edge label CSS counters the
existing color inversion filter so labels render with normal colors.

https://claude.ai/code/session_01M94qqeYWUGVGG7cpJ7z7G3
Include node_reference in the backend NodeInput schema and
get_node_input() serialization so the frontend receives it.
Use node_reference as the edge label when the source node has
one set (e.g., "orders", "clients" connecting into a python_script).
Named output labels (e.g., "valid", "invalid") take precedence
over node_reference for multi-output nodes.

https://claude.ai/code/session_01M94qqeYWUGVGG7cpJ7z7G3
The resolve_node_paths() method hardcoded all input parquet files under
the "main" key, so flowfile.read_input("orders") failed in the
interactive notebook editor. The files are named {name}_{index}.parquet
(e.g. orders_0.parquet), so parse the input name from each filename
and group paths accordingly. A "main" key is still added as a
backward-compatible alias pointing to all input files.

https://claude.ai/code/session_01M94qqeYWUGVGG7cpJ7z7G3
- Edge labels now update reactively when node_reference changes
  (no UI refresh needed)
- Add "Show edge labels" toggle in Execution Settings dialog,
  persisted in FlowSettings (show_edge_labels field)
- When no node_reference is set, edges show df_{nodeId} as the
  default label instead of being blank
- Toggling edge labels off/on immediately hides/shows all labels

https://claude.ai/code/session_01M94qqeYWUGVGG7cpJ7z7G3
@netlify
Copy link
Copy Markdown

netlify bot commented Feb 28, 2026

Deploy Preview for flowfile-wasm canceled.

Name Link
🔨 Latest commit e0636a8
🔍 Latest deploy log https://app.netlify.com/projects/flowfile-wasm/deploys/69b44ac7041a3d0007e87733

claude added 2 commits March 3, 2026 16:07
12 unit tests for resolve_node_paths covering: named input parsing
from filenames, main-only grouping, no-op cases (pre-set paths,
missing flow_id/node_id), empty/missing input dirs, underscored
names, multiple files per name, fallback for files without index
suffix, and path translation in local mode.

4 tests for FlowSettings.show_edge_labels covering: default value,
explicit false, model_dump/validate roundtrip, and backward
compatibility when the field is absent.

https://claude.ai/code/session_01M94qqeYWUGVGG7cpJ7z7G3
- Add label? and nodeReference? to NodeData interface in NodeWrapper
  so handle labels are recognized by the type checker
- Cast sourceNode.data to Record<string, any> in computeEdgeLabel
  since VueFlow's generic node data type defaults to {}

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

codecov-commenter commented Mar 3, 2026

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

Codecov Report

❌ Patch coverage is 67.21311% with 40 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
flowfile_core/flowfile_core/flowfile/flow_graph.py 9.52% 38 Missing ⚠️
flowfile_core/flowfile_core/kernel/execution.py 96.15% 1 Missing ⚠️
flowfile_core/flowfile_core/routes/routes.py 92.85% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

claude and others added 7 commits March 4, 2026 12:28
Remove EdgeCopyValue from useDragAndDrop.ts and
NodeDescriptionEntry from node-store.ts.

https://claude.ai/code/session_01M94qqeYWUGVGG7cpJ7z7G3
…/input_names endpoint

Improves coverage on kernel/execution.py (named/unnamed input paths, error handling),
input_schema.py (output_names defaults and roundtrip), and routes.py (/node/input_names
with reference, fallback, empty inputs, and 404 cases).

https://claude.ai/code/session_01M94qqeYWUGVGG7cpJ7z7G3
Backend:
- Add null guard on node before attribute access in add_python_script
- Extract _resolve_input_names helper to eliminate duplicated logic
- Use zip(strict=True) to catch input name/table count mismatches
- Use model_copy(update=) instead of dump/re-instantiate for template override
- Create NodeInputNameInfo Pydantic model for /node/input_names endpoint
- Update FlowSettings docstring for show_edge_labels field
- Move lazy imports to top-level in test file

Frontend:
- Create shared NodeHandle interface in flow.types.ts
- Create shared InputNameInfo interface in flow.types.ts
- Replace all (o: any) callbacks with typed NodeHandle finds
- Replace Record<string, any> cast with typed FlowNodeData interface
- Type onConnect params with Connection from @vue-flow/core
- Use proper types in NodeWrapper NodeData interface
- Add parseInt radix parameter
- Use unknown instead of any in catch clause

https://claude.ai/code/session_01M94qqeYWUGVGG7cpJ7z7G3
…ibility

Connection.sourceHandle/targetHandle are string|null but NodeConnection
expects specific literal types. Cast them explicitly and use ?? undefined
for the computeEdgeLabel call.

https://claude.ai/code/session_01M94qqeYWUGVGG7cpJ7z7G3
…dwardvaneechoud/Flowfile into claude/named-node-inputs-outputs-SIjmK
…w_edge_labels default mismatch. Add safe identifier validation for node_reference and output_names, defense-in-depth checks in write_inputs_to_parquet, and graceful fallback when input counts diverge.
@Edwardvaneechoud Edwardvaneechoud merged commit b56f503 into main Mar 14, 2026
24 checks passed
@Edwardvaneechoud Edwardvaneechoud deleted the claude/named-node-inputs-outputs-SIjmK branch March 14, 2026 12:08
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