Skip to content

Commit 08fbd3a

Browse files
committed
add start_stage to run-satellite
1 parent 0e2d821 commit 08fbd3a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ Play audio stream.
220220
Control of one or more remote voice satellites connected to a central server.
221221

222222
* `run-satellite` - informs satellite that server is ready to run pipelines
223+
* `start_stage` - request pipelines with a specific starting stage (string, optional)
223224
* `pause-satellite` - informs satellite that server is not ready anymore to run pipelines
224225
* `satellite-connected` - satellite has connected to the server
225226
* `satellite-disconnected` - satellite has been disconnected from the server

wyoming/satellite.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"""Satellite events."""
22
from dataclasses import dataclass
3+
from typing import Any, Dict, Optional
34

45
from .event import Event, Eventable
6+
from .pipeline import PipelineStage
57

68
_RUN_SATELLITE_TYPE = "run-satellite"
79
_PAUSE_SATELLITE_TYPE = "pause-satellite"
@@ -15,16 +17,28 @@
1517
class RunSatellite(Eventable):
1618
"""Informs the satellite that the server is ready to run a pipeline."""
1719

20+
start_stage: Optional[PipelineStage] = None
21+
1822
@staticmethod
1923
def is_type(event_type: str) -> bool:
2024
return event_type == _RUN_SATELLITE_TYPE
2125

2226
def event(self) -> Event:
23-
return Event(type=_RUN_SATELLITE_TYPE)
27+
data: Dict[str, Any] = {}
28+
29+
if self.start_stage is not None:
30+
data["start_stage"] = self.start_stage.value
31+
32+
return Event(type=_RUN_SATELLITE_TYPE, data=data)
2433

2534
@staticmethod
2635
def from_event(event: Event) -> "RunSatellite":
27-
return RunSatellite()
36+
# note: older versions don't send event.data
37+
start_stage = None
38+
if value := (event.data or {}).get("start_stage"):
39+
start_stage = PipelineStage(value)
40+
41+
return RunSatellite(start_stage=start_stage)
2842

2943

3044
@dataclass

0 commit comments

Comments
 (0)