Moderator
lingo.moderator
Testing harness and utilities for orchestration.
Job
Bases: Generic[T]
Represents a dispatched job with result tracking.
Source code in lingo/moderator.py
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 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
result(block: bool = False) -> Optional[T]
Get the result of the job.
Source code in lingo/moderator.py
51 52 53 54 55 | |
set_cancelled() -> None
Mark the job as cancelled.
Source code in lingo/moderator.py
75 76 77 78 79 | |
set_failed(message: str) -> None
Mark the job as failed with an error message.
Source code in lingo/moderator.py
69 70 71 72 73 | |
set_pending() -> None
Mark the job as pending.
Source code in lingo/moderator.py
81 82 83 84 | |
set_result(value: T) -> None
Mark the job as completed with a result.
Source code in lingo/moderator.py
62 63 64 65 66 67 | |
set_running() -> None
Mark the job as running.
Source code in lingo/moderator.py
57 58 59 60 | |
status() -> JobStatus
Get the current status of the job.
Source code in lingo/moderator.py
47 48 49 | |
JobStatus
Represents the status of a job execution.
Source code in lingo/moderator.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
is_ongoing() -> bool
Check if the job is still running.
Source code in lingo/moderator.py
27 28 29 | |
succeeded() -> bool
Check if the job succeeded.
Source code in lingo/moderator.py
31 32 33 | |
Moderator
Test harness for orchestrating test runs.
Source code in lingo/moderator.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
say(phrase: Any) -> Job
Dispatch a phrase and return a job handle.
Source code in lingo/moderator.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
conversation(func: Callable) -> Callable
Decorator that provides a Moderator to orchestrate test runs.
Usage
@lang.conversation def test_something(mod: Moderator): ...
Source code in lingo/moderator.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
echo(task_name: str, reply: Any = None, delay: float = 0.0) -> Callable
Mock task for testing that injects a known result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_name
|
str
|
Name of the task to mock |
required |
reply
|
Any
|
The result to return from this task |
None
|
delay
|
float
|
Delay in seconds before returning |
0.0
|
Returns:
| Type | Description |
|---|---|
Callable
|
A callable that constructs bypass phrases |
Source code in lingo/moderator.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
scribble(root: Optional[str] = None) -> str
Generate a temporary directory for task execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Optional[str]
|
Optional root directory for scribble storage |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Path to temporary directory |
Source code in lingo/moderator.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |