-
-
Notifications
You must be signed in to change notification settings - Fork 563
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
Initialize and cache descriptors only once #1592
Closed
Closed
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
c99de9b
Add caching
starkillerOG 14933c4
fix black
starkillerOG 62cf7c7
improve caching
starkillerOG 3166772
Move descriptor initialization after model is known
starkillerOG ba83361
Merge branch 'master' into caching
starkillerOG 6904829
fix black
starkillerOG 0fe1954
Merge branch 'caching' of https://github.com/starkillerOG/python-miio…
starkillerOG b2a7873
Update miio/device.py
starkillerOG 1dee65a
Update device.py
starkillerOG a7fcbd8
Merge branch 'caching' of https://github.com/starkillerOG/python-miio…
starkillerOG 67013e4
simplify
starkillerOG 2bcb4ba
Merge branch 'master' into caching
starkillerOG 54121f5
Update miio/device.py
starkillerOG d5ec615
initialize descriptors when needed
starkillerOG 391e42f
Merge branch 'caching' of https://github.com/starkillerOG/python-miio…
starkillerOG 86d6e69
Merge branch 'master' into caching
starkillerOG 79b5e0e
Move actions to _initialize_descriptors
starkillerOG 4494ad1
fix linting
starkillerOG cc010b6
fix typing
starkillerOG 96ecb45
fix isort
starkillerOG 7570e81
fix casting
starkillerOG a8a1ae5
Do not make descriptors optional
starkillerOG ba136e2
Split out action/setting/sensor descriptor retrieval
starkillerOG db24017
Update dummies.py
starkillerOG 9c9493c
Move _initialize_descriptors out of info call
starkillerOG f31c701
fix black
starkillerOG a29c05d
update descriptions
starkillerOG c2691bc
fix docstring
starkillerOG 15b67f9
docformatter
starkillerOG 97d4784
Merge branch 'master' into caching
starkillerOG 1ebb309
revert docstring changes
starkillerOG d03c6f2
Merge branch 'master' into caching
starkillerOG 441de02
do not add initialize method
starkillerOG d5c8a6c
fix typing
starkillerOG 1727060
fix black
starkillerOG 7d17f08
fix mypy None possibilities
starkillerOG c92be40
fixes
starkillerOG 58f72b3
fix mypy
starkillerOG ddb0e82
fix mypy complaining
starkillerOG 587194f
fix tests
starkillerOG 480f384
do not change model can be None
starkillerOG 82d3782
cast model
starkillerOG a43614c
try fixing tests
starkillerOG 0f01e36
try to fix tests
starkillerOG 2c79fe9
try fixing tests
starkillerOG 99a7f11
try fixing tests
starkillerOG 051748c
fix tests device_id query
starkillerOG 7f2e163
try fixing tests
starkillerOG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 wrong, the
_fetch_info()
is device-class internals and should not be accessed by any other class.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.
Well how do you then suggest to prevent the loop: status --> info --> _initialize_descriptors--> status --> etc.
I can just remove the info call, but I am not sure what will then break downstream.
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.
I'm not sure what's the best approach right off the bat (especially as genericmiot constructs status containers dynamically), but for statically defined containers it would be enough to access the status container class without really initializing one, right?
Probably the simplest way to access the status container would be using the return type annotation like this:
Do you think that could work for the time being until we figure out a better solution for that?
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.
I just tried it, but that does not include the embeded sensors:
That is missing the embeded sensors/settings....
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.
Ouch, that's indeed annoying... The real solution would be doing the "embedding" of status container classes outside of the status query (maybe inside
__init__
), and performing the update on the container prior to returning it instatus()
. This way:The question is how/where to do this sanely, I don't have an answer to that right now.
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.
I do see what you mean, and think it is a good path forward,
but I think at this point it gets a bit to complicated for me.
I think it would be more efficient if you would implement those changes.
Than we also do not need to have long wait times in between us working on it.
You could do one of the following: