-
Notifications
You must be signed in to change notification settings - Fork 38
Fix startup json for 9320 #206
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
…ons, improving state management and initialization logic. Update JSON configuration to reflect type changes for containers and plates.
Reviewer's GuideRefactors PRCXI9300 labware classes (Container, Plate, TipRack, TubeRack) to better handle JSON-deserialized ordering data and state serialization, and updates the 9320 startup test JSON to use the new types and layouts. Sequence diagram for JSON-based initialization of PRCXI9300Plate orderingsequenceDiagram
participant JsonConfig
participant LabwareFactory
participant PRCXI9300Plate
participant Plate
JsonConfig->>LabwareFactory: create_labware(type, definition)
LabwareFactory->>PRCXI9300Plate: __init__(name, size_x, size_y, size_z, category, ordering, ordered_items, model, material_info, kwargs)
alt ordered_items is not None
PRCXI9300Plate->>Plate: __init__(..., ordered_items=ordered_items, category, model, kwargs)
else ordering is not None and values are strings
PRCXI9300Plate->>PRCXI9300Plate: build ordering_param from ordering keys
PRCXI9300Plate->>Plate: __init__(..., ordering=ordering_param, category, model, kwargs)
else ordering is not None and values are objects
PRCXI9300Plate->>Plate: __init__(..., ordered_items=ordering, category, model, kwargs)
else no ordering data
PRCXI9300Plate->>Plate: __init__(..., category, model, kwargs)
end
Updated class diagram for PRCXI9300 labware typesclassDiagram
class Deck
class Plate
class TipRack
class TubeRack
class PRCXI9300Deck {
+slots: list
+__init__(name: str, size_x: float, size_y: float, size_z: float, kwargs)
}
PRCXI9300Deck --|> Deck
class PRCXI9300Container {
-_unilabos_state: Dict~str, Any~
+__init__(name: str, size_x: float, size_y: float, size_z: float, category: str, ordering: OrderedDict~str, Any~, model: str, kwargs)
+load_state(state: Dict~str, Any~) void
+serialize_state() Dict~str, Dict~str, Any~~
}
PRCXI9300Container --|> Plate
class PRCXI9300Plate {
-_unilabos_state: Dict~str, Any~
+__init__(name: str, size_x: float, size_y: float, size_z: float, category: str, ordering: OrderedDict~str, Any~, ordered_items: OrderedDict~str, Any~, model: str, material_info: Dict~str, Any~, kwargs)
+load_state(state: Dict~str, Any~) void
+serialize_state() Dict~str, Dict~str, Any~~
}
PRCXI9300Plate --|> Plate
class PRCXI9300TipRack {
-_unilabos_state: Dict~str, Any~
+__init__(name: str, size_x: float, size_y: float, size_z: float, category: str, ordering: OrderedDict~str, Any~, ordered_items: OrderedDict~str, Any~, model: str, material_info: Dict~str, Any~, kwargs)
+load_state(state: Dict~str, Any~) void
+serialize_state() Dict~str, Dict~str, Any~~
}
PRCXI9300TipRack --|> TipRack
class PRCXI9300TubeRack {
-_unilabos_state: Dict~str, Any~
+__init__(name: str, size_x: float, size_y: float, size_z: float, category: str, items: Dict~str, Any~, ordered_items: OrderedDict~str, Any~, ordering: OrderedDict~str, Any~, model: str, material_info: Dict~str, Any~, kwargs)
+load_state(state: Dict~str, Any~) void
+serialize_state() Dict~str, Dict~str, Any~~
}
PRCXI9300TubeRack --|> TubeRack
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey - I've found 1 issue, and left some high level feedback:
- The ordering/ordered_items normalization logic in PRCXI9300Plate, PRCXI9300TipRack, and unilabosTubeRack is nearly identical; consider extracting a small helper to reduce duplication and keep future changes to this behavior consistent across labware types.
- In PRCXI9300Container.serialize_state you unconditionally
updatethe Plate state with_unilabos_state; if both contain the same keys this will silently overwrite Plate-managed data, so it may be safer to either namespace custom keys or explicitly resolve conflicts. - The inline comment
# 其他顶层属性也进行类型检查appears after thereturn datain PRCXI9300Plate.serialize_state, making it unreachable and slightly misleading—moving this comment above the return or adjusting the logic would improve readability.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The ordering/ordered_items normalization logic in PRCXI9300Plate, PRCXI9300TipRack, and unilabosTubeRack is nearly identical; consider extracting a small helper to reduce duplication and keep future changes to this behavior consistent across labware types.
- In PRCXI9300Container.serialize_state you unconditionally `update` the Plate state with `_unilabos_state`; if both contain the same keys this will silently overwrite Plate-managed data, so it may be safer to either namespace custom keys or explicitly resolve conflicts.
- The inline comment `# 其他顶层属性也进行类型检查` appears after the `return data` in PRCXI9300Plate.serialize_state, making it unreachable and slightly misleading—moving this comment above the return or adjusting the logic would improve readability.
## Individual Comments
### Comment 1
<location> `unilabos/devices/liquid_handling/prcxi/prcxi.py:189` </location>
<code_context>
data.update(safe_state)
- return data
-
+ return data # 其他顶层属性也进行类型检查
class PRCXI9300TipRack(TipRack):
""" 专用吸头盒类 """
</code_context>
<issue_to_address>
**nitpick:** Inline comment after `return` is misleading given the current implementation.
The `# 其他顶层属性也进行类型检查` comment implies more top-level type checks than are actually performed (only `_unilabos_state` is filtered before return). Consider either removing/rewording this comment to match the behavior, or adding the missing checks if they’re required.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| data.update(safe_state) | ||
| return data | ||
|
|
||
| return data # 其他顶层属性也进行类型检查 |
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.
nitpick: Inline comment after return is misleading given the current implementation.
The # 其他顶层属性也进行类型检查 comment implies more top-level type checks than are actually performed (only _unilabos_state is filtered before return). Consider either removing/rewording this comment to match the behavior, or adding the missing checks if they’re required.
Enhance PRCXI9300 classes with new Container and TipRack implementations, improving state management and initialization logic. Update JSON configuration to reflect type changes for containers and plates.
Summary by Sourcery
Refine PRCXI 9300 labware handling to better support JSON-driven initialization and state persistence for containers, plates, tip racks, and tube racks.
New Features:
Enhancements:
Tests: