Commit graph

174 commits

Author SHA1 Message Date
Sid
721b2c2ca8
Enable Ruff PT012 (#113957) 2024-06-08 17:59:08 +02:00
Marc Mueller
837ee7c4fb
Import Generator from typing_extensions (4) (#118992) 2024-06-06 17:41:37 +02:00
epenet
1317837986
Improve type hints in tests (q-z) (#118381) 2024-05-30 08:48:02 +02:00
J. Nick Koston
0888233f06
Make Recorder dialect_name a cached_property (#117922) 2024-05-29 09:23:40 +02:00
epenet
44f715bd02
Use issue_registry fixture in component tests (#118041) 2024-05-24 15:54:20 +02:00
J. Nick Koston
5a609c34bb
Fix blocking I/O in the event loop when loading timezones (#117721) 2024-05-20 11:06:03 +02:00
J. Nick Koston
d06932bbc2
Refactor asyncio loop protection to improve performance (#117295) 2024-05-13 07:01:55 +09:00
Erik Montnemery
f5fe80bc90
Convert recorder init tests to use async API (#116918) 2024-05-06 07:59:39 -05:00
J. Nick Koston
6339c63176
Improve recorder and worker thread matching in RecorderPool (#116886)
* Improve recorder and worker thread matching in RecorderPool

Previously we would look at the name of the threads. This
was a brittle if because other integrations may name their
thread Recorder or DbWorker. Instead we now use explict thread
ids which ensures there will never be a conflict

* fix

* fixes

* fixes
2024-05-05 16:25:10 -04:00
Erik Montnemery
27fcf72275
Convert history tests to use async API (#116447)
* Convert history tests to use async API

* Add new fixture to help patch recorder

* Modify

* Modify

* Update tests/conftest.py

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

* Rename fixture

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-05-03 08:14:46 +02:00
Erik Montnemery
aa65f21be7
Fix flapping recorder tests (#116239) 2024-04-26 09:05:23 -05:00
Erik Montnemery
10be8f9683
Simplify timezone setting in recorder test (#116220) 2024-04-26 15:14:23 +02:00
J. Nick Koston
5447a1a015
Ensure all tables have the default table args in the db_schema (#114895) 2024-04-05 08:22:00 +02:00
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
Marc Mueller
81c34ac952
Fix spelling [docstrings + comments] (#114168) 2024-03-25 11:33:00 +01:00
Sid
00ec7f11f0
Enable Ruff rule PT007 (#113764)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2024-03-19 09:01:07 +01:00
J. Nick Koston
ef0c17749f
Use async_create_task in recorder init tests (#113586) 2024-03-16 15:40:50 +01:00
Sid
27e844e3bf
Add ruff B005, B015, B032 and fix occurrences (#113543)
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-15 17:48:37 -10:00
J. Nick Koston
af6f2a516e
Guard against db corruption when renaming entities (#112718) 2024-03-08 11:34:07 -10:00
Marc Mueller
7d6251ca08
Add empty line after module docstring [tests q-s] (#112711) 2024-03-08 14:47:22 +01:00
J. Nick Koston
235771aaa2
Bump SQLAlchemy to 2.0.28 (#112314) 2024-03-05 12:14:30 -10:00
Marc Mueller
2ef2172b01
Convert test helpers to get hass instance to contextmanagers (#109990)
* Convert get_test_home_assistant helper to contextmanager

* Convert async_test_home_assistant helper to contextmanager

* Move timezone reset to async_test_home_assistant helper
2024-02-11 21:23:51 +01:00
Marc Mueller
438d3b01b9
Use builtin TimeoutError [o-s] (#109682) 2024-02-05 12:14:37 +01:00
J. Nick Koston
a22244707b
Create an issue when database backups fail because the system runs out of resources (#109020) 2024-01-30 10:23:58 -10:00
J. Nick Koston
c399cab427
Small speed up to checking core state (#107845) 2024-01-18 08:41:32 -10:00
Ville Skyttä
24b1e01d71
Update Ruff to 0.1.8, avoid linter/formatter conflicts (#106080)
* Disable Ruff rules that may conflict with the formatter

* Upgrade Ruff to 0.1.8

- https://github.com/astral-sh/ruff/releases/tag/v0.1.7
- https://github.com/astral-sh/ruff/releases/tag/v0.1.8

* Format with Ruff 0.1.8
2023-12-20 23:55:09 +01:00
Erik Montnemery
0dc21504f5
Remove support for excluding attributes in recorder platforms (#100679) 2023-09-24 14:45:06 +02:00
Ville Skyttä
34b47a2597
Remove unnnecessary pylint configs from components [m-r]* (#98924) 2023-08-24 00:56:50 +02:00
Marc Mueller
cd8d6ecd81
Fix recorder DeprecationWarnings (#97738) 2023-08-04 11:32:51 +02:00
J. Nick Koston
b2e708834f
Add slots to the StateMachine class (#95849) 2023-07-05 14:00:37 +02:00
Allen Porter
12129e9d21
Update service call return values and error handling (#94657)
* Update return signature of service calls

* Add timeout error handling in websocket api for service calls

* Update recorder tests to remove assertion on service call

* Remove timeout behavior and update callers that depend on it today

* Fix tests

* Add missing else

* await coro directly

* Fix more tests

* Update the intent task to use wait instead of timeout

* Remove script service call limits and limit constants

* Update tests that depend on service call limits

* Use wait instead of wait_for and add test

* Update homeassistant/helpers/intent.py

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

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-06-16 07:01:40 -07:00
J. Nick Koston
2ec1359063
Dynamically size recorder max backlog based on available memory (#90894)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-04-18 12:35:49 +02:00
J. Nick Koston
fdc6cf3472
Continue recording events until final write (#91260) 2023-04-16 09:22:47 -10:00
J. Nick Koston
1379ad60c8
Ensure recorder always attempts clean shutdown if recorder thread raises (#91261)
* Ensure recorder run shutdown if the run loop raises

If anything goes wrong with the recorder we should
still try to shutdown cleanly

* tweak

* tests

* tests

* handle migraiton failure

* tweak comment

* naming

* order

* order

* order

* reword

* adjust test

* fixes

* threading

* failure case

* fix test

* have to wait for stop because the task blocks on thread join
2023-04-14 21:03:24 -04:00
epenet
2f7c5a56eb
Use tmp_path in recorder tests (#91202) 2023-04-11 09:18:16 +02:00
J. Nick Koston
49079691d4
Reduce overhead of legacy database columns on new installs (#90246)
* Reduce overhead of legacy database columns on new installs

* Reduce overhead of legacy database columns on new installs

* Reduce overhead of legacy database columns on new installs

* Reduce overhead of legacy database columns on new installs

* not working as expected

* override the type compiler

* override the type compiler

* override the type compiler

* override the type compiler

* Apply suggestions from code review

* pgsql char1

* make entity filter test setup with old schema

* fix some more tests that were mutating state

* fix some more tests that were mutating state

* fix some more tests that were mutating state

* fix more dbstate mutations

* add shim for older tests

* split migration tests

* add coverage for purging legacy data

* tweak

* more fixes

* drop some legacy

* fix another test

* fix a few more

* add casts for postgresql in case someone deletes the schema changes table

* dry

* dry

* dry
2023-04-10 10:08:46 -04:00
J. Nick Koston
96c5e845e5
Guard against invalid ULIDs in contexts while recording events (#90889) 2023-04-06 10:34:54 +02:00
J. Nick Koston
4f1574b859
Prevent overly large event data from being stored in the database (#90747)
This is the same change as #87105 for events
2023-04-04 00:02:49 -04:00
J. Nick Koston
d49fbc17df
Fix recorder attribute excludes not being effective until after startup (#90198)
* Fix attribute excludes not being effective until after startup

fixes #90016

* reduce
2023-03-23 20:52:37 -04:00
J. Nick Koston
96225bb287
Rename recorder run_history to table_managers.recorder_runs_manager (#90070) 2023-03-21 18:38:33 -10:00
epenet
ab4a726e6c
Add tmpdir to known fixtures in pylint (#89844) 2023-03-17 10:22:02 +01:00
J. Nick Koston
f6f3565796
Reduce latency to find stats metadata (#89824) 2023-03-16 19:00:02 -10:00
epenet
ff8b91aeea
Add freezer to known test fixtures in pylint (#89825)
Add freezer to known fixtures in pylint
2023-03-16 22:39:41 -04:00
J. Nick Koston
e379aa23bd
Migrate StateAttributes to use a table manager (#89760)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2023-03-15 15:26:29 -10:00
J. Nick Koston
b906d67c1e
Fix filtered purge not removing newer events (#89721) 2023-03-14 16:33:19 -10:00
J. Nick Koston
c41f91be89
Deduplicate entity_id in the states table (#89557) 2023-03-12 10:01:58 -10:00
J. Nick Koston
8bd43760b6
Deduplicate event_types in the events table (#89465)
* Deduplicate event_types in the events table

* Deduplicate event_types in the events table

* more fixes

* adjust

* adjust

* fix product

* fix tests

* adjust

* migrate

* migrate

* migrate

* more test fixes

* more test fixes

* fix

* migration test

* adjust

* speed up

* fix index

* fix more tests

* handle db failure

* preload

* tweak

* adjust

* fix stale docs strings, remove dead code

* refactor

* fix slow tests

* coverage

* self join to resolve query performance

* fix typo

* no need for quiet

* no need to drop index already dropped

* remove index that will never be used

* drop index sooner as we no longer use it

* Revert "remove index that will never be used"

This reverts commit 461aad2c52.

* typo
2023-03-11 14:54:55 -05:00
J. Nick Koston
a9731a7b26
Make the recorder LRU adjustment threadsafe (#88443) 2023-02-19 19:30:08 +01:00
J. Nick Koston
9df00bd285
Adjust recorder LRU cache to align with the number of entities (#88350)
* Adjust size of recorder LRU based on number of entities

If there are a large number of entities the cache would
get thrashed as there were more state attributes being
recorded than the size of the cache. This meant we had
to go back to the database to do lookups frequently when
an instance has more than 2048 entities that change
frequently

* add a test

* do not actually record 4096 states

* patch target

* patch target
2023-02-19 00:02:36 -05:00
J. Nick Koston
3ca9f3c0d5
Only build the recorder SupportedDialect enum once (#88402)
Every call to dialect_name was creating a new enum object
in the recorder
2023-02-18 20:21:14 -05:00