Skip to content

Commit fa73377

Browse files
Enhance documentation for Runtime blocking behavior and interactive usage (#333)
* Enhance documentation for Runtime blocking behavior and interactive usage - Added a section in the Getting Started guide to highlight the blocking nature of `Runtime.start()`, particularly in interactive environments like Jupyter notebooks and Python REPLs. - Provided alternative approaches for running the runtime in the background using threading and asyncio, ensuring users can continue their interactive sessions without interruption. - Updated the index and create-runtime documentation to reference the new guidance on handling blocking operations. - Removed the satellites documentation as part of a cleanup effort, consolidating relevant information into the main guides. * Update docs/docs/getting-started.md Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 9684bb8 commit fa73377

3 files changed

Lines changed: 114 additions & 9 deletions

File tree

docs/docs/exosphere/create-runtime.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,29 @@ The `Runtime` class is the core component that manages the execution environment
44

55
## Runtime Setup
66

7+
Before creating a runtime, you need to set up the state manager and configure your environment variables.
8+
9+
### Prerequisites
10+
11+
1. **Start the State Manager**: Run the state manager using Docker Compose:
12+
```bash
13+
docker-compose up -d
14+
```
15+
For detailed setup instructions, see [State Manager Setup](./state-manager-setup.md).
16+
17+
2. **Set Environment Variables**: Configure your authentication:
18+
```bash
19+
export EXOSPHERE_STATE_MANAGER_URI="your-state-manager-uri"
20+
export EXOSPHERE_API_KEY="your-api-key"
21+
```
22+
23+
Or create a `.env` file:
24+
```bash
25+
EXOSPHERE_STATE_MANAGER_URI=your-state-manager-uri
26+
EXOSPHERE_API_KEY=your-api-key
27+
```
28+
29+
### Creating a Runtime
730
=== "Basic"
831

932
```python hl_lines="17-22"
@@ -68,6 +91,21 @@ The `Runtime` class is the core component that manages the execution environment
6891

6992
```
7093

94+
!!! warning "Blocking Operation"
95+
`Runtime.start()` is a blocking operation that runs indefinitely. In interactive environments like Jupyter notebooks, consider running it in a background thread:
96+
97+
```python
98+
import threading
99+
100+
def run_runtime():
101+
runtime.start()
102+
103+
thread = threading.Thread(target=run_runtime, daemon=True)
104+
thread.start()
105+
```
106+
107+
See the [Getting Started guide](../getting-started.md#important-blocking-behavior) for more alternatives.
108+
71109
## Runtime Parameters
72110

73111
### Required Parameters

docs/docs/getting-started.md

Lines changed: 72 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,74 @@ Runtime(
8686
).start()
8787
```
8888

89+
## Important: Blocking Behavior
90+
91+
**Note**: `Runtime.start()` is a blocking operation that will run indefinitely until stopped. This can be problematic in interactive environments like Jupyter notebooks or Python REPLs.
92+
93+
### For Interactive Environments
94+
95+
If you're working in a Jupyter notebook or Python REPL, consider these alternatives:
96+
97+
=== "Background Thread"
98+
99+
```python
100+
import threading
101+
102+
# Create the runtime
103+
runtime = Runtime(
104+
namespace="MyProject",
105+
name="DataProcessor",
106+
nodes=[SampleNode]
107+
)
108+
109+
# Run in a background thread
110+
def run_runtime():
111+
runtime.start()
112+
113+
thread = threading.Thread(target=run_runtime, daemon=True)
114+
thread.start()
115+
116+
# Your interactive session continues here
117+
print("Runtime is running in the background!")
118+
```
119+
120+
=== "Asyncio Task"
121+
122+
```python
123+
import asyncio
124+
125+
# Create the runtime
126+
runtime = Runtime(
127+
namespace="MyProject",
128+
name="DataProcessor",
129+
nodes=[SampleNode]
130+
)
131+
132+
# In an async context (like a Jupyter notebook),
133+
# runtime.start() returns a task that runs in the background.
134+
runtime_task = runtime.start()
135+
136+
# Your interactive session can continue.
137+
print("Runtime is running in the background!")
138+
139+
# You can now do other async work while the runtime runs.
140+
# For example:
141+
# await asyncio.sleep(10)
142+
# print("Finished waiting.")
143+
```
144+
145+
=== "Production Script"
146+
147+
```python
148+
# For production scripts, the blocking behavior is usually desired
149+
if __name__ == "__main__":
150+
Runtime(
151+
namespace="MyProject",
152+
name="DataProcessor",
153+
nodes=[SampleNode]
154+
).start() # Blocks and runs forever
155+
```
156+
89157
## Next Steps
90158

91159
Now that you have the basics, explore:
@@ -107,14 +175,10 @@ Now that you have the basics, explore:
107175

108176
## Architecture
109177

110-
```
111-
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
112-
│ Your Nodes │ │ Runtime │ │ State Manager │
113-
│ │◄──►│ │◄──►│ │
114-
│ - Inputs │ │ - Registration │ │ - Orchestration │
115-
│ - Outputs │ │ - Execution │ │ - State Mgmt │
116-
│ - Secrets │ │ - Error Handling │ │ - Dashboard │
117-
└─────────────────┘ └──────────────────┘ └─────────────────┘
178+
```mermaid
179+
graph LR
180+
A["Your Nodes<br/>- Inputs<br/>- Outputs<br/>- Secrets"] <--> B["Runtime<br/>- Registration<br/>- Execution<br/>- Error Handling"]
181+
B <--> C["State Manager<br/>- Orchestration<br/>- State Mgmt<br/>- Dashboard"]
118182
```
119183

120184
## Data Model (v1)

docs/docs/index.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,12 @@ Runtime(
5959
namespace="MyProject",
6060
name="HelloWorld",
6161
nodes=[HelloWorldNode]
62-
).start()
62+
).start() # Note: This blocks the main thread
6363
```
6464

65+
!!! info "Interactive Environments"
66+
If you're using Jupyter notebooks or Python REPLs, `Runtime.start()` will block your session. See the [Getting Started guide](./getting-started.md#important-blocking-behavior) for non-blocking alternatives.
67+
6568
### Run it
6669

6770
Run the server with:

0 commit comments

Comments
 (0)