add UserActions for bulk UserUpdateNodesAttrs#190
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #190 +/- ##
==========================================
+ Coverage 91.07% 91.11% +0.04%
==========================================
Files 59 60 +1
Lines 2923 2948 +25
==========================================
+ Hits 2662 2686 +24
- Misses 261 262 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| nodes: The node ids to update. | ||
| attrs: A mapping from attribute name to new attribute values, | ||
| applied to all nodes. | ||
| attrs: Either a single dict applied to all nodes, or a list of dicts |
There was a problem hiding this comment.
Is this the API you want? Or, would it be better to have dict[str, list[values]] - one dictionary, one entry per attribute, with lists of values to cover all the nodes? In general, I'm open to having bulk BasicActions as well as the current singular ones, it seems like the User doing bulk things is happening more often than I thought
There was a problem hiding this comment.
In general, I like that approach a lot! However, I can see problems distinguishing whether a list within the dict represents an array attribute or a series of single-value attributes ({"pos": [1, 2, 3]}), especially when the number of nodes equals the number of dimensions in pos. Any suggestion?
There was a problem hiding this comment.
I would not allow the single-value entries for this one? Since we have the singular UserAction right? But that's a good point if we want to allow both. Plus, the dictionary approach allows updating different attributes per node, which is more flexible
| self, | ||
| tracks: SolutionTracks, | ||
| nodes: list[int], | ||
| attrs: dict[str, Any] | list[dict[str, Any]], |
There was a problem hiding this comment.
| attrs: dict[str, Any] | list[dict[str, Any]], | |
| attrs: dict[str, list[Any]], |
if you have one element explicitly, call singular version
|
@cmalinmayor, I implemented what we discussed, ready to merge! 😊 |
The group actions make heavy use of the
UserUpdateNodeAttractions. They loop over all nodes and apply the update user actions one-by-one, including the expensivetracks.refresh.This PR makes a "bulk" version of this UserAction, to make that process faster.
(I needed this for the v2-branch, but as the functions are near-idential to main, might just as well change it on main, and pull into v2 😅)