Exemple #1
0
def _migrate_container(container_name):
    print('migrating {} from json to database'.format(container_name))
    container = get_persisted_container(container_name)
    container = rotate_container_for_alpha(container)
    print("CONTAINER: {}, {}".format(container_name, container._coordinates))

    database.save_new_container(container, container_name)
Exemple #2
0
def _setup_container(container_name):
    try:
        container = database.load_container(container_name)

    # Database.load_container throws ValueError when a container name is not
    # found.
    except ValueError:
        # First must populate "get persisted container" list
        old_container_loading.load_all_containers_from_disk()
        # Load container from old json file
        container = old_container_loading.get_persisted_container(
            container_name)
        # Rotate coordinates to fit the new deck map
        rotated_container = database_migration.rotate_container_for_alpha(
            container)
        # Save to the new database
        database.save_new_container(rotated_container, container_name)

    container.properties['type'] = container_name
    container_x, container_y, container_z = container._coordinates

    if not fflags.split_labware_definitions():
        # infer z from height
        if container_z == 0 and 'height' in container[0].properties:
            container_z = container[0].properties['height']

    from opentrons.util.vector import Vector
    container._coordinates = Vector(container_x, container_y, container_z)

    return container
Exemple #3
0
        def test_load_all_containers(self):
            old_container_loading.load_all_containers_from_disk()
            old_container_loading.get_persisted_container("24-vial-rack")
            old_container_loading.get_persisted_container("container-1")
            old_container_loading.get_persisted_container("container-2")

            # Skip container-3 is defined in .secret/containers-3.json.
            with self.assertRaisesRegexp(
                    ValueError,
                    'Container type "container-3" not found in files: .*'):
                old_container_loading.get_persisted_container("container-3")

            # Skip container-4 is defined in .containers-4.json.
            with self.assertRaisesRegexp(
                    ValueError,
                    'Container type "container-4" not found in files: .*'):
                old_container_loading.get_persisted_container("container-4")
Exemple #4
0
def test_load_all_containers(old_container_data):
    old_container_loading.load_all_containers_from_disk()
    old_container_loading.get_persisted_container("24-vial-rack")
    print("Old container data: {} infer: {}".format(old_container_data,
                                                    infer_config_base_dir()))
    old_container_loading.get_persisted_container("container-1")
    old_container_loading.get_persisted_container("container-2")

    # Skip container-3 is defined in .secret/containers-3.json.
    with pytest.raises(
            ValueError,
            match='Container type "container-3" not found in files: .*'):
        old_container_loading.get_persisted_container("container-3")

    # Skip container-4 is defined in .containers-4.json.
    with pytest.raises(
            ValueError,
            match='Container type "container-4" not found in files: .*'):
        old_container_loading.get_persisted_container("container-4")
Exemple #5
0
def _load_weird_container(container_name):
    """ Load a container from persisted containers, whatever that is """
    # First must populate "get persisted container" list
    old_container_loading.load_all_containers_from_disk()
    # Load container from old json file
    container = old_container_loading.get_persisted_container(container_name)
    # Rotate coordinates to fit the new deck map
    rotated_container = database_migration.rotate_container_for_alpha(
        container)
    # Save to the new database
    database.save_new_container(rotated_container, container_name)
    return container
Exemple #6
0
def test_load_persisted_container(old_container_data):
    plate = old_container_loading.get_persisted_container(
        "24-vial-rack")
    assert isinstance(plate, Container)

    wells = [well for well in plate]
    assert all([isinstance(i, Well) for i in wells])

    well_1 = wells[0]
    well_2 = wells[1]

    assert well_1.coordinates() == (5.86 + 0, 8.19 + 0, 0)
    assert well_2.coordinates() == (5.86 + 0, 8.19 + 19.3, 0)
Exemple #7
0
        def test_load_persisted_container(self):
            plate = old_container_loading.get_persisted_container(
                "24-vial-rack")
            self.assertIsInstance(plate, Container)

            self.assertIsInstance(plate, Container)

            wells = [well for well in plate]
            self.assertTrue(all([isinstance(i, Well) for i in wells]))

            well_1 = wells[0]
            well_2 = wells[1]

            self.assertEqual(well_1.coordinates(), (5.86 + 0, 8.19 + 0, 0))
            self.assertEqual(well_2.coordinates(), (5.86 + 0, 8.19 + 19.3, 0))
Exemple #8
0
def migrate_containers_and_wells():
    print("Loading json containers...")
    load_all_containers_from_disk()
    print("Json container file load complete.")
    print("Starting migration...")
    for container_name in list_container_names():
        print('migrating {} from json to database'.format(container_name))
        container = get_persisted_container(container_name)

        container = rotate_container_for_alpha(container)
        print("CONTAINER: {}, {}".format(container_name,
                                         container._coordinates))

        database.save_new_container(container, container_name)
    print("Database migration complete!")