-
Notifications
You must be signed in to change notification settings - Fork 94
ResourceStack, Plate, Lid inheritance logic fix #546
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
base: main
Are you sure you want to change the base?
Changes from all commits
8307b34
5f517a1
5acdc82
0a4eeef
8bb93da
3ead5b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,8 +234,25 @@ def _update_resource_stack_location(self, resource: Resource): | |
Args: | ||
resource: The Resource on the ResourceStack tht was assigned. | ||
""" | ||
resource_stack = resource.parent | ||
assert isinstance(resource_stack, ResourceStack) | ||
|
||
if isinstance(resource, Lid): | ||
lid_parent = resource.parent | ||
if lid_parent is None: | ||
raise ValueError("Lid has no parent. ResourceStack not found for Lid") | ||
if isinstance(lid_parent, ResourceStack): | ||
resource_stack = lid_parent | ||
elif isinstance(lid_parent.parent, ResourceStack): | ||
resource_stack = lid_parent.parent | ||
Comment on lines
+244
to
+245
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in this case, the parent is likely a plate. in that case, the location of the plate wrt the stack should be updated (and the plate should have a callback already registered) - not the lid. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you elaborate a little bit on what should be done with the plate / how the plate should be updated? For some more context, in the original codebase, I ran into an issue with move_lid where moving a lid to a plate on a stack would raise an exception because of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it would be removing this case from the if statement i think the problem with moving a lid to a plate on a stack is with liquid handler (since this callback should not be called in that case. if it is, there's a problem elsewhere) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it! I was also a little confused as to why this callback was called. I tried tracing out the code earlier today to see why but I had some trouble following it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The lid gets properly attached (lh.summary() shows this) with move_lid, but the code won't fully execute because of the assertion line There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. then it seems that this callback is incorrectly called. it should only be called when the first child of the ResourceStack changes |
||
else: | ||
raise ValueError("ResourceStack not found for Lid") | ||
else: | ||
if resource.parent is None: | ||
raise ValueError("ResourceStack not found for resource") | ||
if not isinstance(resource.parent, ResourceStack): | ||
raise TypeError( | ||
f"Resource {resource} is not a child of a ResourceStack, but of {type(resource.parent)}" | ||
) | ||
resource_stack = resource.parent | ||
if resource_stack.children[0] == resource: | ||
resource_stack.location = self.get_default_child_location(resource) | ||
|
||
|
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.
perhaps it makes more sense to make these different cases ((destination = ResourceStack, resource = Lid), (destination = Plate, resource = Lid)) into two 'top level' if statements?
or merge the (destination = ResourceStack, resource = Lid) case into the (destination=ResourceStack) cause above?
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.
Hello, thank you for the suggestions! I noticed before that you left a comment for carrier.py but I can't see it here anymore. I thought the method you outlined there was very clean and a more catch all solution for finding the parent ResourceStack. For the liquid_handler.py, I can look into making the logic more clean via your suggestions above!
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.
i deleted the other comment because I realized i was wrong :)
(i made a comment suggesting to get the resource stack in the "parent-path" until the root. That is wrong because this method specifically exists to update the location of the first resource in the resource stack: if there are resources in between the given resource and the stack, it should probably be the location of the direct child of the resource that determines its location, not some [grand]child.)
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.
Ah got it, that makes sense!