99
1010#include < shogun/lib/config.h>
1111
12- #ifdef HAVE_CURL
13-
1412#include < shogun/base/SGObject.h>
1513#include < shogun/io/SGIO.h>
1614
17- #include < curl/curl.h>
18-
1915#include < memory>
2016#include < numeric>
2117#include < string>
@@ -32,7 +28,9 @@ namespace shogun
3228 {
3329
3430 public:
35- explicit OpenMLReader (const std::string& api_key);
31+ explicit OpenMLReader (const std::string& api_key) : m_api_key(api_key)
32+ {
33+ }
3634
3735 /* *
3836 * Returns a string returned by the server given a request.
@@ -50,7 +48,10 @@ namespace shogun
5048 std::string
5149 get (const std::string& request, const std::string& format, Args... args)
5250 {
51+ #ifdef HAVE_CURL
52+
5353 std::string request_path;
54+ // clear the buffer before request
5455 m_curl_response_buffer.clear ();
5556 auto find_format = m_format_options.find (format);
5657 if (find_format == m_format_options.end ())
@@ -63,8 +64,8 @@ namespace shogun
6364 if (format == " split" )
6465 {
6566 REQUIRE (
66- request == " get_split" ,
67- " Split server can only handle \" get_split\" request.\n " )
67+ request == " get_split" ,
68+ " Split server can only handle \" get_split\" request.\n " )
6869 request_path = get_split;
6970 }
7071 else
@@ -73,8 +74,8 @@ namespace shogun
7374 if (find_request == m_request_options.end ())
7475 {
7576 SG_SERROR (
76- " Could not find a way to solve the request \" %s\"\n " ,
77- request.c_str ())
77+ " Could not find a way to solve the request \" %s\"\n " ,
78+ request.c_str ())
7879 }
7980 request_path = find_request->second ;
8081 }
@@ -110,6 +111,9 @@ namespace shogun
110111 openml_curl_request_helper (url);
111112
112113 return m_curl_response_buffer;
114+ #else
115+ SG_SERROR (" This function is only available witht the CURL library!\n " )
116+ #endif // HAVE_CURL
113117 }
114118
115119 private:
@@ -124,14 +128,6 @@ namespace shogun
124128 */
125129 void openml_curl_request_helper (const std::string& url);
126130
127- /* *
128- * Handles all possible codes
129- *
130- * @param curl_handle curl handle used in the request
131- * @param code the code returned by the query
132- */
133- void openml_curl_error_helper (CURL* curl_handle, CURLcode code);
134-
135131 /* * the user API key, not required for all requests */
136132 std::string m_api_key;
137133
@@ -214,7 +210,8 @@ namespace shogun
214210 const std::string& model, components_type components,
215211 parameters_type parameters)
216212 : m_name(name), m_description(description), m_class_name(model),
217- m_parameters (parameters), m_components(components)
213+ m_parameters (std::move(parameters)),
214+ m_components(std::move(components))
218215 {
219216 }
220217
@@ -247,7 +244,7 @@ namespace shogun
247244 /* *
248245 * Dumps the OpenMLFlow to disk.
249246 */
250- void dump ();
247+ void dump () const ;
251248
252249 /* *
253250 * Gets a subflow, i.e. a kernel in a machine
@@ -266,17 +263,17 @@ namespace shogun
266263 }
267264
268265#ifndef SWIG
269- SG_FORCED_INLINE parameters_type get_parameters ()
266+ SG_FORCED_INLINE parameters_type get_parameters () const noexcept
270267 {
271268 return m_parameters;
272269 }
273270
274- SG_FORCED_INLINE components_type get_components ()
271+ SG_FORCED_INLINE components_type get_components () const noexcept
275272 {
276273 return m_components;
277274 }
278275
279- SG_FORCED_INLINE std::string get_class_name ()
276+ SG_FORCED_INLINE std::string get_class_name () const noexcept
280277 {
281278 return m_class_name;
282279 }
@@ -320,7 +317,6 @@ namespace shogun
320317 param_descriptors,
321318 std::vector<std::unordered_map<std::string, std::string>>
322319 param_qualities)
323-
324320 : m_name(name), m_description(description),
325321 m_data_format (data_format), m_dataset_id(dataset_id),
326322 m_version(version), m_creator(creator),
@@ -441,8 +437,8 @@ namespace shogun
441437 std::shared_ptr<OpenMLData> data)
442438 : m_task_id(task_id), m_task_name(task_name),
443439 m_task_type (task_type), m_task_type_id(task_type_id),
444- m_evaluation_measures(evaluation_measures), m_split(split ),
445- m_data(data)
440+ m_evaluation_measures(std::move( evaluation_measures)),
441+ m_split(std::move(split)), m_data(std::move( data) )
446442 {
447443 }
448444
@@ -459,9 +455,9 @@ namespace shogun
459455 return m_split;
460456 }
461457
462- SGMatrix<int32_t > get_train_indices ();
458+ SGMatrix<int32_t > get_train_indices () const ;
463459
464- SGMatrix<int32_t > get_test_indices ();
460+ SGMatrix<int32_t > get_test_indices () const ;
465461
466462#ifndef SWIG
467463 SG_FORCED_INLINE TaskType get_task_type () const noexcept
@@ -553,9 +549,10 @@ namespace shogun
553549 m_fold_evaluations(std::move(fold_evaluations)),
554550 m_sample_evaluations(std::move(sample_evaluations)),
555551 m_data_content(data_content),
556- m_output_files(std::move(output_files)), m_task(task),
557- m_flow(flow), m_run_id(run_id), m_model(model), m_tags(tags),
558- m_predictions_url(predictions_url)
552+ m_output_files(std::move(output_files)), m_task(std::move(task)),
553+ m_flow(std::move(flow)), m_run_id(run_id),
554+ m_model(std::move(model)), m_tags(std::move(tags)),
555+ m_predictions_url(std::move(predictions_url))
559556 {
560557 }
561558
@@ -591,6 +588,5 @@ namespace shogun
591588 std::string m_predictions_url;
592589 };
593590} // namespace shogun
594- #endif // HAVE_CURL
595591
596592#endif // SHOGUN_OPENMLFLOW_H
0 commit comments