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,9 @@ namespace shogun
5048 std::string
5149 get (const std::string& request, const std::string& format, Args... args)
5250 {
51+ #ifdef HAVE_CURL
5352 std::string request_path;
53+ // clear the buffer before request
5454 m_curl_response_buffer.clear ();
5555 auto find_format = m_format_options.find (format);
5656 if (find_format == m_format_options.end ())
@@ -63,8 +63,8 @@ namespace shogun
6363 if (format == " split" )
6464 {
6565 REQUIRE (
66- request == " get_split" ,
67- " Split server can only handle \" get_split\" request.\n " )
66+ request == " get_split" ,
67+ " Split server can only handle \" get_split\" request.\n " )
6868 request_path = get_split;
6969 }
7070 else
@@ -73,8 +73,8 @@ namespace shogun
7373 if (find_request == m_request_options.end ())
7474 {
7575 SG_SERROR (
76- " Could not find a way to solve the request \" %s\"\n " ,
77- request.c_str ())
76+ " Could not find a way to solve the request \" %s\"\n " ,
77+ request.c_str ())
7878 }
7979 request_path = find_request->second ;
8080 }
@@ -110,6 +110,9 @@ namespace shogun
110110 openml_curl_request_helper (url);
111111
112112 return m_curl_response_buffer;
113+ #else
114+ SG_SERROR (" This function is only available witht the CURL library!\n " )
115+ #endif // HAVE_CURL
113116 }
114117
115118 private:
@@ -124,14 +127,6 @@ namespace shogun
124127 */
125128 void openml_curl_request_helper (const std::string& url);
126129
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-
135130 /* * the user API key, not required for all requests */
136131 std::string m_api_key;
137132
@@ -214,7 +209,8 @@ namespace shogun
214209 const std::string& model, components_type components,
215210 parameters_type parameters)
216211 : m_name(name), m_description(description), m_class_name(model),
217- m_parameters (parameters), m_components(components)
212+ m_parameters (std::move(parameters)),
213+ m_components(std::move(components))
218214 {
219215 }
220216
@@ -247,7 +243,7 @@ namespace shogun
247243 /* *
248244 * Dumps the OpenMLFlow to disk.
249245 */
250- void dump ();
246+ void dump () const ;
251247
252248 /* *
253249 * Gets a subflow, i.e. a kernel in a machine
@@ -266,17 +262,17 @@ namespace shogun
266262 }
267263
268264#ifndef SWIG
269- SG_FORCED_INLINE parameters_type get_parameters ()
265+ SG_FORCED_INLINE parameters_type get_parameters () const noexcept
270266 {
271267 return m_parameters;
272268 }
273269
274- SG_FORCED_INLINE components_type get_components ()
270+ SG_FORCED_INLINE components_type get_components () const noexcept
275271 {
276272 return m_components;
277273 }
278274
279- SG_FORCED_INLINE std::string get_class_name ()
275+ SG_FORCED_INLINE std::string get_class_name () const noexcept
280276 {
281277 return m_class_name;
282278 }
@@ -320,7 +316,6 @@ namespace shogun
320316 param_descriptors,
321317 std::vector<std::unordered_map<std::string, std::string>>
322318 param_qualities)
323-
324319 : m_name(name), m_description(description),
325320 m_data_format (data_format), m_dataset_id(dataset_id),
326321 m_version(version), m_creator(creator),
@@ -441,8 +436,8 @@ namespace shogun
441436 std::shared_ptr<OpenMLData> data)
442437 : m_task_id(task_id), m_task_name(task_name),
443438 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)
439+ m_evaluation_measures(std::move( evaluation_measures)),
440+ m_split(std::move(split)), m_data(std::move( data) )
446441 {
447442 }
448443
@@ -459,9 +454,9 @@ namespace shogun
459454 return m_split;
460455 }
461456
462- SGMatrix<int32_t > get_train_indices ();
457+ SGMatrix<int32_t > get_train_indices () const ;
463458
464- SGMatrix<int32_t > get_test_indices ();
459+ SGMatrix<int32_t > get_test_indices () const ;
465460
466461#ifndef SWIG
467462 SG_FORCED_INLINE TaskType get_task_type () const noexcept
@@ -553,9 +548,10 @@ namespace shogun
553548 m_fold_evaluations(std::move(fold_evaluations)),
554549 m_sample_evaluations(std::move(sample_evaluations)),
555550 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)
551+ m_output_files(std::move(output_files)), m_task(std::move(task)),
552+ m_flow(std::move(flow)), m_run_id(run_id),
553+ m_model(std::move(model)), m_tags(std::move(tags)),
554+ m_predictions_url(std::move(predictions_url))
559555 {
560556 }
561557
@@ -591,6 +587,5 @@ namespace shogun
591587 std::string m_predictions_url;
592588 };
593589} // namespace shogun
594- #endif // HAVE_CURL
595590
596591#endif // SHOGUN_OPENMLFLOW_H
0 commit comments