Skip to content

Commit a6ecb77

Browse files
committed
Add sequence diagram
1 parent e3f39fd commit a6ecb77

File tree

2 files changed

+80
-4
lines changed

2 files changed

+80
-4
lines changed

README.md

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,83 @@ that the server extension is enabled:
3434
jupyter server extension list
3535
```
3636

37+
## How does it works
38+
39+
### Generic case
40+
41+
Execution of a Python code snippet: `print("hello")`
42+
43+
```mermaid
44+
sequenceDiagram
45+
Frontend->>+Server: POST /api/kernels/<id>/execute
46+
Server->>+ExecutionStack: Create asyncio.Task
47+
ExecutionStack->>Kernel: Execute request msg
48+
activate Kernel
49+
ExecutionStack-->>Server: Task uid
50+
Server-->>-Frontend: Returns task uid
51+
loop Running
52+
Kernel->>Shared Document: Add output
53+
Shared Document->>Frontend: Document update
54+
end
55+
loop While status is 202
56+
Frontend->>+Server: GET /api/kernels/<id>/requests/<uid>
57+
Server->>ExecutionStack: Get task result
58+
ExecutionStack-->>Server: null
59+
Server-->>-Frontend: Request status 202
60+
end
61+
Kernel-->>ExecutionStack: Execution reply
62+
deactivate Kernel
63+
Frontend->>+Server: GET /api/kernels/<id>/requests/<uid>
64+
Server->>ExecutionStack: Get task result
65+
ExecutionStack-->>Server: Result
66+
Server-->>-Frontend: Status 200 & result
67+
```
68+
69+
### With input case
70+
71+
72+
Execution of a Python code snippet: `input("Age:")`
73+
74+
```mermaid
75+
sequenceDiagram
76+
Frontend->>+Server: POST /api/kernels/<id>/execute
77+
Server->>+ExecutionStack: Create asyncio.Task
78+
ExecutionStack->>Kernel: Execute request msg
79+
activate Kernel
80+
ExecutionStack-->>Server: Task uid
81+
Server-->>-Frontend: Returns task uid
82+
loop Running
83+
Kernel->>Shared Document: Add output
84+
Shared Document->>Frontend: Document update
85+
end
86+
loop While status is 202
87+
Frontend->>+Server: GET /api/kernels/<id>/requests/<uid>
88+
Server->>ExecutionStack: Get task result
89+
ExecutionStack-->>Server: null
90+
Server-->>-Frontend: Request status 202
91+
end
92+
Kernel->>ExecutionStack: Set pending input
93+
Frontend->>+Server: GET /api/kernels/<id>/requests/<uid>
94+
Server->>ExecutionStack: Get task result
95+
ExecutionStack-->>Server: Pending input
96+
Server-->>-Frontend: Status 300 & Pending input
97+
Frontend->>+Server: POST /api/kernels/<id>/input
98+
Server->>Kernel: Send input msg
99+
Server-->>-Frontend:
100+
loop While status is 202
101+
Frontend->>+Server: GET /api/kernels/<id>/requests/<uid>
102+
Server->>ExecutionStack: Get task result
103+
ExecutionStack-->>Server: null
104+
Server-->>-Frontend: Request status 202
105+
end
106+
Kernel-->>ExecutionStack: Execution reply
107+
deactivate Kernel
108+
Frontend->>+Server: GET /api/kernels/<id>/requests/<uid>
109+
Server->>ExecutionStack: Get task result
110+
ExecutionStack-->>Server: Result
111+
Server-->>-Frontend: Status 200 & result
112+
```
113+
37114
## Contributing
38115

39116
### Development install
@@ -46,7 +123,6 @@ jupyter server extension list
46123
pip install -e .
47124
```
48125

49-
50126
You can watch the source directory and run your Jupyter Server-based application at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension. For example,
51127
when running JupyterLab:
52128

jupyter_server_nbmodel/handlers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def _stdin_hook(self, kernel_id: str, msg: dict) -> None:
111111
112112
It will register the pending input as temporary answer to the execution request.
113113
"""
114-
get_logger().info(f"Execution request {kernel_id} received a input request {msg!s}")
114+
get_logger().debug(f"Execution request {kernel_id} received a input request.")
115115
if kernel_id in self.__pending_inputs:
116116
get_logger().error(
117117
f"Execution request {kernel_id} received a input request while waiting for an input.\n{msg}" # noqa: E501
@@ -186,11 +186,11 @@ async def _execute_snippet(
186186
reply_content = reply["content"]
187187

188188
if ycell is not None:
189-
ycell["execution_count"] = reply_content["execution_count"]
189+
ycell["execution_count"] = reply_content.get("execution_count")
190190

191191
return {
192192
"status": reply_content["status"],
193-
"execution_count": reply_content["execution_count"],
193+
"execution_count": reply_content.get("execution_count"),
194194
# FIXME quid for buffers
195195
"outputs": json.dumps(outputs),
196196
}

0 commit comments

Comments
 (0)