-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprotocol.py
More file actions
71 lines (51 loc) · 1.73 KB
/
Copy pathprotocol.py
File metadata and controls
71 lines (51 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""Equal Python/Rust engine SPI with pandas-free requests and results."""
from __future__ import annotations
from dataclasses import dataclass
from typing import Protocol, runtime_checkable
from ..planning import BackendKind, ExecutionPlan, OutputRequirements, TraceRequirements
from ..preparation import PreparedRun
from ..results import RawEngineResult
@dataclass(frozen=True, slots=True)
class BackendDescriptor:
name: BackendKind
implementation_version: str
protocol_version: int
command_abi_version: str
result_abi_version: str
contracts: tuple[str, ...]
workloads: tuple[str, ...]
build: str
@dataclass(frozen=True, slots=True)
class EngineRunRequest:
run_id: int
output: OutputRequirements
trace: TraceRequirements
seed: int | None = None
parameters: tuple[float, ...] | None = None
def __post_init__(self) -> None:
if self.run_id < 0:
raise ValueError("run_id must be >= 0")
@dataclass(frozen=True, slots=True)
class ResetRequest:
reset_account: bool = True
reset_orders: bool = True
reset_strategy: bool = True
@runtime_checkable
class PreparedEngineSession(Protocol):
@property
def descriptor(self) -> BackendDescriptor: ...
def run(self, request: EngineRunRequest) -> RawEngineResult: ...
def reset(self, reset: ResetRequest = ResetRequest()) -> None: ...
def close(self) -> None: ...
@runtime_checkable
class EngineBackend(Protocol):
@property
def descriptor(self) -> BackendDescriptor: ...
def prepare(self, plan: ExecutionPlan, prepared: PreparedRun) -> PreparedEngineSession: ...
__all__ = [
"BackendDescriptor",
"EngineBackend",
"EngineRunRequest",
"PreparedEngineSession",
"ResetRequest",
]