-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
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
Converge stream av open methods, options, and error handling #134020
Conversation
Hey there @hunterjm, @uvjustin, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Hey there @rytilahti, @bdraco, @sdb9696, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
# Import from stream.worker as stream cannot reexport from worker | ||
# without forcing the av dependency on default_config | ||
# pylint: disable-next=import-outside-toplevel | ||
from homeassistant.components.stream.worker import StreamWorkerError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, this is removing rather than moving to new import location. This can never be thrown here since its caught by Stream
and never exposed. We can fix exception handling here by exposing the error codes in a follow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@allenporter
Ok this makes sense.
It looks like this change is what has lowered the coverage in #133927
Lines like
if err.details:
errors["error_details"] = err.details
...no longer have any way of being triggered.
I will add a test to raise StreamOpenClientError
within the generic config flow to restore the test coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok sorry for missing that -- btw there is still not yet a way that StreamOpenClientError
is thrown here, but need to add in a follow up.
@@ -48,7 +49,7 @@ | |||
CONF_PART_DURATION = "part_duration" | |||
CONF_SEGMENT_DURATION = "segment_duration" | |||
|
|||
CONF_PREFER_TCP = "prefer_tcp" | |||
ATTR_PREFER_TCP = "prefer_tcp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reaming this since its not a configuration option. This is not exposed in __all__
today.
super().__init__(*args, **kwargs) | ||
|
||
|
||
async def _async_try_open_stream( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is removed since it is not used anywhere.
if pyav_options is None: | ||
pyav_options = {} | ||
|
||
default_pyav_options = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These options are slightly different than the defaults used by the stream component. These have been removed and converted with the existing default.
|
||
def _try_open_stream( | ||
source: str, pyav_options: dict[str, str] | None = None | ||
) -> InputContainer | OutputContainer: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is changed to only be InputContainer
when moving since we're only using one of the open constructors for input.
raise HomeAssistantError("Invalid stream options") from exc | ||
|
||
if extra_wait_time := stream_options.get(CONF_EXTRA_PART_WAIT_TIME): | ||
stream_settings.hls_part_timeout += extra_wait_time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to add coverage for this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is easy to get coverage for, but hard to test since stream settings are consumed deeper in HLS. I'm skipping this for now.
Proposed change
Address proposed improvements in #132866 with related cleanup. This converges:
generic
config flow which will happen in follow up steps. Currently the exceptions caught in generic are not validType of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: