-
Notifications
You must be signed in to change notification settings - Fork 42
Enhance documentation for Runtime blocking behavior and interactive usage #333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,29 @@ The `Runtime` class is the core component that manages the execution environment | |
|
|
||
| ## Runtime Setup | ||
|
|
||
| Before creating a runtime, you need to set up the state manager and configure your environment variables. | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| 1. **Start the State Manager**: Run the state manager using Docker Compose: | ||
| ```bash | ||
| docker-compose up -d | ||
| ``` | ||
| For detailed setup instructions, see [State Manager Setup](./state-manager-setup.md). | ||
|
|
||
| 2. **Set Environment Variables**: Configure your authentication: | ||
| ```bash | ||
| export EXOSPHERE_STATE_MANAGER_URI="your-state-manager-uri" | ||
| export EXOSPHERE_API_KEY="your-api-key" | ||
| ``` | ||
|
|
||
| Or create a `.env` file: | ||
| ```bash | ||
| EXOSPHERE_STATE_MANAGER_URI=your-state-manager-uri | ||
| EXOSPHERE_API_KEY=your-api-key | ||
| ``` | ||
|
|
||
| ### Creating a Runtime | ||
| === "Basic" | ||
|
|
||
| ```python hl_lines="17-22" | ||
|
|
@@ -68,6 +91,21 @@ The `Runtime` class is the core component that manages the execution environment | |
|
|
||
| ``` | ||
|
|
||
| !!! warning "Blocking Operation" | ||
| `Runtime.start()` is a blocking operation that runs indefinitely. In interactive environments like Jupyter notebooks, consider running it in a background thread: | ||
|
|
||
| ```python | ||
| import threading | ||
|
|
||
| def run_runtime(): | ||
| runtime.start() | ||
|
|
||
| thread = threading.Thread(target=run_runtime, daemon=True) | ||
| thread.start() | ||
| ``` | ||
|
|
||
| See the [Getting Started guide](../getting-started.md#important-blocking-behavior) for more alternatives. | ||
|
|
||
|
Comment on lines
+94
to
+108
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Blocking warning: ensure fenced code block renders (not indented-code). Markdownlint flagged MD046. Keep fenced code inside the admonition with 4-space indentation (MkDocs Material), but avoid extra leading spaces that turn it into an indented block. - ```python
- import threading
-
- def run_runtime():
- runtime.start()
-
- thread = threading.Thread(target=run_runtime, daemon=True)
- thread.start()
- ```
+ ```python
+ import threading
+
+ def run_runtime():
+ runtime.start()
+
+ thread = threading.Thread(target=run_runtime, daemon=True)
+ thread.start()
+ ```Also, consider adding a line noting how to stop the runtime cleanly (mirroring Getting Started). 🧰 Tools🪛 LanguageTool[grammar] ~94-~94: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~95-~95: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) 🪛 markdownlint-cli2 (0.17.2)96-96: Trailing spaces (MD009, no-trailing-spaces) 97-97: Code block style (MD046, code-block-style) 🤖 Prompt for AI Agents |
||
| ## Runtime Parameters | ||
|
|
||
| ### Required Parameters | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -86,6 +86,74 @@ Runtime( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).start() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Important: Blocking Behavior | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Fix minor spacing/markdownlint nits around headings and fences. Ensure a single blank line before/after headings and fenced code blocks; remove double spaces flagged by LanguageTool/MD031. Also applies to: 91-91, 93-93, 95-95, 97-97, 120-120, 142-142 🧰 Tools🪛 LanguageTool[grammar] ~89-~89: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| **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. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### For Interactive Environments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| If you're working in a Jupyter notebook or Python REPL, consider these alternatives: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| === "Background Thread" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ```python | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import threading | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Create the runtime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runtime = Runtime( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespace="MyProject", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name="DataProcessor", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nodes=[SampleNode] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Run in a background thread | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def run_runtime(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runtime.start() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| thread = threading.Thread(target=run_runtime, daemon=True) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| thread.start() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Your interactive session continues here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print("Runtime is running in the background!") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+99
to
+118
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Background-thread pattern: add a minimal shutdown note. Daemon threads exit abruptly on interpreter shutdown. Recommend documenting how to stop the runtime (e.g., a stop() API or signal handling) to avoid partial work loss. - thread = threading.Thread(target=run_runtime, daemon=True)
+ thread = threading.Thread(target=run_runtime, daemon=True)
thread.start()
- # Your interactive session continues here
+ # Your interactive session continues here. To stop cleanly, prefer a provided
+ # `runtime.stop()` or send KeyboardInterrupt in terminals if supported.
print("Runtime is running in the background!")📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| === "Asyncio Task" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ```python | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import asyncio | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Create the runtime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runtime = Runtime( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespace="MyProject", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name="DataProcessor", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nodes=[SampleNode] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # In an async context (like a Jupyter notebook), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # runtime.start() returns a task that runs in the background. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runtime_task = runtime.start() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Your interactive session can continue. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print("Runtime is running in the background!") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # You can now do other async work while the runtime runs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # For example: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # await asyncio.sleep(10) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # print("Finished waiting.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| === "Production Script" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ```python | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # For production scripts, the blocking behavior is usually desired | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if __name__ == "__main__": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Runtime( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespace="MyProject", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name="DataProcessor", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nodes=[SampleNode] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).start() # Blocks and runs forever | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Next Steps | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Now that you have the basics, explore: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -107,14 +175,10 @@ Now that you have the basics, explore: | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Architecture | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| │ Your Nodes │ │ Runtime │ │ State Manager │ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| │ │◄──►│ │◄──►│ │ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| │ - Inputs │ │ - Registration │ │ - Orchestration │ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| │ - Outputs │ │ - Execution │ │ - State Mgmt │ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| │ - Secrets │ │ - Error Handling │ │ - Dashboard │ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| └─────────────────┘ └──────────────────┘ └─────────────────┘ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ```mermaid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| graph LR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| A["Your Nodes<br/>- Inputs<br/>- Outputs<br/>- Secrets"] <--> B["Runtime<br/>- Registration<br/>- Execution<br/>- Error Handling"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| B <--> C["State Manager<br/>- Orchestration<br/>- State Mgmt<br/>- Dashboard"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Data Model (v1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Prereqs: prefer “docker compose” and fix markdownlint issues around fences.
🧰 Tools
🪛 LanguageTool
[grammar] ~7-~7: Use correct spacing
Context: ...nd configure your environment variables. ### Prerequisites 1. **Start the State Mana...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~9-~9: Use correct spacing
Context: ...nvironment variables. ### Prerequisites 1. Start the State Manager: Run the state...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~11-~11: Use correct spacing
Context: ... the state manager using Docker Compose:
bash docker-compose up -dFor detailed setup instructions, see [St...(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~15-~15: Use correct spacing
Context: ...anager Setup](./state-manager-setup.md). 2. Set Environment Variables: Configure y...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~17-~17: Use correct spacing
Context: ...iables**: Configure your authentication:
bash export EXOSPHERE_STATE_MANAGER_URI="your-state-manager-uri" export EXOSPHERE_API_KEY="your-api-key"Or create a.envfile: ```bash E...(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~23-~23: Use correct spacing
Context: ..."
Or create a `.env` file:bash EXOSPHERE_STATE_MANAGER_URI=your-state-manager-uri EXOSPHERE_API_KEY=your-api-key### Creating a Runtime === "Basic"p...(QB_NEW_EN_OTHER_ERROR_IDS_5)
🪛 markdownlint-cli2 (0.17.2)
12-12: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
14-14: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
18-18: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
22-22: Trailing spaces
Expected: 0 or 2; Actual: 3
(MD009, no-trailing-spaces)
24-24: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
🤖 Prompt for AI Agents
🧹 Nitpick (assertive)
Code snippet variables vs env: avoid NameError in later examples.
Advanced example uses
EXOSPHERE_STATE_MANAGER_URI/EXOSPHERE_API_KEYas Python names. Recommend showingos.getenv(...)orload_dotenv()usage explicitly before they are referenced.Offer to patch if you confirm desired style (os.getenv vs dotenv).
🧰 Tools
🪛 LanguageTool
[grammar] ~7-~7: Use correct spacing
Context: ...nd configure your environment variables. ### Prerequisites 1. **Start the State Mana...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~9-~9: Use correct spacing
Context: ...nvironment variables. ### Prerequisites 1. Start the State Manager: Run the state...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~11-~11: Use correct spacing
Context: ... the state manager using Docker Compose:
bash docker-compose up -dFor detailed setup instructions, see [St...(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~15-~15: Use correct spacing
Context: ...anager Setup](./state-manager-setup.md). 2. Set Environment Variables: Configure y...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~17-~17: Use correct spacing
Context: ...iables**: Configure your authentication:
bash export EXOSPHERE_STATE_MANAGER_URI="your-state-manager-uri" export EXOSPHERE_API_KEY="your-api-key"Or create a.envfile: ```bash E...(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~23-~23: Use correct spacing
Context: ..."
Or create a `.env` file:bash EXOSPHERE_STATE_MANAGER_URI=your-state-manager-uri EXOSPHERE_API_KEY=your-api-key### Creating a Runtime === "Basic"p...(QB_NEW_EN_OTHER_ERROR_IDS_5)
🪛 markdownlint-cli2 (0.17.2)
12-12: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
14-14: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
18-18: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
22-22: Trailing spaces
Expected: 0 or 2; Actual: 3
(MD009, no-trailing-spaces)
24-24: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
🤖 Prompt for AI Agents