Skip to content

Improve Controller Attribute and sub controller creation with __setattr__#235

Merged
GDYendell merged 3 commits intomainfrom
controller-setattr
Oct 22, 2025
Merged

Improve Controller Attribute and sub controller creation with __setattr__#235
GDYendell merged 3 commits intomainfrom
controller-setattr

Conversation

@GDYendell
Copy link
Contributor

@GDYendell GDYendell commented Oct 22, 2025

Breaking Changes

  • register_sub_controller -> add_sub_controller
  • sub controllers with snake_case names will now be converted to PascalCase for use in PVs, as attribute names are. If you are currently calling register_sub_controller with a PascalCase name, you can instead add it as an attribute with a snake_case name and the generated PVs will be the same.

Features

  • new Controller.add_attribute that can be used instead of setattr(self, ...) - direct access to Controller.attributes may be deprecated in a future release
  • sub controllers can be added to a controller by assigning it as an attribute - add_sub_controller can be used directly if adding programmatically or to avoid using a non-snake-case name for an attribute. They will be available via controller.<sub_controller_name> in the interactive shell either way
  • when Attributes are added to a controller, the name used is added to its _name field to use in __repr__ so you can tell what they are in log statements and the debugger

@GDYendell GDYendell requested a review from coretl October 22, 2025 12:29
@GDYendell GDYendell linked an issue Oct 22, 2025 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

❌ Patch coverage is 96.22642% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.18%. Comparing base (dcd7b5e) to head (46deaa7).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/fastcs/attributes.py 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #235      +/-   ##
==========================================
+ Coverage   90.15%   90.18%   +0.02%     
==========================================
  Files          44       45       +1     
  Lines        2256     2273      +17     
==========================================
+ Hits         2034     2050      +16     
- Misses        222      223       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@GDYendell GDYendell force-pushed the controller-setattr branch 2 times, most recently from dfc9be9 to 1b23440 Compare October 22, 2025 13:05
Copy link
Contributor

@coretl coretl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a skim this looks fine

@GDYendell GDYendell merged commit 019ae15 into main Oct 22, 2025
12 checks passed
@GDYendell GDYendell deleted the controller-setattr branch October 22, 2025 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement __get_item__ on Controller to access sub controllers

2 participants