Loading...
Searching...
No Matches
gpr::track::MlflowRestClient Class Reference

#include <gpr/auxiliary/MlflowFileStore.h>

Classes

struct  Response

Public Member Functions

 MlflowRestClient (std::string_view tracking_uri, double timeout_seconds)
 Throws std::invalid_argument on a URI that is not plain http.
Response post (const std::string &path, const std::string &json) const
Response put (const std::string &path, const std::string &body, const std::string &content_type) const
Response get (const std::string &path) const
const std::string & host () const noexcept
int port () const noexcept
const std::string & prefix () const noexcept

Detailed Description

A plain HTTP/1.1 client over a POSIX socket for the MLflow REST API (http://host:port[/prefix]). No TLS: a tracking server on a login node or a tunnel is reached in the clear, which is how mlflow server listens by default.

Definition at line 51 of file MlflowFileStore.h.

Constructor & Destructor Documentation

◆ MlflowRestClient()

gpr::track::MlflowRestClient::MlflowRestClient ( std::string_view tracking_uri,
double timeout_seconds )

Throws std::invalid_argument on a URI that is not plain http.

Definition at line 184 of file MlflowFileStore.cpp.

186 : timeout_seconds_(timeout_seconds)
187{
188 const std::string_view scheme = "http://";
189 if (tracking_uri.substr(0, scheme.size()) != scheme)
190 throw std::invalid_argument(
191 "mlflow tracking uri must be plain http://host:port: " +
192 std::string(tracking_uri));
193 std::string_view rest = tracking_uri.substr(scheme.size());
194 const std::size_t slash = rest.find('/');
195 std::string_view authority = rest.substr(0, slash);
196 if (slash != std::string_view::npos) {
197 prefix_ = std::string(rest.substr(slash));
198 while (!prefix_.empty() && prefix_.back() == '/')
199 prefix_.pop_back();
200 }
201 const std::size_t colon = authority.rfind(':');
202 if (colon != std::string_view::npos) {
203 host_ = std::string(authority.substr(0, colon));
204 port_ = std::atoi(std::string(authority.substr(colon + 1)).c_str());
205 } else {
206 host_ = std::string(authority);
207 }
208 if (host_.empty() || port_ <= 0)
209 throw std::invalid_argument("mlflow tracking uri has no host:port: " +
210 std::string(tracking_uri));
211}

Member Function Documentation

◆ get()

MlflowRestClient::Response gpr::track::MlflowRestClient::get ( const std::string & path) const
nodiscard

Definition at line 226 of file MlflowFileStore.cpp.

227{
228 return request("GET", path, "", "");
229}

◆ host()

const std::string & gpr::track::MlflowRestClient::host ( ) const
inlinenodiscardnoexcept

Definition at line 64 of file MlflowFileStore.h.

65 {
66 return host_;
67 }

◆ port()

int gpr::track::MlflowRestClient::port ( ) const
inlinenodiscardnoexcept

Definition at line 68 of file MlflowFileStore.h.

69 {
70 return port_;
71 }

◆ post()

MlflowRestClient::Response gpr::track::MlflowRestClient::post ( const std::string & path,
const std::string & json ) const
nodiscard

Definition at line 213 of file MlflowFileStore.cpp.

215{
216 return request("POST", path, json, "application/json");
217}

◆ prefix()

const std::string & gpr::track::MlflowRestClient::prefix ( ) const
inlinenodiscardnoexcept

Definition at line 72 of file MlflowFileStore.h.

73 {
74 return prefix_;
75 }

◆ put()

MlflowRestClient::Response gpr::track::MlflowRestClient::put ( const std::string & path,
const std::string & body,
const std::string & content_type ) const
nodiscard

Definition at line 219 of file MlflowFileStore.cpp.

222{
223 return request("PUT", path, body, content_type);
224}

The documentation for this class was generated from the following files: