Tile base class that powers every piece of functionality.
Tile
¶
Bases: ABC
Base class to implement custom tiles.
Subclasses should define a unique name and implement execute. When
async support is required override aexecute; otherwise the default
implementation safely offloads the sync execute via asyncio.to_thread.
Source code in src/tileable/tile.py
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 | |
aexecute(payload)
async
¶
Execute the tile asynchronously.
The default behavior offloads execute to a worker thread, ensuring the
event loop never blocks. Overriding tiles can provide a native async
implementation if needed.
Source code in src/tileable/tile.py
43 44 45 46 47 48 49 50 51 | |
execute(payload)
abstractmethod
¶
Execute the tile synchronously.
Source code in src/tileable/tile.py
39 40 41 | |
set_context(context)
¶
Attach or detach the runtime context.
Source code in src/tileable/tile.py
34 35 36 37 | |
Execution context injected into every tile instance.
TileContext
¶
Runtime context that tiles can use to interact with the system.
Source code in src/tileable/context.py
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 | |
services
property
¶
Read-only view of registered services.
state
property
¶
Mutable state bag shared across the current invocation.
emit(event, /, **payload)
¶
Emit event with payload through the event bus.
Source code in src/tileable/context.py
42 43 44 45 | |
get_service(name)
¶
Return a registered service or raise KeyError.
Source code in src/tileable/context.py
47 48 49 50 51 52 53 | |
get_service_or(name, default=None)
¶
Return a service if available, otherwise default.
Source code in src/tileable/context.py
55 56 57 58 | |
set_service(name, value)
¶
Register or override a service for the current invocation.
Source code in src/tileable/context.py
60 61 62 63 | |
Event bus abstraction built on top of :mod:blinker.
CapturedEvent
dataclass
¶
Structured representation of an emitted event.
Source code in src/tileable/events.py
22 23 24 25 26 27 28 | |
EventBus
¶
Small helper around :class:blinker.Namespace.
The bus exposes emit/subscribe/unsubscribe methods to keep the
public API tiny while still giving developers full control over the
underlying signal system.
Source code in src/tileable/events.py
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 | |
emit(event, /, **payload)
¶
Broadcast payload to all subscribers of event.
Source code in src/tileable/events.py
42 43 44 45 46 | |
record(*events, include_sender=False)
¶
Capture emissions for events inside a context manager.
When events is omitted the recorder listens to
:data:STANDARD_EVENTS. The returned object exposes captured
payloads for assertions and debugging.
Source code in src/tileable/events.py
61 62 63 64 65 66 67 68 69 70 | |
subscribe(event, handler, *, weak=False)
¶
Register handler for event and return an unsubscribe callback.
Source code in src/tileable/events.py
48 49 50 51 52 53 | |
unsubscribe(event, handler)
¶
Remove handler from event subscribers if previously registered.
Source code in src/tileable/events.py
55 56 57 58 59 | |
EventRecorder
¶
Context manager that records events emitted by :class:EventBus.
Source code in src/tileable/events.py
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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
events
property
¶
Names of the events being recorded.
clear()
¶
Drop any previously captured events.
Source code in src/tileable/events.py
169 170 171 172 | |
last(name=None)
¶
Return the most recent captured event, optionally filtered by name.
Source code in src/tileable/events.py
159 160 161 162 163 164 165 166 167 | |
payloads(name=None)
¶
Return recorded payloads.
When name is provided only events matching the name are
returned. Copies of the payload dictionaries are produced so callers
can mutate them freely.
Source code in src/tileable/events.py
148 149 150 151 152 153 154 155 156 157 | |
records()
¶
Return captured events in chronological order.
Source code in src/tileable/events.py
143 144 145 146 | |
get_event_bus()
¶
Get a shared :class:EventBus instance.
The helper keeps the footprint tiny for users who prefer not to manually manage bus instances yet allows passing a custom bus everywhere if desired.
Source code in src/tileable/events.py
76 77 78 79 80 81 82 83 84 85 86 87 | |
Tile registry keeping track of available tile classes.
TileRecord
dataclass
¶
Metadata describing a registered tile.
Source code in src/tileable/registry.py
13 14 15 16 17 18 19 20 | |
TileRegistry
¶
Central registry for tile classes.
Source code in src/tileable/registry.py
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 | |
Plugin integration powered by :mod:pluggy.
HookSpecs
¶
Hook specification container registered with :class:pluggy.PluginManager.
Source code in src/tileable/plugins.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
tile_shutdown(ctx, tile, error)
¶
Run after a tile executes, regardless of success.
Source code in src/tileable/plugins.py
29 30 31 32 33 34 | |
tile_specs()
¶
Yield or return an iterable of tile classes to register.
Source code in src/tileable/plugins.py
19 20 21 22 | |
tile_startup(ctx, tile)
¶
Run before a tile executes.
Source code in src/tileable/plugins.py
24 25 26 27 | |
TilePluginManager
¶
Thin wrapper around :class:pluggy.PluginManager with helpful utilities.
Source code in src/tileable/plugins.py
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 | |
Execution helpers for running tiles.
ainvoke_tile(tile, payload, *, registry=None, event_bus=None, plugins=None, services=None, state=None, return_context=False)
async
¶
Async counterpart to :func:invoke_tile.
Source code in src/tileable/runtime.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
invoke_tile(tile, payload, *, registry=None, event_bus=None, plugins=None, services=None, state=None, return_context=False)
¶
Execute tile synchronously and return the result.
Source code in src/tileable/runtime.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | |