def test_log_batch_invalid_run_id(mocker): mock_client = mocker.Mock() mocker.patch("faculty.client", return_value=mock_client) store = FacultyRestStore(STORE_URI) with pytest.raises(ValueError): store.log_batch("invalid-run-id")
def test_log_batch_empty(mocker): mock_client = mocker.Mock() mocker.patch("faculty.client", return_value=mock_client) store = FacultyRestStore(STORE_URI) 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_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_log_batch_param_conflict(mocker): mock_client = mocker.Mock() exception = faculty.clients.experiment.ParamConflict( message="message", conflicting_params=["param-key"] ) 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="param-key"): 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_log_batch(mocker): mock_client = mocker.Mock() mocker.patch("faculty.client", return_value=mock_client) mlflow_metric = mocker.Mock() metric_converter_mock = mocker.patch( "mlflow_faculty.tracking.mlflow_metric_to_faculty_metric", return_value=mlflow_metric, ) mlflow_param = mocker.Mock() param_converter_mock = mocker.patch( "mlflow_faculty.tracking.mlflow_param_to_faculty_param", return_value=mlflow_param, ) mlflow_tag = mocker.Mock() tag_converter_mock = mocker.patch( "mlflow_faculty.tracking.mlflow_tag_to_faculty_tag", return_value=mlflow_tag, ) store = FacultyRestStore(STORE_URI) store.log_batch( run_id=RUN_UUID_HEX_STR, metrics=[MLFLOW_METRIC], params=[MLFLOW_PARAM], tags=[MLFLOW_TAG], ) mock_client.log_run_data.assert_called_once_with( PROJECT_ID, RUN_UUID, metrics=[mlflow_metric], params=[mlflow_param], tags=[mlflow_tag], ) metric_converter_mock.assert_called_once_with(MLFLOW_METRIC) param_converter_mock.assert_called_once_with(MLFLOW_PARAM) tag_converter_mock.assert_called_once_with(MLFLOW_TAG)