9
9
10
10
#include < shogun/lib/config.h>
11
11
12
- #ifdef HAVE_CURL
13
-
14
12
#include < shogun/base/SGObject.h>
15
13
#include < shogun/io/SGIO.h>
16
14
17
- #include < curl/curl.h>
18
-
19
15
#include < memory>
20
16
#include < numeric>
21
17
#include < string>
@@ -32,7 +28,9 @@ namespace shogun
32
28
{
33
29
34
30
public:
35
- explicit OpenMLReader (const std::string& api_key);
31
+ explicit OpenMLReader (const std::string& api_key) : m_api_key(api_key)
32
+ {
33
+ }
36
34
37
35
/* *
38
36
* Returns a string returned by the server given a request.
@@ -50,7 +48,10 @@ namespace shogun
50
48
std::string
51
49
get (const std::string& request, const std::string& format, Args... args)
52
50
{
51
+ #ifdef HAVE_CURL
52
+
53
53
std::string request_path;
54
+ // clear the buffer before request
54
55
m_curl_response_buffer.clear ();
55
56
auto find_format = m_format_options.find (format);
56
57
if (find_format == m_format_options.end ())
@@ -63,8 +64,8 @@ namespace shogun
63
64
if (format == " split" )
64
65
{
65
66
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 " )
68
69
request_path = get_split;
69
70
}
70
71
else
@@ -73,8 +74,8 @@ namespace shogun
73
74
if (find_request == m_request_options.end ())
74
75
{
75
76
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 ())
78
79
}
79
80
request_path = find_request->second ;
80
81
}
@@ -110,6 +111,9 @@ namespace shogun
110
111
openml_curl_request_helper (url);
111
112
112
113
return m_curl_response_buffer;
114
+ #else
115
+ SG_SERROR (" This function is only available witht the CURL library!\n " )
116
+ #endif // HAVE_CURL
113
117
}
114
118
115
119
private:
@@ -124,14 +128,6 @@ namespace shogun
124
128
*/
125
129
void openml_curl_request_helper (const std::string& url);
126
130
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
-
135
131
/* * the user API key, not required for all requests */
136
132
std::string m_api_key;
137
133
@@ -214,7 +210,8 @@ namespace shogun
214
210
const std::string& model, components_type components,
215
211
parameters_type parameters)
216
212
: 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))
218
215
{
219
216
}
220
217
@@ -247,7 +244,7 @@ namespace shogun
247
244
/* *
248
245
* Dumps the OpenMLFlow to disk.
249
246
*/
250
- void dump ();
247
+ void dump () const ;
251
248
252
249
/* *
253
250
* Gets a subflow, i.e. a kernel in a machine
@@ -266,17 +263,17 @@ namespace shogun
266
263
}
267
264
268
265
#ifndef SWIG
269
- SG_FORCED_INLINE parameters_type get_parameters ()
266
+ SG_FORCED_INLINE parameters_type get_parameters () const noexcept
270
267
{
271
268
return m_parameters;
272
269
}
273
270
274
- SG_FORCED_INLINE components_type get_components ()
271
+ SG_FORCED_INLINE components_type get_components () const noexcept
275
272
{
276
273
return m_components;
277
274
}
278
275
279
- SG_FORCED_INLINE std::string get_class_name ()
276
+ SG_FORCED_INLINE std::string get_class_name () const noexcept
280
277
{
281
278
return m_class_name;
282
279
}
@@ -320,7 +317,6 @@ namespace shogun
320
317
param_descriptors,
321
318
std::vector<std::unordered_map<std::string, std::string>>
322
319
param_qualities)
323
-
324
320
: m_name(name), m_description(description),
325
321
m_data_format (data_format), m_dataset_id(dataset_id),
326
322
m_version(version), m_creator(creator),
@@ -441,8 +437,8 @@ namespace shogun
441
437
std::shared_ptr<OpenMLData> data)
442
438
: m_task_id(task_id), m_task_name(task_name),
443
439
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) )
446
442
{
447
443
}
448
444
@@ -459,9 +455,9 @@ namespace shogun
459
455
return m_split;
460
456
}
461
457
462
- SGMatrix<int32_t > get_train_indices ();
458
+ SGMatrix<int32_t > get_train_indices () const ;
463
459
464
- SGMatrix<int32_t > get_test_indices ();
460
+ SGMatrix<int32_t > get_test_indices () const ;
465
461
466
462
#ifndef SWIG
467
463
SG_FORCED_INLINE TaskType get_task_type () const noexcept
@@ -553,9 +549,10 @@ namespace shogun
553
549
m_fold_evaluations(std::move(fold_evaluations)),
554
550
m_sample_evaluations(std::move(sample_evaluations)),
555
551
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))
559
556
{
560
557
}
561
558
@@ -591,6 +588,5 @@ namespace shogun
591
588
std::string m_predictions_url;
592
589
};
593
590
} // namespace shogun
594
- #endif // HAVE_CURL
595
591
596
592
#endif // SHOGUN_OPENMLFLOW_H
0 commit comments