Skip to content

Commit e61742f

Browse files
authored
Merge pull request #10 from chatziko/run-satellite-start-stage
add start_stage to run-satellite
2 parents 3ef7ee0 + 08fbd3a commit e61742f

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
@@ -222,6 +222,7 @@ Play audio stream.
222222
Control of one or more remote voice satellites connected to a central server.
223223

224224
* `run-satellite` - informs satellite that server is ready to run pipelines
225+
* `start_stage` - request pipelines with a specific starting stage (string, optional)
225226
* `pause-satellite` - informs satellite that server is not ready anymore to run pipelines
226227
* `satellite-connected` - satellite has connected to the server
227228
* `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)