Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add start_stage to run-satellite #10

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ Play audio stream.
Control of one or more remote voice satellites connected to a central server.

* `run-satellite` - informs satellite that server is ready to run pipelines
* `start_stage` - request pipelines with a specific starting stage (string, optional)
* `pause-satellite` - informs satellite that server is not ready anymore to run pipelines
* `satellite-connected` - satellite has connected to the server
* `satellite-disconnected` - satellite has been disconnected from the server
Expand Down
18 changes: 16 additions & 2 deletions wyoming/satellite.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""Satellite events."""
from dataclasses import dataclass
from typing import Any, Dict, Optional

from .event import Event, Eventable
from .pipeline import PipelineStage

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

start_stage: Optional[PipelineStage] = None

@staticmethod
def is_type(event_type: str) -> bool:
return event_type == _RUN_SATELLITE_TYPE

def event(self) -> Event:
return Event(type=_RUN_SATELLITE_TYPE)
data: Dict[str, Any] = {}

if self.start_stage is not None:
data["start_stage"] = self.start_stage.value

return Event(type=_RUN_SATELLITE_TYPE, data=data)

@staticmethod
def from_event(event: Event) -> "RunSatellite":
return RunSatellite()
# note: older versions don't send event.data
start_stage = None
if value := (event.data or {}).get("start_stage"):
start_stage = PipelineStage(value)

return RunSatellite(start_stage=start_stage)


@dataclass
Expand Down