-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add task handler api c++ #334
Conversation
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified FilesNo covered modified files...
|
packages/cpp/ArmoniK.Api.Worker/source/Worker/ArmoniKWorker.cpp
Outdated
Show resolved
Hide resolved
packages/cpp/ArmoniK.Api.Worker/source/Worker/ArmoniKWorker.cpp
Outdated
Show resolved
Hide resolved
if (init_request.payload().data_complete()) { | ||
std::string temp = init_request.payload().data(); | ||
payload.resize(temp.length()); | ||
for (size_t i = 0; i < temp.length(); i++) { | ||
payload[i] = static_cast<std::byte>(temp[i]); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is correct, you cannot have data_complete AND data
chuncks.push_back(datachunck.data()); | ||
} | ||
|
||
size_t size = chuncks.size(); | ||
|
||
auto payload_data = new std::byte[size]; | ||
int address = 0; | ||
for (auto iter = chuncks.begin(); iter != chuncks.end(); iter++) { | ||
std::string temp_str = *iter; | ||
|
||
for (size_t i = 0; i < temp_str.length(); i++) { | ||
payload_data[i + address] = static_cast<std::byte>(temp_str[i]); | ||
} | ||
address += temp_str.length(); | ||
} | ||
|
||
payload.resize(size); | ||
std::copy_n(payload_data, size, std::back_inserter(payload)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 : what's the point of payload_data ? You already have payload
2 : Both payload_data and payload are local, they cannot be accessed !
4cf07c7
to
b5a23ed
Compare
b5a23ed
to
f2d6986
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only details, looks good as is
static auto to_request_stream(const std::vector<armonik::api::grpc::v1::TaskRequest> &task_requests, | ||
armonik::api::grpc::v1::TaskOptions task_options, size_t chunk_max_size) | ||
-> std::vector<std::future<std::vector<armonik::api::grpc::v1::agent::CreateTaskRequest>>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static auto to_request_stream(const std::vector<armonik::api::grpc::v1::TaskRequest> &task_requests, | |
armonik::api::grpc::v1::TaskOptions task_options, size_t chunk_max_size) | |
-> std::vector<std::future<std::vector<armonik::api::grpc::v1::agent::CreateTaskRequest>>>; | |
static std::vector<std::future<std::vector<armonik::api::grpc::v1::agent::CreateTaskRequest>>> to_request_stream(const std::vector<armonik::api::grpc::v1::TaskRequest> &task_requests, | |
armonik::api::grpc::v1::TaskOptions task_options, size_t chunk_max_size); | |
for (auto task_request = task_requests.begin(); task_request != task_requests.end(); ++task_request) { | ||
const bool is_last = task_request == task_requests.end() - 1 ? true : false; | ||
|
||
async_chunk_payload_tasks.push_back(task_chunk_stream(*task_request, is_last, chunk_max_size)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (auto task_request = task_requests.begin(); task_request != task_requests.end(); ++task_request) { | |
const bool is_last = task_request == task_requests.end() - 1 ? true : false; | |
async_chunk_payload_tasks.push_back(task_chunk_stream(*task_request, is_last, chunk_max_size)); | |
} | |
for (auto&& task_request : task_requests) { | |
const bool is_last = task_request == task_requests.end() - 1 ? true : false; | |
async_chunk_payload_tasks.push_back(task_chunk_stream(*task_request, is_last, chunk_max_size)); | |
} | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure between auto& and auto&&
No description provided.