Commit Graph

231 Commits (c7ce53cc4954190e9b7a6b11537190a565599416)

Author SHA1 Message Date
Joost Lekkerkerker 6bb4e7d62c
Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-26 00:02:16 +01:00
J. Nick Koston d0708b5b32
Fix grammar in async_get_platform comment (#113948)
https://github.com/home-assistant/core/pull/113917#pullrequestreview-1951203739
2024-03-21 15:10:47 -04:00
J. Nick Koston 3b66328591
Add a fast path for async_get_platform (#113917) 2024-03-21 09:34:33 +01:00
J. Nick Koston c615b52840
Refactor integration startup time to show wall clock time (#113707)
* Refactor setup time tracking to exclude time waiting on other operations

We now exclude the import time and th time waiting on
base platforms to setup from the setup times

* tweak

* tweak

* tweak

* tweak

* adjust

* fixes

* fixes

* preen

* preen

* tweak

* tweak

* adjust

* tweak

* reduce

* do not count integrtion platforms against their parent integration

* handle legacy tts platforms

* stt as well

* one more wait

* use the same pattern in all the legacy

* fix tts and stt legacy

* fix

* fix

* reduce

* preen

* entity comp does not wait for platforms

* scene blocks as well

* fix test

* test fixes

* coverage

* coverage

* coverage

* fix test

* Update tests/test_setup.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update tests/test_setup.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update homeassistant/setup.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* strip

* strip WAIT_PLATFORM_INTEGRATION

* strip WAIT_PLATFORM_INTEGRATION

* strip WAIT_PLATFORM_INTEGRATION

* strip WAIT_PLATFORM_INTEGRATION

* remove complexity

* Apply suggestions from code review

* no longer works that way

* fixes

* fixes

* fixes

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-03-18 21:45:34 -04:00
Sid 6ee273a548
Clean up unneeded ruff noqa directives (#113616) 2024-03-16 09:48:37 -10:00
G Johansson e8de1a7031
Revert "Avoid pre-importing config_flows if the integration does not … (#113553)
Revert "Avoid pre-importing config_flows if the integration does not support …"

This reverts commit 9940f51b95.
2024-03-15 23:15:36 +01:00
J. Nick Koston 9940f51b95
Avoid pre-importing config_flows if the integration does not support migration (#113369)
* Avoid pre-importing config_flows if the integration does support migration

Currently we pre-import the config flow module if it exists since
setting up the config entry required comparing the versions found
in the config_flow.py. We can avoid the pre-import if the integration
does not support async_migrate_entry which means we avoid loading
many config flows in memory at startup.

* cover

* fix missing block

* do not call directly

* its too fast now, the test gets more along

* Update homeassistant/loader.py
2024-03-14 00:13:40 -04:00
Paulus Schoutsen 145657dc21
Only load services.yaml for integrations that have it (#112732)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-11 19:05:32 +01:00
J. Nick Koston afa69cca38
Import custom components in the executor by default (#112177)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-03-10 08:41:33 -10:00
J. Nick Koston 08416974c9
Avoid trying to load translations for integrations that have none (#112683) 2024-03-08 14:21:44 -10:00
Marc Mueller 19ab3d6daf
Add empty line after module docstring [helpers + other] (#112707) 2024-03-08 10:36:11 -05:00
Erik Montnemery ffcb06beb9
Allow start_time >= 1.1.7 (#112500) 2024-03-06 14:56:50 +01:00
Erik Montnemery 807c3ca76b
Add custom integration block list (#112481)
* Add custom integration block list

* Fix typo

* Add version condition

* Add block reason, simplify blocked versions, add tests

* Change logic for OK versions

* Add link to custom integration's issue tracker

* Add missing file

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-03-06 13:56:47 +01:00
J. Nick Koston e568f867d2
Adjust MAX_LOAD_CONCURRENTLY constant to allow 6 storage loaders (#112468) 2024-03-05 16:31:10 -10:00
J. Nick Koston 946572e382
Simplify loader preload logic for config_flows (#112290)
We previously checked Integration.config_flow to see if we should
pre-import the config flow, but this is now always set for some
integration like `homeassistant_green`, `hassio`, etc. Instead
we can add it to the rest of the platforms since we already know
which files exist. This simplifies the logic and ensures the pre-import
still happens if the file is there even if its not listed in the
manifest

`2024-03-04 22:54:31.906 DEBUG (MainThread) [homeassistant.loader] Importing platforms for homeassistant_green executor=[config_flow] loop=[] took 2.74s`
2024-03-05 10:02:23 -05:00
J. Nick Koston 7cb8a8bbc9
Migrate remaining calls in config modules to async_get_component (#112293)
* Migrate remaining calls in config modules to async_get_component

There were a few cases that were still using get_component that
could have done blocking I/O in the event loop, although it
was unlikely.

The caching check in async_get_component has been moved
up to avoid creating the future if the module is already in
the cache

* fix one more
2024-03-05 09:59:52 -05:00
J. Nick Koston 8b017016b0
Refactor integration platforms to import in the executor (#112168)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-03-04 19:21:18 -10:00
J. Nick Koston 1e173e82d0
Add support for preloading platforms in the loader (#112282)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-03-04 16:33:12 -10:00
J. Nick Koston 917f0f849d
Import in the executor by default for core integrations (#112127)
* Import in the executor by default for core integration

* merge correct branch in

* Group loading of platforms in the import executor

* adjust test

* remove other pr

* Fix async_prepare_setup_platform test

The message changed because the order changed but was not caught before
merge because it required the combination of PRs to change
the error message

* fix

* tweak

* fix

* self review

* review

* fix hue mocking

* Update homeassistant/loader.py

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* lint

* Fix async_get_component loading in the executor when the module is already loaded

The sys.modules check was incorrect (only on dev)

* fix

* Avoid multiple executor jobs with concurrent calls to async_get_component

Return a future that can be awaited if the component is
curently being loaded

* adjust

* coverage

* coverage

* concurrent platforms load test

* doc strings

* coverage

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-03-04 06:29:32 -05:00
J. Nick Koston 5227976aa2
Group loading of platforms in the import executor (#112141)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-03-03 21:32:19 -10:00
J. Nick Koston 943996b60b
Avoid multiple executor jobs with concurrent calls to async_get_component (#112155) 2024-03-03 20:22:31 -10:00
J. Nick Koston f4b2c9b569
Fix async_get_component loading in the executor when the module is already loaded (#112153) 2024-03-03 17:56:50 -10:00
J. Nick Koston f1eab3f11f
Preload config flow if it exists when loading a component (#112145)
Since config_entries always requires the config_flow to be loaded
to check for migrations, load it if we know it exists when loading
the underlying integration
2024-03-03 21:16:50 -05:00
J. Nick Koston ba9733e90b
Try to preload the config platform when loading a component (#112104) 2024-03-03 10:23:08 -10:00
J. Nick Koston c8cb0ff61d
Avoid trying to import platforms that do not exist (#112028)
* Avoid trying to import platforms that do not exist

* adjust

* fixes

* cleanup

* cleanup

* cleanup

* Apply suggestions from code review

* docs

* fixes

* fixes

* comment

* coverage

* coverage

* coverage

* Switch config to use async_get_component

This was another path where integrations that were marked to load in the executor
would be loaded in the loop

* Switch config to use async_get_component/async_get_platform

This was another path where integrations that were marked to load in the executor
would be loaded in the loop

* merge

* refactor

* refactor

* coverage

* preen

* preen
2024-03-02 22:14:28 -05:00
J. Nick Koston 567d4d5926
Simplify load_executor check in loader (#112029) 2024-03-02 09:01:11 -10:00
Jan-Philipp Benecke 914abcec32
Change `hass.components` removal version in log to 2024.9 (#111903) 2024-02-29 21:05:33 -05:00
J. Nick Koston 25510fc13c
Limit executor imports to a single thread (#111898)
* Limit executor imports to a single thread

* test for import executor

* test for import executor

* test for import executor

* fixes

* better fix
2024-02-29 21:02:13 -05:00
J. Nick Koston ba4120d779
Fallback to event loop import on deadlock (#111868) 2024-02-29 09:01:03 -10:00
Jan-Philipp Benecke bc6b4d01c8
Deprecate `hass.components` and log warning if used inside custom component (#111508)
* Deprecate @bind_hass and log error if used inside custom component

* Log also when accessing `hass.components`

* Log warning only when `hass.components` is used

* Change version

* Process code review
2024-02-29 12:25:46 +01:00
J. Nick Koston c38e0d22b8
Fix text in docstrings and debug logging for loader (#111560) 2024-02-26 15:14:15 -10:00
J. Nick Koston 4ea1c5cc3c
Add support for importing integrations in the executor (#111336)
* Add support for pre-imports at setup time

alternative solution to #111331

* refactor

* refactor

* refactor

* mark >1.0s integrations

* no point in executor if already loaded

* no point in executor if already loaded

* cleanup

* cleanup

* two more

* one more

* analytics loads a lot more integrations

* cloud

* debug

* psutil, hardwre

* try zha

* Update homeassistant/setup.py

* await

* comments

* coverage

* coverage

* coverage

* move logic to loader

* move logic to loader

* preserve comments
2024-02-26 14:49:43 -05:00
Jan-Philipp Benecke baf84b6fba
Add `single_config_entry` manifest option (#109505)
* Allow setting if we support multiple config entries in config flow

* Move property to config flow instead of flow handler

* Move marking an integration as single instance only to manifest

* Revert line remove

* Avoid init a config flow or adding a new entry on a single instance with an entry

* Revert changes in test

* Process code review comments

* Apply code review suggestion
2024-02-26 19:00:33 +01:00
J. Nick Koston 3aecec5082
Avoid rechecking for missing platforms in the loader (#111204) 2024-02-23 10:48:47 -10:00
J. Nick Koston 1260c5a909
Speed up bootstrap by preloading manifests for base platforms (#110130) 2024-02-16 09:35:46 -06:00
J. Nick Koston 95015fbb40
Small performance improvement to async_get_config_flows (#110666)
- Migrates to using a future instead of Event like we have done
  everywhere else
2024-02-16 14:32:26 +01:00
J. Nick Koston f7b9b0da0e
Migrate dependencies loader to use async_get_integrations (#110690) 2024-02-16 08:07:39 +01:00
J. Nick Koston 37897ee384
Move late import of config flows in loader to load time (#110688)
* Move late import of config flows in loader to load time

There does not seem to be any reason to import the
generated flows late. Import them at load time
with the rest of the generated files

* tests
2024-02-16 07:55:12 +01:00
J. Nick Koston 01c3205635
Small performance improvements to config entry setup retry (#110448)
* Small performance improvements to config entry setup retry

- cache some properties that never change
- avoid loader.async_get_integration when we already have it
- avoid multiple integration.domain checks

* tweaks
2024-02-13 13:28:52 +01:00
J. Nick Koston 6173bfe873
Cache commonly called Integration manifest properties (#108141) 2024-01-16 21:05:44 +01:00
Joakim Plate 523352c97e
Avoid keeping config dir in path (#107760) 2024-01-16 13:38:47 +01:00
J. Nick Koston bb30bfa225
Reduce zeroconf matcher complexity (#105880) 2023-12-23 11:04:05 +01:00
Aarni Koskela 706add4a57
Switch formatting from black to ruff-format (#102893)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-11-27 14:38:59 +01:00
Erik Montnemery 50e11a7a37
Tweak loader.resolve_dependencies (#103851) 2023-11-12 17:27:32 +01:00
Erik Montnemery 97cc05d0b4
Make it possible to restart core in safe mode (#102606) 2023-10-24 14:47:58 +02:00
Erik Montnemery c481fdb7d0
Rename safe mode to recovery mode (#102580) 2023-10-23 20:33:08 +02:00
Erik Montnemery 17779c5f0c
Add loader.async_suggest_report_issue and loader.async_get_issue_tracker (#101336)
* Add loader.async_suggest_report_issue and loader.async_get_issue_tracker

* Update tests

* Add tests

* Address review comments

* Address review comments
2023-10-04 13:40:33 +02:00
Artur Pragacz e1771ae01e
Fix circular dependancy detection (#100458)
* Fix _async_component_dependencies

Fix bug with circular dependency detection
Fix bug with circular after_dependency detection
Simplify interface and make the code more readable

* Implement review feedback

* Pass all conflicting deps to Exception

* Change inner docstring

Co-authored-by: Erik Montnemery <erik@montnemery.com>

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-09-28 08:05:00 +02:00
J. Nick Koston e5ebba0753
Fix module check in _async_get_flow_handler (#99509)
We should have been checking for the module in hass.data[DATA_COMPONENTS]
and not hass.config.components as the check was ineffective if there were
no existing integrations instances for the domain which is the case for
discovery or when the integration is ignored
2023-09-04 14:19:10 -04:00
Erik Montnemery 7643820e59
Add loader.async_get_loaded_integration (#99440)
* Add loader.async_get_loaded_integration

* Decorate async_get_loaded_integration with @callback
2023-09-04 14:12:33 +02:00