-
Notifications
You must be signed in to change notification settings - Fork 6
Call sync setpoint callbacks with validated value #315
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
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #315 +/- ##
=======================================
Coverage 90.79% 90.79%
=======================================
Files 70 70
Lines 2542 2543 +1
=======================================
+ Hits 2308 2309 +1
Misses 234 234 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9369eba to
c8ee243
Compare
📝 WalkthroughWalkthroughChanges improve logging consistency by converting values to Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/fastcs/attributes/attr_r.py (1)
76-98:⚠️ Potential issue | 🟡 MinorLog callback failure with the validated value.
Callbacks are invoked with
self._value, so loggingrepr(value)on failure can mislead when casting occurs (e.g.,"100"→100). Prefer logging the validated value (and optionally keep the raw input in a separate field).🔧 Suggested fix
- logger.opt(exception=e).error( - "On update callbacks failed", attribute=self, value=repr(value) - ) + logger.opt(exception=e).error( + "On update callbacks failed", + attribute=self, + value=repr(self._value), + )
🤖 Fix all issues with AI agents
In `@src/fastcs/transports/epics/ca/util.py`:
- Around line 148-150: The slice uses a falsy check that treats length==0 as
None; update the case handling for the pattern "case String() as string" to
compute max length with an explicit None check (use string.length if
string.length is not None else DEFAULT_STRING_WAVEFORM_LENGTH) and then slice
value[:max_len]; reference the String pattern and DEFAULT_STRING_WAVEFORM_LENGTH
so the semantics preserve a legitimate zero length.
c8ee243 to
2320e58
Compare
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: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/fastcs/attributes/attr_r.py (1)
205-207:⚠️ Potential issue | 🟡 MinorTypo in keyword argument:
target_valuevalueshould betarget_value.Line 206 has a duplicated "value" in the keyword argument name, which will cause the log event to have an incorrectly named parameter.
🐛 Proposed fix
self.log_event( - "Value equals target value", target_valuevalue=target_value, attribute=self + "Value equals target value", target_value=target_value, attribute=self )
5c0ebf7 to
a81baec
Compare
Improve trace logging of attribute set
a81baec to
9b9cd3f
Compare
This fix handles a case for the odin meta writer where it returns None for a String datatype. The problem was that it was correctly using the validated value to set the readback, but the original value to set the setpoint.
This also fixes a potential issue that initially thought was the problem where String.length is None and used to truncate strings in the EPICS CA transport and improves some trace messages that made this issue much easier to figure out. Using
repr(value)in log messages means strings appear as'None'instead ofNone.It was already doing the right thing in the other case here.
Summary by CodeRabbit
Bug Fixes
Improvements
Tests