def test_restore_run_client_error(mocker): mock_client = mocker.Mock() mock_client.restore_runs.side_effect = HttpError(mocker.Mock(), "An error") mocker.patch("faculty.client", return_value=mock_client) store = FacultyRestStore(STORE_URI) with pytest.raises(MlflowException, match="An error"): store.restore_run(RUN_UUID_HEX_STR)
def test_rename_experiment_client_error(mocker): mock_client = mocker.Mock() mock_client.update.side_effect = HttpError(mocker.Mock(), "Error") mocker.patch("faculty.client", return_value=mock_client) store = FacultyRestStore(STORE_URI) with pytest.raises(MlflowException, match="Error"): store.rename_experiment(EXPERIMENT_ID, "new name")
def test_list_experiments_client_error(mocker): mock_client = mocker.Mock() mock_client.list.side_effect = HttpError(mocker.Mock(), "Error") mocker.patch("faculty.client", return_value=mock_client) store = FacultyRestStore(STORE_URI) with pytest.raises(MlflowException, match="Error"): store.list_experiments()
def test_create_experiment_client_error(mocker): mock_client = mocker.Mock() mock_client.create.side_effect = HttpError(mocker.Mock(), "Error") mocker.patch("faculty.client", return_value=mock_client) store = FacultyRestStore(STORE_URI) with pytest.raises(MlflowException, match="Error"): store.create_experiment(NAME, ARTIFACT_LOCATION)
def test_get_metric_history_client_error(mocker): mock_client = mocker.Mock() mock_client.get_metric_history.side_effect = HttpError( mocker.Mock(), "Dummy client error.") mocker.patch("faculty.client", return_value=mock_client) store = FacultyRestStore(STORE_URI) with pytest.raises(MlflowException, match="Dummy client error."): store.get_metric_history(RUN_UUID_HEX_STR, "metric-key")
def test_get_experiment_client_error(mocker): mock_client = mocker.Mock() mock_client.get.side_effect = HttpError( mocker.Mock(), "Experiment with ID _ not found in project _") mocker.patch("faculty.client", return_value=mock_client) store = FacultyRestStore(STORE_URI) with pytest.raises(MlflowException, match="Experiment with ID _ not found in project _"): store.get_experiment(EXPERIMENT_ID)
def test_get_run_client_error(mocker): mock_client = mocker.Mock() mock_client.get_run.side_effect = HttpError( mocker.Mock(), "Experiment run with ID _ not found in project _") mocker.patch("faculty.client", return_value=mock_client) store = FacultyRestStore(STORE_URI) with pytest.raises( MlflowException, match="Experiment run with ID _ not found in project _", ): store.get_run(RUN_UUID_HEX_STR)
def test_update_run_info_client_error(mocker): mock_client = mocker.Mock() mock_client.update_run_info.side_effect = HttpError( mocker.Mock(), "Experiment run with ID _ not found in project _") mocker.patch("faculty.client", return_value=mock_client) store = FacultyRestStore(STORE_URI) with pytest.raises( MlflowException, match="Experiment run with ID _ not found in project _", ): store.update_run_info(RUN_UUID_HEX_STR, "RUNNING", RUN_ENDED_AT_MILLISECONDS)
def test_log_batch_error(mocker): mock_client = mocker.Mock() exception = HttpError( mocker.Mock(), error="error_message", error_code="some_error_code" ) mock_client.log_run_data.side_effect = exception mocker.patch("faculty.client", return_value=mock_client) store = FacultyRestStore(STORE_URI) with pytest.raises(MlflowException, match="error_message"): store.log_batch(RUN_UUID_HEX_STR) mock_client.log_run_data.assert_called_once_with( PROJECT_ID, RUN_UUID, metrics=[], params=[], tags=[] )
def test_create_run_client_error(mocker): mocker.patch("mlflow_faculty.tracking.mlflow_timestamp_to_datetime") mocker.patch("mlflow_faculty.tracking.mlflow_tag_to_faculty_tag") mock_client = mocker.Mock() mock_client.create_run.side_effect = HttpError(mocker.Mock(), "Some error") mocker.patch("faculty.client", return_value=mock_client) store = FacultyRestStore(STORE_URI) with pytest.raises(MlflowException, match="Some error"): store.create_run( EXPERIMENT_ID, "unused-mlflow-user-id", RUN_STARTED_AT_MILLISECONDS, tags=[], )
def test_search_runs_client_error(mocker): mock_client = mocker.Mock() mock_client.query_runs.side_effect = HttpError(mocker.Mock(), "Dummy client error.") mocker.patch("faculty.client", return_value=mock_client) mocker.patch("mlflow_faculty.tracking.build_search_runs_filter") store = FacultyRestStore(STORE_URI) with pytest.raises(MlflowException, match="Dummy client error."): store._search_runs( [1, 2, 3], filter_string=None, run_view_type=None, max_results=None, order_by=None, page_token=None, )