예제 #1
0
def test_add_index_file(labware_name, labware_offset_tempdir):
    deck = Deck()
    parent = deck.position_for(1)
    definition = labware.get_labware_definition(labware_name)
    lw = labware.Labware(definition, parent)
    labware_hash = helpers.hash_labware_def(definition)
    labware.save_calibration(lw, Point(0, 0, 0))

    lw_uri = helpers.uri_from_definition(definition)

    str_parent = labware._get_parent_identifier(lw)
    slot = '1'
    if str_parent:
        mod_dict = {str_parent: f'{slot}-{str_parent}'}
    else:
        mod_dict = {}
    full_id = f'{labware_hash}{str_parent}'
    blob = {
            "uri": f'{lw_uri}',
            "slot": full_id,
            "module": mod_dict
        }

    lw_path = labware_offset_tempdir / 'index.json'
    info = file_operators.read_cal_file(lw_path)
    assert info['data'][full_id] == blob
예제 #2
0
async def test_save_pipette_calibration(mock_user_flow):
    uf = mock_user_flow

    def mock_save_pipette_offset(*args, **kwargs):
        pass

    modify.save_pipette_calibration = \
        MagicMock(side_effect=mock_save_pipette_offset)

    uf._current_state = 'savingPointOne'
    await uf._hardware.move_to(
            mount=uf._mount,
            abs_position=Point(x=10, y=10, z=40),
            critical_point=uf._get_critical_point_override()
        )

    await uf.save_offset()
    tiprack_hash = helpers.hash_labware_def(uf._tip_rack._definition)
    offset = uf._cal_ref_point - Point(x=10, y=10, z=40)
    modify.save_pipette_calibration.assert_called_with(
        offset=offset,
        mount=uf._mount,
        pip_id=uf._hw_pipette.pipette_id,
        tiprack_hash=tiprack_hash,
        tiprack_uri=uf._tip_rack.uri
    )
예제 #3
0
 def _save_attitude_matrix(self):
     e = tuplefy_cal_point_dicts(self._expected_points)
     a = tuplefy_cal_point_dicts(self._saved_points)
     tiprack_hash = helpers.hash_labware_def(self._tip_rack._definition)
     pip_id = self._hw_pipette.pipette_id
     assert pip_id
     robot_cal.save_attitude_matrix(expected=e, actual=a, pipette_id=pip_id,
                                    tiprack_hash=tiprack_hash)
예제 #4
0
def testhash_labware_def():
    def1a = {"metadata": {"a": 123}, "importantStuff": [1.1, 0.00003, 1/3]}
    def1aa = {"metadata": {"a": 123}, "importantStuff": [1.1, 0.00003, 1/3]}
    def1b = {"metadata": {"a": "blah"}, "importantStuff": [1.1, 0.00003, 1/3]}
    def2 = {"metadata": {"a": 123}, "importantStuff": [1.1, 0.000033, 1/3]}

    # identity preserved across json serialization+deserialization
    assert helpers.hash_labware_def(def1a) == \
        helpers.hash_labware_def(
            json.loads(json.dumps(def1a, separators=(',', ':'))))
    # 2 instances of same def should match
    assert helpers.hash_labware_def(def1a) == \
        helpers.hash_labware_def(def1aa)
    # metadata ignored
    assert helpers.hash_labware_def(def1a) == helpers.hash_labware_def(def1b)
    # different data should not match
    assert helpers.hash_labware_def(def1a) != helpers.hash_labware_def(def2)
예제 #5
0
 async def save_offset(self):
     cur_pt = await self._get_current_point(critical_point=None)
     if self.current_state == State.joggingToDeck:
         self._z_height_reference = cur_pt.z
     elif self._current_state == State.savingPointOne:
         if self._hw_pipette.config.channels > 1:
             cur_pt = await self._get_current_point(
                 critical_point=CriticalPoint.FRONT_NOZZLE)
         tiprack_hash = helpers.hash_labware_def(self._tip_rack._definition)
         offset = self._cal_ref_point - cur_pt
         modify.save_pipette_calibration(offset=offset,
                                         mount=self._mount,
                                         pip_id=self._hw_pipette.pipette_id,
                                         tiprack_hash=tiprack_hash,
                                         tiprack_uri=self._tip_rack.uri)
예제 #6
0
def load_new_labware_def(definition):
    """ Load a labware definition in the new schema into a placeable
    """
    labware_hash = cal_helpers.hash_labware_def(definition)
    saved_offset = _look_up_offsets(labware_hash, definition)
    container = Container()
    container_name = definition['parameters']['loadName']
    log.info(f"Container name {container_name}, hash {labware_hash}")
    container.properties['labware_hash'] = labware_hash
    container.properties['definition'] = definition
    container.properties['type'] = container_name
    lw_quirks = definition['parameters'].get('quirks', [])
    if definition['parameters']['isMagneticModuleCompatible']:
        engage_height = definition['parameters']['magneticModuleEngageHeight']
    else:
        engage_height = None
    container.properties['magdeck_engage_height'] = engage_height

    container._coordinates = Vector(definition['cornerOffsetFromSlot'])
    for well_name in itertools.chain(*definition['ordering']):
        well_obj, well_pos = _load_new_well(definition['wells'][well_name],
                                            saved_offset, lw_quirks)
        container.add(well_obj, well_name, well_pos)
    return container
예제 #7
0
def get_labware_hash_with_parent(labware: 'Labware') -> str:
    return helpers.hash_labware_def(labware._definition)\
        + _get_parent_identifier(labware)
예제 #8
0
def get_labware_hash(labware: 'Labware') -> str:
    return helpers.hash_labware_def(labware._definition)