Update communication.md

This commit is contained in:
Zachary Huang 2025-03-15 02:00:27 -04:00 committed by GitHub
parent e52d205769
commit 4a8ad825a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 4 deletions

View File

@ -7,9 +7,9 @@ nav_order: 3
# Communication # Communication
Nodes and Flows **communicate** in two ways: Nodes and Flows **communicate** in 2 ways:
1. **Shared Store (recommended)** 1. **Shared Store (for almost all the cases)**
- A global data structure (often an in-mem dict) that all nodes can read and write by `prep()` and `post()`. - A global data structure (often an in-mem dict) that all nodes can read and write by `prep()` and `post()`.
- Great for data results, large content, or anything multiple nodes need. - Great for data results, large content, or anything multiple nodes need.
@ -21,7 +21,7 @@ Nodes and Flows **communicate** in two ways:
If you know memory management, think of the **Shared Store** like a **heap** (shared by all function calls), and **Params** like a **stack** (assigned by the caller). If you know memory management, think of the **Shared Store** like a **heap** (shared by all function calls), and **Params** like a **stack** (assigned by the caller).
> Use `Shared Store` for almost all cases. It's flexible and easy to manage. It separates *Data Schema* from *Compute Logic*, making the code easier to maintain. `Params` is more a syntax sugar for [Batch](./batch.md). > **Separation of Concerns:** Use `Shared Store` for almost all cases to separate *Data Schema* from *Compute Logic*! This approach is both flexible and easy to manage, resulting in more maintainable code. `Params` is more a syntax sugar for [Batch](./batch.md).
{: .best-practice } {: .best-practice }
--- ---
@ -123,4 +123,4 @@ flow = Flow(start=node)
# 5) Set Flow params (overwrites node params) # 5) Set Flow params (overwrites node params)
flow.set_params({"filename": "doc2.txt"}) flow.set_params({"filename": "doc2.txt"})
flow.run(shared) # The node summarizes doc2, not doc1 flow.run(shared) # The node summarizes doc2, not doc1
``` ```