Build typed IPython app execution pipeline
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Literal
|
||||
|
||||
|
||||
CallEventKind = Literal[
|
||||
"stdout",
|
||||
"stderr",
|
||||
"display_data",
|
||||
"execute_result",
|
||||
"clear_output",
|
||||
"update_display_data",
|
||||
"error",
|
||||
]
|
||||
|
||||
|
||||
@dataclass
|
||||
class CallEvent:
|
||||
"""One ordered, UI-safe event emitted while a call executes."""
|
||||
|
||||
call_id: str
|
||||
sequence: int
|
||||
kind: CallEventKind
|
||||
text: str | None = None
|
||||
data: dict[str, object] | None = None
|
||||
metadata: dict[str, object] | None = None
|
||||
transient: dict[str, object] | None = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class CallError:
|
||||
"""Serializable error information from one cell execution."""
|
||||
|
||||
ename: str
|
||||
evalue: str
|
||||
traceback: list[str]
|
||||
|
||||
|
||||
@dataclass
|
||||
class CallResult:
|
||||
"""The application-level result of one cell execution."""
|
||||
|
||||
call_id: str
|
||||
execution_count: int | None
|
||||
result: object | None
|
||||
error: CallError | None = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class CallResponse:
|
||||
"""Complete response envelope intended for a UI or graph node."""
|
||||
|
||||
call_id: str
|
||||
shell_name: str
|
||||
code: str
|
||||
collapsed: bool
|
||||
result: CallResult
|
||||
events: list[CallEvent]
|
||||
Reference in New Issue
Block a user