-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathpyclient.cpp
More file actions
810 lines (723 loc) · 24.3 KB
/
pyclient.cpp
File metadata and controls
810 lines (723 loc) · 24.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
/*
* BSD 2-Clause License
*
* Copyright (c) 2021-2024, Hewlett Packard Enterprise
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "pyclient.h"
#include "tensorbase.h"
#include "tensor.h"
#include "srexception.h"
using namespace SmartRedis;
namespace py = pybind11;
// Decorator to standardize exception handling in PyBind Client API methods
template <class T>
auto pb_client_api(T&& client_api_func, const char* name)
{
// we create a closure below
auto decorated =
[name, client_api_func = std::forward<T>(client_api_func)](auto&&... args)
{
try {
return client_api_func(std::forward<decltype(args)>(args)...);
}
catch (Exception& e) {
// exception is already prepared for caller
throw;
}
catch (std::exception& e) {
// should never happen
throw SRInternalException(e.what());
}
catch (...) {
// should never happen
std::string msg(
"A non-standard exception was encountered while executing ");
msg += name;
throw SRInternalException(msg);
}
};
return decorated;
}
// Macro to invoke the decorator with a lambda function
#define MAKE_CLIENT_API(stuff)\
pb_client_api([&] { stuff }, __func__)()
PyClient::PyClient(const std::string& logger_name)
: PySRObject(logger_name)
{
MAKE_CLIENT_API({
_client = new Client(logger_name);
});
}
PyClient::PyClient(
PyConfigOptions& config_options,
const std::string& logger_name)
: PySRObject(logger_name)
{
MAKE_CLIENT_API({
ConfigOptions* co = config_options.get();
_client = new Client(co, logger_name);
});
}
PyClient::PyClient(bool cluster, const std::string& logger_name)
: PySRObject(logger_name)
{
MAKE_CLIENT_API({
_client = new Client(cluster, logger_name);
});
}
PyClient::~PyClient()
{
MAKE_CLIENT_API({
if (_client != NULL) {
delete _client;
_client = NULL;
}
});
}
void PyClient::put_tensor(
std::string& name, std::string& type, py::array data)
{
MAKE_CLIENT_API({
auto buffer = data.request();
void* ptr = buffer.ptr;
// get dims
std::vector<size_t> dims(buffer.ndim);
for (size_t i = 0; i < buffer.shape.size(); i++) {
dims[i] = (size_t)buffer.shape[i];
}
SRTensorType ttype = TENSOR_TYPE_MAP.at(type);
_client->put_tensor(name, ptr, dims, ttype, SRMemLayoutContiguous);
});
}
void PyClient::put_bytes(std::string& name, py::object data)
{
MAKE_CLIENT_API({
std::string bytes_data = data.attr("getvalue")().cast<std::string>();
_client->put_bytes(name, bytes_data.data(), bytes_data.size());
});
}
py::array PyClient::get_tensor(const std::string& name)
{
return MAKE_CLIENT_API({
TensorBase* tensor = _client->_get_tensorbase_obj(name);
// Define py::capsule lambda function for destructor
py::capsule free_when_done((void*)tensor, [](void *tensor) {
delete reinterpret_cast<TensorBase*>(tensor);
});
// detect data type
switch (tensor->type()) {
case SRTensorTypeDouble: {
double* data = reinterpret_cast<double*>(tensor->data_view(
SRMemLayoutContiguous));
return py::array(tensor->dims(), data, free_when_done);
}
case SRTensorTypeFloat: {
float* data = reinterpret_cast<float*>(tensor->data_view(
SRMemLayoutContiguous));
return py::array(tensor->dims(), data, free_when_done);
}
case SRTensorTypeInt64: {
int64_t* data = reinterpret_cast<int64_t*>(tensor->data_view(
SRMemLayoutContiguous));
return py::array(tensor->dims(), data, free_when_done);
}
case SRTensorTypeInt32: {
int32_t* data = reinterpret_cast<int32_t*>(tensor->data_view(
SRMemLayoutContiguous));
return py::array(tensor->dims(), data, free_when_done);
}
case SRTensorTypeInt16: {
int16_t* data = reinterpret_cast<int16_t*>(tensor->data_view(
SRMemLayoutContiguous));
return py::array(tensor->dims(), data, free_when_done);
}
case SRTensorTypeInt8: {
int8_t* data = reinterpret_cast<int8_t*>(tensor->data_view(
SRMemLayoutContiguous));
return py::array(tensor->dims(), data, free_when_done);
}
case SRTensorTypeUint16: {
uint16_t* data = reinterpret_cast<uint16_t*>(tensor->data_view(
SRMemLayoutContiguous));
return py::array(tensor->dims(), data, free_when_done);
}
case SRTensorTypeUint8: {
uint8_t* data = reinterpret_cast<uint8_t*>(tensor->data_view(
SRMemLayoutContiguous));
return py::array(tensor->dims(), data, free_when_done);
}
default :
throw SRRuntimeException("Could not infer type in "\
"PyClient::get_tensor().");
}
});
}
// Get a py::bytes object pointing to the underlying bytes data
py::bytes PyClient::get_bytes(const std::string& name)
{
return MAKE_CLIENT_API({
void* data = NULL;
size_t n_bytes = 0;
// Get the bytes and store in data pointer and update n_bytes
_client->get_bytes(name, data, n_bytes);
// TODO by using py::bytes makes another copy. It would
// be ideal to transfer ownership because get_bytes gives
// back new, unmanaged memory that could be transferred
py::bytes py_bytes = py::bytes((char*)data, n_bytes);
free(data);
return py_bytes;
});
}
void PyClient::delete_bytes(const std::string& name)
{
MAKE_CLIENT_API({
_client->delete_bytes(name);
});
}
void PyClient::delete_tensor(const std::string& name)
{
MAKE_CLIENT_API({
_client->delete_tensor(name);
});
}
void PyClient::copy_tensor(const std::string& src_name,
const std::string& dest_name)
{
MAKE_CLIENT_API({
_client->copy_tensor(src_name, dest_name);
});
}
void PyClient::rename_tensor(const std::string& old_name,
const std::string& new_name)
{
MAKE_CLIENT_API({
_client->rename_tensor(old_name, new_name);
});
}
void PyClient::put_dataset(PyDataset& dataset)
{
MAKE_CLIENT_API({
_client->put_dataset(*(dataset.get()));
});
}
PyDataset* PyClient::get_dataset(const std::string& name)
{
return MAKE_CLIENT_API({
DataSet* data = new DataSet(_client->get_dataset(name));
return new PyDataset(data);
});
}
void PyClient::delete_dataset(const std::string& name)
{
MAKE_CLIENT_API({
_client->delete_dataset(name);
});
}
void PyClient::copy_dataset(
const std::string& src_name, const std::string& dest_name)
{
MAKE_CLIENT_API({
_client->copy_dataset(src_name, dest_name);
});
}
void PyClient::rename_dataset(
const std::string& old_name, const std::string& new_name)
{
MAKE_CLIENT_API({
_client->rename_dataset(old_name, new_name);
});
}
void PyClient::set_script_from_file(const std::string& name,
const std::string& device,
const std::string& script_file)
{
MAKE_CLIENT_API({
_client->set_script_from_file(name, device, script_file);
});
}
void PyClient::set_script_from_file_multigpu(const std::string& name,
const std::string& script_file,
int first_gpu,
int num_gpus)
{
MAKE_CLIENT_API({
_client->set_script_from_file_multigpu(
name, script_file, first_gpu, num_gpus);
});
}
void PyClient::set_script(const std::string& name,
const std::string& device,
const std::string_view& script)
{
MAKE_CLIENT_API({
_client->set_script(name, device, script);
});
}
void PyClient::set_script_multigpu(const std::string& name,
const std::string_view& script,
int first_gpu,
int num_gpus)
{
MAKE_CLIENT_API({
_client->set_script_multigpu(name, script, first_gpu, num_gpus);
});
}
std::string_view PyClient::get_script(const std::string& name)
{
return MAKE_CLIENT_API({
return _client->get_script(name);
});
}
void PyClient::run_script(const std::string& name,
const std::string& function,
std::vector<std::string>& inputs,
std::vector<std::string>& outputs)
{
MAKE_CLIENT_API({
_client->run_script(name, function, inputs, outputs);
});
}
void PyClient::run_script_multigpu(const std::string& name,
const std::string& function,
std::vector<std::string>& inputs,
std::vector<std::string>& outputs,
int offset,
int first_gpu,
int num_gpus)
{
MAKE_CLIENT_API({
_client->run_script_multigpu(
name, function, inputs, outputs, offset, first_gpu, num_gpus);
});
}
void PyClient::delete_script(const std::string& name)
{
MAKE_CLIENT_API({
_client->delete_script(name);
});
}
void PyClient::delete_script_multigpu(
const std::string& name, int first_gpu, int num_gpus)
{
MAKE_CLIENT_API({
_client->delete_script_multigpu(name, first_gpu, num_gpus);
});
}
py::bytes PyClient::get_model(const std::string& name)
{
return MAKE_CLIENT_API({
std::string model(_client->get_model(name));
return py::bytes(model);
});
}
void PyClient::set_model(const std::string& name,
const std::string_view& model,
const std::string& backend,
const std::string& device,
int batch_size,
int min_batch_size,
int min_batch_timeout,
const std::string& tag,
const std::vector<std::string>& inputs,
const std::vector<std::string>& outputs)
{
MAKE_CLIENT_API({
_client->set_model(name, model, backend, device,
batch_size, min_batch_size, min_batch_timeout,
tag, inputs, outputs);
});
}
void PyClient::set_model_multigpu(const std::string& name,
const std::string_view& model,
const std::string& backend,
int first_gpu,
int num_gpus,
int batch_size,
int min_batch_size,
int min_batch_timeout,
const std::string& tag,
const std::vector<std::string>& inputs,
const std::vector<std::string>& outputs)
{
MAKE_CLIENT_API({
_client->set_model_multigpu(name, model, backend, first_gpu, num_gpus,
batch_size, min_batch_size, min_batch_timeout,
tag, inputs, outputs);
});
}
void PyClient::set_model_from_file(const std::string& name,
const std::string& model_file,
const std::string& backend,
const std::string& device,
int batch_size,
int min_batch_size,
int min_batch_timeout,
const std::string& tag,
const std::vector<std::string>& inputs,
const std::vector<std::string>& outputs)
{
MAKE_CLIENT_API({
_client->set_model_from_file(name, model_file, backend, device,
batch_size, min_batch_size, min_batch_timeout,
tag, inputs, outputs);
});
}
void PyClient::set_model_from_file_multigpu(const std::string& name,
const std::string& model_file,
const std::string& backend,
int first_gpu,
int num_gpus,
int batch_size,
int min_batch_size,
int min_batch_timeout,
const std::string& tag,
const std::vector<std::string>& inputs,
const std::vector<std::string>& outputs)
{
MAKE_CLIENT_API({
_client->set_model_from_file_multigpu(
name, model_file, backend, first_gpu, num_gpus, batch_size,
min_batch_size, min_batch_timeout, tag, inputs, outputs);
});
}
void PyClient::run_model(const std::string& name,
std::vector<std::string> inputs,
std::vector<std::string> outputs)
{
MAKE_CLIENT_API({
_client->run_model(name, inputs, outputs);
});
}
void PyClient::run_model_multigpu(const std::string& name,
std::vector<std::string> inputs,
std::vector<std::string> outputs,
int offset,
int first_gpu,
int num_gpus)
{
MAKE_CLIENT_API({
_client->run_model_multigpu(name, inputs, outputs, offset, first_gpu, num_gpus);
});
}
void PyClient::delete_model(const std::string& name)
{
MAKE_CLIENT_API({
_client->delete_model(name);
});
}
void PyClient::delete_model_multigpu(
const std::string& name, int first_gpu, int num_gpus)
{
MAKE_CLIENT_API({
_client->delete_model_multigpu(name, first_gpu, num_gpus);
});
}
void PyClient::set_data_source(const std::string& source_id)
{
MAKE_CLIENT_API({
_client->set_data_source(source_id);
});
}
bool PyClient::key_exists(const std::string& key)
{
return MAKE_CLIENT_API({
return _client->key_exists(key);
});
}
bool PyClient::poll_key(const std::string& key,
int poll_frequency_ms,
int num_tries)
{
return MAKE_CLIENT_API({
return _client->poll_key(key, poll_frequency_ms, num_tries);
});
}
bool PyClient::model_exists(const std::string& name)
{
return MAKE_CLIENT_API({
return _client->model_exists(name);
});
}
bool PyClient::tensor_exists(const std::string& name)
{
return MAKE_CLIENT_API({
return _client->tensor_exists(name);
});
}
bool PyClient::dataset_exists(const std::string& name)
{
return MAKE_CLIENT_API({
return this->_client->dataset_exists(name);
});
}
bool PyClient::bytes_exists(const std::string& name)
{
return MAKE_CLIENT_API({
return this->_client->bytes_exists(name);
});
}
bool PyClient::poll_tensor(const std::string& name,
int poll_frequency_ms,
int num_tries)
{
return MAKE_CLIENT_API({
return _client->poll_tensor(name, poll_frequency_ms, num_tries);
});
}
bool PyClient::poll_dataset(const std::string& name,
int poll_frequency_ms,
int num_tries)
{
return MAKE_CLIENT_API({
return _client->poll_dataset(name, poll_frequency_ms, num_tries);
});
}
bool PyClient::poll_model(const std::string& name,
int poll_frequency_ms,
int num_tries)
{
return MAKE_CLIENT_API({
return _client->poll_model(name, poll_frequency_ms, num_tries);
});
}
bool PyClient::poll_bytes(const std::string& name,
int poll_frequency_ms,
int num_tries)
{
return MAKE_CLIENT_API({
return _client->poll_bytes(name, poll_frequency_ms, num_tries);
});
}
void PyClient::use_tensor_ensemble_prefix(bool use_prefix)
{
MAKE_CLIENT_API({
_client->use_tensor_ensemble_prefix(use_prefix);
});
}
void PyClient::use_dataset_ensemble_prefix(bool use_prefix)
{
MAKE_CLIENT_API({
_client->use_dataset_ensemble_prefix(use_prefix);
});
}
void PyClient::use_model_ensemble_prefix(bool use_prefix)
{
MAKE_CLIENT_API({
_client->use_model_ensemble_prefix(use_prefix);
});
}
void PyClient::use_list_ensemble_prefix(bool use_prefix)
{
MAKE_CLIENT_API({
_client->use_list_ensemble_prefix(use_prefix);
});
}
void PyClient::use_bytes_ensemble_prefix(bool use_prefix)
{
MAKE_CLIENT_API({
_client->use_bytes_ensemble_prefix(use_prefix);
});
}
std::vector<py::dict> PyClient::get_db_node_info(std::vector<std::string> addresses)
{
return MAKE_CLIENT_API({
std::vector<py::dict> addresses_info;
for (size_t i = 0; i < addresses.size(); i++) {
parsed_reply_nested_map info_map = _client->get_db_node_info(addresses[i]);
py::dict info_dict = py::cast(info_map);
addresses_info.push_back(info_dict);
}
return addresses_info;
});
}
std::vector<py::dict> PyClient::get_db_cluster_info(std::vector<std::string> addresses)
{
return MAKE_CLIENT_API({
std::vector<py::dict> addresses_info;
for (size_t i = 0; i < addresses.size(); i++) {
parsed_reply_map info_map = _client->get_db_cluster_info(addresses[i]);
py::dict info_dict = py::cast(info_map);
addresses_info.push_back(info_dict);
}
return addresses_info;
});
}
// Execute AI.INFO command
std::vector<py::dict> PyClient::get_ai_info(
const std::vector<std::string>& addresses,
const std::string& key,
const bool reset_stat)
{
return MAKE_CLIENT_API({
std::vector<py::dict> ai_info;
for (size_t i = 0; i < addresses.size(); i++) {
parsed_reply_map result =
_client->get_ai_info(addresses[i], key, reset_stat);
ai_info.push_back(py::cast(result));
}
return ai_info;
});
}
// Delete all keys of all existing databases
void PyClient::flush_db(std::vector<std::string> addresses)
{
for (size_t i = 0; i < addresses.size(); i++) {
MAKE_CLIENT_API({
_client->flush_db(addresses[i]);
});
}
}
// Read the configuration parameters of a running server
py::dict PyClient::config_get(std::string expression, std::string address)
{
return MAKE_CLIENT_API({
auto result_map = _client->config_get(expression, address);
return py::cast(result_map);
});
}
// Reconfigure the server
void PyClient::config_set(
std::string config_param, std::string value, std::string address)
{
MAKE_CLIENT_API({
_client->config_set(config_param, value, address);
});
}
// Save a copy of the database
void PyClient::save(std::vector<std::string> addresses)
{
for (size_t address_index = 0; address_index < addresses.size(); address_index++) {
MAKE_CLIENT_API({
_client->save(addresses[address_index]);
});
}
}
// Appends a dataset to the aggregation list
void PyClient::append_to_list(const std::string& list_name, PyDataset& dataset)
{
MAKE_CLIENT_API({
_client->append_to_list(list_name, *dataset.get());
});
}
// Delete an aggregation list
void PyClient::delete_list(const std::string& list_name)
{
MAKE_CLIENT_API({
_client->delete_list(list_name);
});
}
// Copy an aggregation list
void PyClient::copy_list(const std::string& src_name, const std::string& dest_name)
{
MAKE_CLIENT_API({
_client->copy_list(src_name, dest_name);
});
}
// Rename an aggregation list
void PyClient::rename_list(const std::string& src_name, const std::string& dest_name)
{
MAKE_CLIENT_API({
_client->rename_list(src_name, dest_name);
});
}
// Get the number of entries in the list
int PyClient::get_list_length(const std::string& list_name)
{
return MAKE_CLIENT_API({
return _client->get_list_length(list_name);
});
}
// Poll list length until length is equal
bool PyClient::poll_list_length(const std::string& name, int list_length,
int poll_frequency_ms, int num_tries)
{
return MAKE_CLIENT_API({
return _client->poll_list_length(
name, list_length, poll_frequency_ms, num_tries);
});
}
// Poll list length until length is greater than or equal
bool PyClient::poll_list_length_gte(const std::string& name, int list_length,
int poll_frequency_ms, int num_tries)
{
return MAKE_CLIENT_API({
return _client->poll_list_length_gte(
name, list_length, poll_frequency_ms, num_tries);
});
}
// Poll list length until length is less than or equal
bool PyClient::poll_list_length_lte(const std::string& name, int list_length,
int poll_frequency_ms, int num_tries)
{
return MAKE_CLIENT_API({
return _client->poll_list_length_lte(
name, list_length, poll_frequency_ms, num_tries);
});
}
// Get datasets from an aggregation list
py::list PyClient::get_datasets_from_list(const std::string& list_name)
{
return MAKE_CLIENT_API({
std::vector<DataSet> datasets = _client->get_datasets_from_list(list_name);
std::vector<PyDataset*> result;
for (auto it = datasets.begin(); it != datasets.end(); it++) {
DataSet* ds = new DataSet(std::move(*it));
result.push_back(new PyDataset(ds));
}
py::list result_list = py::cast(result);
return result_list;
});
}
// Get a range of datasets (by index) from an aggregation list
py::list PyClient::get_dataset_list_range(
const std::string& list_name, const int start_index, const int end_index)
{
return MAKE_CLIENT_API({
std::vector<DataSet> datasets = _client->get_dataset_list_range(
list_name, start_index, end_index);
std::vector<PyDataset*> result;
for (auto it = datasets.begin(); it != datasets.end(); it++) {
DataSet* ds = new DataSet(std::move(*it));
result.push_back(new PyDataset(ds));
}
py::list result_list = py::cast(result);
return result_list;
});
}
// Configure the Redis module chunk size
void PyClient::set_model_chunk_size(int chunk_size)
{
return MAKE_CLIENT_API({
return _client->set_model_chunk_size(chunk_size);
});
}
// Create a string representation of the Client
std::string PyClient::to_string()
{
return MAKE_CLIENT_API({
return _client->to_string();
});
}
// EOF