def _look_up_offsets(labware_hash, definition): calibration_path = CONFIG['labware_calibration_offsets_dir_v2'] labware_offset_path = calibration_path / '{}.json'.format(labware_hash) if labware_offset_path.exists(): return get.get_labware_calibration(labware_offset_path, definition) else: return Point(x=0, y=0, z=0)
def load_from_definition( definition: 'LabwareDefinition', parent: Location, label: str = None, api_level: APIVersion = None) -> Labware: """ Return a labware object constructed from a provided labware definition dict :param definition: A dict representing all required data for a labware, including metadata such as the display name of the labware, a definition of the order to iterate over wells, the shape of wells (shape, physical dimensions, etc), and so on. The correct shape of this definition is governed by the "labware-designer" project in the Opentrons/opentrons repo. :param parent: A :py:class:`.Location` representing the location where the front and left most point of the outside of labware is (often the front-left corner of a slot on the deck). :param str label: An optional label that will override the labware's display name from its definition :param APIVersion api_level: the API version to set for the loaded labware instance. The :py:class:`.Labware` will conform to this level. If not specified, defaults to :py:attr:`.MAX_SUPPORTED_VERSION`. """ labware = Labware(definition, parent, label, api_level) index_info = _get_index_file_information(labware) offset = get.get_labware_calibration( index_info[0], index_info[1], parent=index_info[2]) labware.set_calibration(offset) return labware
def test_load_calibration(monkeypatch, clear_calibration): monkeypatch.setattr(helpers, 'hash_labware_def', mock_hash_labware) test_labware = labware.Labware(minimalLabwareDef, Location(Point(0, 0, 0), 'deck')) test_offset = Point(1, 1, 1) labware.save_calibration(test_labware, test_offset) # Set without saving to show that load will update with previously saved # data test_labware.set_calibration(Point(0, 0, 0)) test_labware.tip_length = 46.8 lookup_path = labware._get_labware_path(test_labware) calibration_point =\ get.get_labware_calibration(lookup_path, test_labware._definition) assert calibration_point == test_offset