Exemplo n.º 1
0
def test_delete_runs_no_run_ids(mocker):
    mocker.patch.object(ExperimentClient, "_post")
    schema_mock = mocker.patch(
        "faculty.clients.experiment._DeleteExperimentRunsResponseSchema")

    client = ExperimentClient(mocker.Mock(), mocker.Mock())
    client.delete_runs(PROJECT_ID)

    ExperimentClient._post.assert_called_once_with(
        "/project/{}/run/delete/query".format(PROJECT_ID),
        schema_mock.return_value,
        json={},
    )
Exemplo n.º 2
0
def test_delete_runs(mocker):
    delete_runs_response = mocker.Mock()
    mocker.patch.object(ExperimentClient,
                        "_post",
                        return_value=delete_runs_response)
    response_schema_mock = mocker.patch(
        "faculty.clients.experiment._DeleteExperimentRunsResponseSchema")
    filter_schema_mock = mocker.patch(
        "faculty.clients.experiment._FilterSchema")
    filter_dump_mock = filter_schema_mock.return_value.dump

    run_ids = [uuid4(), uuid4()]

    client = ExperimentClient(mocker.Mock(), mocker.Mock())
    response = client.delete_runs(PROJECT_ID, run_ids)

    assert response == delete_runs_response

    expected_filter = CompoundFilter(
        LogicalOperator.OR,
        [
            RunIdFilter(ComparisonOperator.EQUAL_TO, run_ids[0]),
            RunIdFilter(ComparisonOperator.EQUAL_TO, run_ids[1]),
        ],
    )
    filter_dump_mock.assert_called_once_with(expected_filter)
    ExperimentClient._post.assert_called_once_with(
        "/project/{}/run/delete/query".format(PROJECT_ID),
        response_schema_mock.return_value,
        json={"filter": filter_dump_mock.return_value},
    )
Exemplo n.º 3
0
def test_delete_runs_empty_list(mocker):
    mocker.patch.object(ExperimentClient, "_post")

    client = ExperimentClient(mocker.Mock(), mocker.Mock())
    response = client.delete_runs(PROJECT_ID, run_ids=[])

    ExperimentClient._post.assert_not_called()
    assert len(response.deleted_run_ids) == 0
    assert len(response.conflicted_run_ids) == 0