def test_session_request(server_setup, get_interface_params):
    """
    Test session request.

    Args:
        server_setup (tuple): Tuple containing url and result directory
        get_interface_params (tuple): Tuple to configure par interface

    Return:
        None
    """
    from sail_on_client.protocol.parinterface import ParInterface

    url, result_dir = server_setup
    config_directory, config_name = get_interface_params
    par_interface = ParInterface(config_name, config_directory)
    test_id_path = os.path.join(os.path.dirname(__file__), "data", "OND",
                                "image_classification", "test_ids.csv")
    test_ids = list(map(str.strip, open(test_id_path, "r").readlines()))
    # Testing if session was sucessfully initalized
    par_interface.session_request(test_ids, "OND", "image_classification",
                                  "0.1.1", [])
    # Testing with hints
    par_interface.session_request(test_ids, "OND", "image_classification",
                                  "0.1.1", ["red_light"])
Example #2
0
def test_resume_session(server_setup, get_interface_params):
    """
    Test resume session.

    Args:
        server_setup (tuple): Tuple containing url and result directory
        get_interface_params (tuple): Tuple to configure par interface

    Return:
        None
    """
    from sail_on_client.protocol.parinterface import ParInterface

    url, result_dir = server_setup
    config_directory, config_name = get_interface_params
    par_interface = ParInterface(config_name, config_directory)
    session_id = par_interface.session_request(["OND.54011215.0000.1236"],
                                               "OND", "image_classification",
                                               "0.1.1", [], 0.5)
    par_interface.complete_test(session_id, "OND.54011215.0000.1236")
    finished_test = par_interface.resume_session(session_id)
    assert finished_test == ["OND.54011215.0000.1236"]
    # Testing with hints
    session_id = par_interface.session_request(
        ["OND.54011215.0000.1236"],
        "OND",
        "image_classification",
        "0.1.1",
        ["red_light"],
        0.4,
    )
    par_interface.complete_test(session_id, "OND.54011215.0000.1236")
    finished_test = par_interface.resume_session(session_id)
    assert finished_test == ["OND.54011215.0000.1236"]