Skip to content

Conversation

@ALITTLELZ
Copy link
Contributor

@ALITTLELZ ALITTLELZ commented Dec 25, 2025

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:

  • Introduce a PRCXI9300Container type for PRCXI 9300 deck slots with custom state serialization.

Enhancements:

  • Improve PRCXI9300Plate, PRCXI9300TipRack, and tube rack constructors to handle both object-based and string-based ordering from JSON while maintaining backward compatibility with existing parameters.
  • Ensure labware state and material metadata are preserved and merged correctly during serialization.

Tests:

  • Update the PRCXI 9320 JSON experiment fixture to align with the new labware configuration and type handling.

…ons, improving state management and initialization logic. Update JSON configuration to reflect type changes for containers and plates.
@sourcery-ai
Copy link

sourcery-ai bot commented Dec 25, 2025

Reviewer's Guide

Refactors 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 ordering

sequenceDiagram
  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
Loading

Updated class diagram for PRCXI9300 labware types

classDiagram

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
Loading

File-Level Changes

Change Details Files
Add PRCXI9300Container class with custom state handling for generic containers/slots.
  • Introduce PRCXI9300Container subclassing Plate with constructor mirroring Plate’s geometry and ordering parameters.
  • Track additional _unilabos_state alongside base Plate state.
  • Override load_state to store the raw state dict after delegating to Plate.
  • Override serialize_state to merge Plate-serialized data with stored _unilabos_state.
unilabos/devices/liquid_handling/prcxi/prcxi.py
Make PRCXI9300Plate robust to JSON-derived ordering data and missing ordered_items.
  • Replace simple ordered_items-or-ordering selection with branching that inspects ordering value types.
  • When ordering values are strings (from JSON), generate an ordering OrderedDict with keys only and pass it as ordering so Plate constructs Well objects.
  • When ordering already contains objects, pass it as ordered_items.
  • Fall back to calling base Plate with no ordered_items/ordering when neither is supplied.
  • Keep existing _unilabos_state handling and safe serialization of nested state.
unilabos/devices/liquid_handling/prcxi/prcxi.py
Align PRCXI9300TipRack construction with JSON-derived ordering semantics similar to Plate.
  • Change constructor to branch on ordered_items, ordering, or neither, inspecting ordering values for string-vs-object distinction.
  • For string-valued ordering (from JSON), build a keys-only OrderedDict and pass it as ordering so TipRack builds Tip objects.
  • For object-valued ordering or explicit ordered_items, pass them as ordered_items to the base TipRack.
  • Retain _unilabos_state and material_info handling and state serialization behavior.
unilabos/devices/liquid_handling/prcxi/prcxi.py
Update PRCXI9300TubeRack initialization to support ordering and JSON-derived layouts while remaining backward compatible with items/ordered_items.
  • Extend TubeRack constructor signature with an ordering parameter in addition to items and ordered_items.
  • If ordered_items is provided, pass it straight through as ordered_items to the base TubeRack.
  • If ordering is provided, inspect value types; for string-valued ordering, construct a keys-only OrderedDict and pass it as ordering, otherwise treat it as ordered_items.
  • Maintain compatibility with legacy items parameter when used.
  • Fall back to calling base TubeRack without ordered_items/ordering when nothing is provided, preserving existing _unilabos_state logic.
unilabos/devices/liquid_handling/prcxi/prcxi.py
Adjust 9320 experiment/startup JSON to match new PRCXI9300 labware types and ordering representation.
  • Update labware type names to use PRCXI9300Container/PRCXI9300Plate/PRCXI9300TipRack/PRCXI9300TubeRack as appropriate.
  • Ensure container, plate, and rack ordering sections use string-valued slot/well IDs compatible with the new constructors’ JSON handling.
  • Align any material/state sections with the new _unilabos_state expectations for serialization and reloading.
unilabos/test/experiments/prcxi_9320_with_res_test.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a 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 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.
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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
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 # 其他顶层属性也进行类型检查
Copy link

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.

@q434343 q434343 merged commit 546fb63 into deepmodeling:prcix9320 Dec 25, 2025
1 check passed
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.

2 participants