-
Notifications
You must be signed in to change notification settings - Fork 143
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
[RFC] Arches model QuerySets #11595 #11596
base: dev/8.0.x
Are you sure you want to change the base?
Conversation
def find_root_node(prefetched_siblings, nodegroup_id): | ||
for sibling_node in prefetched_siblings: | ||
if sibling_node.pk == nodegroup_id: | ||
return sibling_node |
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.
It just occurred to me could add a column is_root_node
to the Node
model, perhaps as a GeneratedField so that we don't have to run these searches.
arches/app/models/querysets.py
Outdated
if tile_val is not NOT_PROVIDED: | ||
datatype_instance = datatype_factory.get_instance(node.datatype) | ||
python_val = datatype_instance.to_python(tile_val) | ||
setattr(tile, node.alias, python_val) |
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 pretty well hidden (I'll declutter and add some signposting), but here is where I'm attaching the tile value to the tile object by node alias. Similar place in the ResourceInstanceQuerySet.
If we need to "seal" these python values so that we can know when they've been "tampered" with to make computation of saving back a little faster, I'm imagining we can wrap this in some sort of class with custom __setattr__
and __getattr__
methods to set that dirty state.
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.
Er, probably just on the __getattr__
, and treat anything accessed as potentially dirty, because you can directly mutate things without setting something on the python object directly (unless we consider that a feature, that such an update is blocked...)
08b75b1
to
6273b5d
Compare
Types of changes
Description of Change
This first iteration has TODOs enumerated and will need some tests, but this is functional enough to invite some testing and feedback. See #11595 for motivation. I'll update the bottom of this PR with DX questions that come up as I polish.
The basic idea:
annotate()
feature for joining tile data to resource instance queriesTesting instructions
Issues Solved
Closes #11595
Checklist
Ticket Background
Further comments
TODO: flesh out DX questions below