Exemple #1
0
def test_non_json_ok_response():
    with mock.patch("requests.Session.request") as request_mock:
        host_only = MlflowHostCreds("http://my-host")
        response_mock = mock.MagicMock()
        response_mock.status_code = 200
        response_mock.text = "<html></html>"
        request_mock.return_value = response_mock

        response_proto = GetRun.Response()
        with pytest.raises(
                MlflowException,
                match=
                "API request to endpoint was successful but the response body was not "
                "in a valid JSON format",
        ):
            call_endpoint(host_only, "/api/2.0/fetch-model", "GET", "",
                          response_proto)
Exemple #2
0
 def _call_endpoint(self, api, json_body, call_all_endpoints=False):
     response_proto = api.Response()
     if call_all_endpoints:
         endpoints = _METHOD_TO_ALL_INFO[api]
         return call_endpoints(self.get_host_creds(), endpoints, json_body,
                               response_proto)
     else:
         endpoint, method = _METHOD_TO_INFO[api]
         return call_endpoint(self.get_host_creds(), endpoint, method,
                              json_body, response_proto)
Exemple #3
0
 def _call_endpoint(self, api, json_body):
     endpoint, method = _METHOD_TO_INFO[api]
     response_proto = api.Response()
     return call_endpoint(self.get_host_creds(), endpoint, method, json_body, response_proto)
 def _call_endpoint(self, service, api, json_body):
     db_creds = get_databricks_host_creds(self.databricks_profile_uri)
     endpoint, method = _SERVICE_AND_METHOD_TO_INFO[service][api]
     response_proto = api.Response()
     return call_endpoint(db_creds, endpoint, method, json_body, response_proto)
Exemple #5
0
 def _call_endpoint(self, service, api, json_body):
     db_profile = get_db_profile_from_uri(mlflow.tracking.get_tracking_uri())
     db_creds = get_databricks_host_creds(db_profile)
     endpoint, method = _SERVICE_AND_METHOD_TO_INFO[service][api]
     response_proto = api.Response()
     return call_endpoint(db_creds, endpoint, method, json_body, response_proto)