Throws std::invalid_argument on a URI that is not plain http.
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}