-
Notifications
You must be signed in to change notification settings - Fork 2
Continuous cache improving #351
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
Conversation
WalkthroughDeferred cache-file existence tracking from initialization to read time in Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Caller
participant CacheHelper as Helper (plugwise_usb/helpers/cache.py)
participant FS as FileSystem
Caller->>CacheHelper: initialize_cache()
Note right of CacheHelper: no existence flag set at init
Caller->>CacheHelper: read_cache()
CacheHelper->>FS: exists(self._cache_file)?
alt file exists
CacheHelper->>FS: read file
FS-->>CacheHelper: data
CacheHelper-->>Caller: parsed cache
else file missing
CacheHelper-->>Caller: empty cache
end
sequenceDiagram
autonumber
actor RegistryCaller
participant Registry as NetworkRegistry
participant NetCache as NetworkRegistrationCache
RegistryCaller->>Registry: update_network_nodetype(mac, node_type)
Registry->>NetCache: update_nodetype(mac, node_type)
alt node_type is None or CIRCLE_PLUS
NetCache-->>Registry: no-op (skipped)
else
NetCache->>NetCache: validate/update nodetypes and save
NetCache-->>Registry: ack
end
Registry-->>RegistryCaller: done
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #351 +/- ##
==========================================
- Coverage 82.14% 82.08% -0.07%
==========================================
Files 36 36
Lines 8171 8171
==========================================
- Hits 6712 6707 -5
- Misses 1459 1464 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
plugwise_usb/helpers/cache.py(1 hunks)plugwise_usb/network/cache.py(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: bouwew
PR: plugwise/python-plugwise-usb#329
File: plugwise_usb/nodes/circle.py:0-0
Timestamp: 2025-08-30T10:46:42.649Z
Learning: In plugwise_usb/nodes/circle.py, the save_cache() method should only be called when both cache_updated AND save_cache parameters are True. If no cache updates occurred (cache_updated = False), there's no meaningful data to persist to disk, even if the caller requested saving (save_cache = True). This prevents unnecessary disk I/O operations.
Learnt from: bouwew
PR: plugwise/python-plugwise-usb#255
File: plugwise_usb/nodes/circle.py:615-627
Timestamp: 2025-06-20T07:58:41.534Z
Learning: In the plugwise_usb/nodes/circle.py file, the `log_addresses_missing` property being `None` means the parameter has not been initialized yet, not that all logs are present. When `log_addresses_missing` is `None`, returning `False` from cache loading methods is correct because the system is not properly initialized and further execution would be useless.
📚 Learning: 2025-08-30T10:46:42.649Z
Learnt from: bouwew
PR: plugwise/python-plugwise-usb#329
File: plugwise_usb/nodes/circle.py:0-0
Timestamp: 2025-08-30T10:46:42.649Z
Learning: In plugwise_usb/nodes/circle.py, the save_cache() method should only be called when both cache_updated AND save_cache parameters are True. If no cache updates occurred (cache_updated = False), there's no meaningful data to persist to disk, even if the caller requested saving (save_cache = True). This prevents unnecessary disk I/O operations.
Applied to files:
plugwise_usb/network/cache.py
🧬 Code graph analysis (1)
plugwise_usb/helpers/cache.py (1)
tests/test_usb.py (1)
exists(209-221)
only a single nodetype update is stored
098d2b2 to
cc9d586
Compare
dirixmjm
left a comment
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.
LGTM
|



This update prohibits an unintentional
nodetype.cacheupdate that replaces the existing file with an empty file.Summary by CodeRabbit
Bug Fixes
Refactor
Chores