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

Rename PipelineData.pipeline_runs to pipeline_debug #100907

Merged
merged 1 commit into from
Sep 26, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions homeassistant/components/assist_pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,11 @@ def __post_init__(self) -> None:
raise InvalidPipelineStagesError(self.start_stage, self.end_stage)

pipeline_data: PipelineData = self.hass.data[DOMAIN]
if self.pipeline.id not in pipeline_data.pipeline_runs:
pipeline_data.pipeline_runs[self.pipeline.id] = LimitedSizeDict(
if self.pipeline.id not in pipeline_data.pipeline_debug:
pipeline_data.pipeline_debug[self.pipeline.id] = LimitedSizeDict(
size_limit=STORED_PIPELINE_RUNS
)
pipeline_data.pipeline_runs[self.pipeline.id][self.id] = PipelineRunDebug()
pipeline_data.pipeline_debug[self.pipeline.id][self.id] = PipelineRunDebug()

# Initialize with audio settings
self.audio_processor_buffer = AudioBuffer(AUDIO_PROCESSOR_BYTES)
Expand All @@ -518,10 +518,10 @@ def process_event(self, event: PipelineEvent) -> None:
"""Log an event and call listener."""
self.event_callback(event)
pipeline_data: PipelineData = self.hass.data[DOMAIN]
if self.id not in pipeline_data.pipeline_runs[self.pipeline.id]:
if self.id not in pipeline_data.pipeline_debug[self.pipeline.id]:
# This run has been evicted from the logged pipeline runs already
return
pipeline_data.pipeline_runs[self.pipeline.id][self.id].events.append(event)
pipeline_data.pipeline_debug[self.pipeline.id][self.id].events.append(event)

def start(self, device_id: str | None) -> None:
"""Emit run start event."""
Expand Down Expand Up @@ -1559,7 +1559,7 @@ async def ws_set_preferred_item(
class PipelineData:
"""Store and debug data stored in hass.data."""

pipeline_runs: dict[str, LimitedSizeDict[str, PipelineRunDebug]]
pipeline_debug: dict[str, LimitedSizeDict[str, PipelineRunDebug]]
pipeline_store: PipelineStorageCollection
pipeline_devices: set[str] = field(default_factory=set, init=False)

Expand Down
14 changes: 7 additions & 7 deletions homeassistant/components/assist_pipeline/websocket_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,18 @@ def websocket_list_runs(
pipeline_data: PipelineData = hass.data[DOMAIN]
pipeline_id = msg["pipeline_id"]

if pipeline_id not in pipeline_data.pipeline_runs:
if pipeline_id not in pipeline_data.pipeline_debug:
connection.send_result(msg["id"], {"pipeline_runs": []})
return

pipeline_runs = pipeline_data.pipeline_runs[pipeline_id]
pipeline_debug = pipeline_data.pipeline_debug[pipeline_id]

connection.send_result(
msg["id"],
{
"pipeline_runs": [
{"pipeline_run_id": id, "timestamp": pipeline_run.timestamp}
for id, pipeline_run in pipeline_runs.items()
for id, pipeline_run in pipeline_debug.items()
]
},
)
Expand All @@ -294,17 +294,17 @@ def websocket_get_run(
pipeline_id = msg["pipeline_id"]
pipeline_run_id = msg["pipeline_run_id"]

if pipeline_id not in pipeline_data.pipeline_runs:
if pipeline_id not in pipeline_data.pipeline_debug:
connection.send_error(
msg["id"],
websocket_api.const.ERR_NOT_FOUND,
f"pipeline_id {pipeline_id} not found",
)
return

pipeline_runs = pipeline_data.pipeline_runs[pipeline_id]
pipeline_debug = pipeline_data.pipeline_debug[pipeline_id]

if pipeline_run_id not in pipeline_runs:
if pipeline_run_id not in pipeline_debug:
connection.send_error(
msg["id"],
websocket_api.const.ERR_NOT_FOUND,
Expand All @@ -314,7 +314,7 @@ def websocket_get_run(

connection.send_result(
msg["id"],
{"events": pipeline_runs[pipeline_run_id].events},
{"events": pipeline_debug[pipeline_run_id].events},
)


Expand Down
40 changes: 20 additions & 20 deletions tests/components/assist_pipeline/test_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ async def test_text_only_pipeline(
events.append(msg["event"])

pipeline_data: PipelineData = hass.data[DOMAIN]
pipeline_id = list(pipeline_data.pipeline_runs)[0]
pipeline_run_id = list(pipeline_data.pipeline_runs[pipeline_id])[0]
pipeline_id = list(pipeline_data.pipeline_debug)[0]
pipeline_run_id = list(pipeline_data.pipeline_debug[pipeline_id])[0]

await client.send_json_auto_id(
{
Expand Down Expand Up @@ -153,8 +153,8 @@ async def test_audio_pipeline(
events.append(msg["event"])

pipeline_data: PipelineData = hass.data[DOMAIN]
pipeline_id = list(pipeline_data.pipeline_runs)[0]
pipeline_run_id = list(pipeline_data.pipeline_runs[pipeline_id])[0]
pipeline_id = list(pipeline_data.pipeline_debug)[0]
pipeline_run_id = list(pipeline_data.pipeline_debug[pipeline_id])[0]

await client.send_json_auto_id(
{
Expand Down Expand Up @@ -316,8 +316,8 @@ async def test_audio_pipeline_with_wake_word_no_timeout(
events.append(msg["event"])

pipeline_data: PipelineData = hass.data[DOMAIN]
pipeline_id = list(pipeline_data.pipeline_runs)[0]
pipeline_run_id = list(pipeline_data.pipeline_runs[pipeline_id])[0]
pipeline_id = list(pipeline_data.pipeline_debug)[0]
pipeline_run_id = list(pipeline_data.pipeline_debug[pipeline_id])[0]

await client.send_json_auto_id(
{
Expand Down Expand Up @@ -452,8 +452,8 @@ async def sleepy_converse(*args, **kwargs):
events.append(msg["event"])

pipeline_data: PipelineData = hass.data[DOMAIN]
pipeline_id = list(pipeline_data.pipeline_runs)[0]
pipeline_run_id = list(pipeline_data.pipeline_runs[pipeline_id])[0]
pipeline_id = list(pipeline_data.pipeline_debug)[0]
pipeline_run_id = list(pipeline_data.pipeline_debug[pipeline_id])[0]

await client.send_json_auto_id(
{
Expand Down Expand Up @@ -505,8 +505,8 @@ async def sleepy_run(*args, **kwargs):
events.append(msg["event"])

pipeline_data: PipelineData = hass.data[DOMAIN]
pipeline_id = list(pipeline_data.pipeline_runs)[0]
pipeline_run_id = list(pipeline_data.pipeline_runs[pipeline_id])[0]
pipeline_id = list(pipeline_data.pipeline_debug)[0]
pipeline_run_id = list(pipeline_data.pipeline_debug[pipeline_id])[0]

await client.send_json_auto_id(
{
Expand Down Expand Up @@ -573,8 +573,8 @@ async def test_intent_failed(
events.append(msg["event"])

pipeline_data: PipelineData = hass.data[DOMAIN]
pipeline_id = list(pipeline_data.pipeline_runs)[0]
pipeline_run_id = list(pipeline_data.pipeline_runs[pipeline_id])[0]
pipeline_id = list(pipeline_data.pipeline_debug)[0]
pipeline_run_id = list(pipeline_data.pipeline_debug[pipeline_id])[0]

await client.send_json_auto_id(
{
Expand Down Expand Up @@ -628,8 +628,8 @@ async def sleepy_run(*args, **kwargs):
events.append(msg["event"])

pipeline_data: PipelineData = hass.data[DOMAIN]
pipeline_id = list(pipeline_data.pipeline_runs)[0]
pipeline_run_id = list(pipeline_data.pipeline_runs[pipeline_id])[0]
pipeline_id = list(pipeline_data.pipeline_debug)[0]
pipeline_run_id = list(pipeline_data.pipeline_debug[pipeline_id])[0]

await client.send_json_auto_id(
{
Expand Down Expand Up @@ -760,8 +760,8 @@ async def test_stt_stream_failed(
events.append(msg["event"])

pipeline_data: PipelineData = hass.data[DOMAIN]
pipeline_id = list(pipeline_data.pipeline_runs)[0]
pipeline_run_id = list(pipeline_data.pipeline_runs[pipeline_id])[0]
pipeline_id = list(pipeline_data.pipeline_debug)[0]
pipeline_run_id = list(pipeline_data.pipeline_debug[pipeline_id])[0]

await client.send_json_auto_id(
{
Expand Down Expand Up @@ -828,8 +828,8 @@ async def test_tts_failed(
events.append(msg["event"])

pipeline_data: PipelineData = hass.data[DOMAIN]
pipeline_id = list(pipeline_data.pipeline_runs)[0]
pipeline_run_id = list(pipeline_data.pipeline_runs[pipeline_id])[0]
pipeline_id = list(pipeline_data.pipeline_debug)[0]
pipeline_run_id = list(pipeline_data.pipeline_debug[pipeline_id])[0]

await client.send_json_auto_id(
{
Expand Down Expand Up @@ -1792,8 +1792,8 @@ async def test_audio_pipeline_with_enhancements(
events.append(msg["event"])

pipeline_data: PipelineData = hass.data[DOMAIN]
pipeline_id = list(pipeline_data.pipeline_runs)[0]
pipeline_run_id = list(pipeline_data.pipeline_runs[pipeline_id])[0]
pipeline_id = list(pipeline_data.pipeline_debug)[0]
pipeline_run_id = list(pipeline_data.pipeline_debug[pipeline_id])[0]

await client.send_json_auto_id(
{
Expand Down