Exemplo n.º 1
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
Exemplo n.º 2
0
def _ensure_containers_and_wells():
    """ Load all persisted containers in to the labware database
    """

    print("Loading json containers...")
    load_all_containers_from_disk()
    json_containers = list_container_names()
    log.debug("_ensure_containers_and_wells: file load complete")
    print("Json container file load complete, listing database")
    current_containers = database.list_all_containers()
    to_update = set(json_containers) - set(current_containers)
    msg = f"Found {len(to_update)} containers to add. Starting migration..."
    print(msg)
    log.info(msg)
    for container_name in to_update:
        _migrate_container(container_name)
    current_containers = database.list_all_containers()
    missing = set(json_containers) - set(current_containers)
    if missing:
        msg = f"MIGRATION FAILED: MISSING {missing}"
        log.error(msg)
        print(msg)
    else:
        log.info("Database migration complete")
        print("Database migration complete!")
Exemplo n.º 3
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
Exemplo n.º 4
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!")
Exemplo n.º 5
0
def _ensure_trash():
    """ Ensure that the tall and short fixed trash containers are present

    This is a separate step because the robot singleton needs them, so
    they need to be present whenever the singleton is constructed on import.
    The rest of the containers are not necessarily needed, and so are handled
    elsewhere.
    """
    load_all_containers_from_disk()

    to_load = set(['fixed-trash', 'tall-fixed-trash'])
    present = set(database.list_all_containers())
    to_update = to_load - present
    log.info(f"_ensure_trash: loading {to_update}")
    for container_name in to_update:
        _migrate_container(container_name)
Exemplo n.º 6
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")
Exemplo n.º 7
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")