Skip to content

Commit

Permalink
feat: Add alternative methods to create tasks and results separately
Browse files Browse the repository at this point in the history
  • Loading branch information
aneojgurhem committed Apr 3, 2023
1 parent 3d3367d commit 359c033
Show file tree
Hide file tree
Showing 9 changed files with 406 additions and 21 deletions.
139 changes: 133 additions & 6 deletions Protos/V1/agent_common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ syntax = "proto3";

package armonik.api.grpc.v1.agent;

import "google/protobuf/timestamp.proto";
import "objects.proto";
import "result_status.proto";

option csharp_namespace = "ArmoniK.Api.gRPC.V1.Agent";

Expand All @@ -16,7 +18,7 @@ message CreateTaskRequest {
DataChunk task_payload = 3;
}

string communication_token = 4;
string communication_token = 4; /** Communication token received by the worker during task processing */
}

message CreateTaskReply {
Expand All @@ -41,11 +43,11 @@ message CreateTaskReply {
CreationStatusList creation_status_list = 1;
string error = 2;
}
string communication_token = 4;
string communication_token = 4; /** Communication token received by the worker during task processing */
}

message DataRequest {
string communication_token = 1;
string communication_token = 1; /** Communication token received by the worker during task processing */
string key = 2;
}

Expand All @@ -57,7 +59,7 @@ message DataReply {
string error = 3;
}
}
string communication_token = 1;
string communication_token = 1; /** Communication token received by the worker during task processing */
oneof type {
Init init = 2;
DataChunk data = 3;
Expand All @@ -70,13 +72,138 @@ message Result {
InitKeyedDataStream init = 1;
DataChunk data = 2;
}
string communication_token = 3;
string communication_token = 3; /** Communication token received by the worker during task processing */
}

message ResultReply {
string communication_token = 3;
string communication_token = 3; /** Communication token received by the worker during task processing */
oneof type {
Empty Ok = 1;
string Error = 2;
}
}

/*
* Request for creating results without data
*/
message CreateResultsMetaDataRequest {
/**
* A result to create.
*/
message ResultCreate {
string name = 1; /** The result name. Given by the client. */
}
repeated ResultCreate results = 1; /** The list of results to create. */
string session_id = 2; /** The session in which create results. */
string communication_token = 3; /** Communication token received by the worker during task processing */
}

/**
* Result metadata
*/
message ResultMetaData {
string session_id = 1; /** The session ID. */
string name = 2; /** The result name. */
string owner_task_id = 3; /** The owner task ID. */
result_status.ResultStatus status = 4; /** The result status. */
google.protobuf.Timestamp created_at = 5; /** The result creation date. */
}

/*
* Response for creating results without data
*/
message CreateResultsMetaDataResponse {
repeated ResultMetaData results = 1; /** The list of metadata results that were created. */
string communication_token = 2; /** Communication token received by the worker during task processing */
}

/**
* Request to create tasks.
*/
message SubmitTasksRequest {
string session_id = 1; /** The session ID. */
TaskOptions task_options = 2; /** The options for the tasks. Each task will have the same. Options are merged with the one from the session. */
repeated TaskRequest task_requests = 3; /** Task creation requests. */
string communication_token = 4; /** Communication token received by the worker during task processing */
}

/**
* Response to create tasks.
*
* expected_output_ids and data_dependencies must be created through ResultsService.
*
* Remark : this may have to be enriched to a better management of errors but
* will the client application be able to manage a missing data dependency or expected output ?
*/
message SubmitTasksResponse {
message TaskInfo {
string task_id = 1; /** The task ID. */
repeated string expected_output_ids = 2; /** The expected output IDs. A task have expected output IDs. */
repeated string data_dependencies = 3; /** The data dependencies IDs (inputs). A task have data dependencies. */
}

repeated TaskInfo task_infos = 1; /** List of task infos if submission successful, else throw gRPC exception. */
string communication_token = 2; /** Communication token received by the worker during task processing */
}

/*
* Request for creating results without data
*/
message CreateResultRequest {
/**
* A result to create.
*/
message ResultCreate {
bytes data = 1; /** The actual data of the result. */
string name = 2; /** The result name. Given by the client. */
}
ResultCreate results = 1; /** The result to create. */
string session_id = 2; /** The session in which create results. */
string communication_token = 3; /** Communication token received by the worker during task processing */
}

/*
* Response for creating results without data
*/
message CreateResultResponse {
ResultMetaData result = 1; /** The raw result that was created. */
string communication_token = 2; /** Communication token received by the worker during task processing */
}

/*
* Request for uploading results data through stream.
* Data must be sent in multiple chunks
*/
message UploadResultDataRequest {
/**
* The metadata to identify the result to update.
*/
message ResultIdentifier {
string session_id = 1; /** The session of the result. */
string result_id = 2; /** The ID of the result. */
}

/**
* The possible messages that constitute a UploadResultDataRequest
* They should be sent in the following order:
* - id
* - data_chunk (stream can have multiple data_chunk messages that represent data divided in several parts)
* - data_complete
*
* Data chunk cannot exceed the size returned by the GetServiceConfiguration rpc method
*/
oneof type {
ResultIdentifier id = 1; /** The identifier of the result to which add data. */
bytes data_chunk = 2; /** A chunk of data. */
bool data_complete = 3; /** Last message telling the data are complete. */
}
string communication_token = 4; /** Communication token received by the worker during task processing */
}

/*
* Response for creating results without data
*/
message UploadResultDataResponse {
ResultMetaData result = 1; /** The raw result that was created. */
string communication_token = 2; /** Communication token received by the worker during task processing */
}
21 changes: 21 additions & 0 deletions Protos/V1/agent_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ import "agent_common.proto";
option csharp_namespace = "ArmoniK.Api.gRPC.V1.Agent";

service Agent {
/**
* Create the metadata of multiple results at once
* Data have to be uploaded separately
*/
rpc CreateResultsMetaData(CreateResultsMetaDataRequest) returns (CreateResultsMetaDataResponse) {}

/**
* Create one result with data included in the request
*/
rpc CreateResult(CreateResultRequest) returns (CreateResultResponse) {}

/**
* Upload data for result with stream
*/
rpc UploadResultData(stream UploadResultDataRequest) returns (UploadResultDataResponse) {}

/**
* Create tasks metadata and submit task for processing.
*/
rpc SubmitTasks(SubmitTasksRequest) returns (SubmitTasksResponse) {}

rpc CreateTask(stream CreateTaskRequest) returns (CreateTaskReply);
rpc GetResourceData(DataRequest) returns (stream DataReply);
rpc GetCommonData(DataRequest) returns (stream DataReply);
Expand Down
11 changes: 6 additions & 5 deletions Protos/V1/objects.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ message Output {
}

message TaskRequest {
repeated string expected_output_keys = 1;
repeated string data_dependencies = 2;
bytes payload = 3;
repeated string expected_output_keys = 1; /** Given names to the expected outputs that will be created implicitly. IDs are returned after task creation */
repeated string data_dependencies = 2; /** IDs of the results that will be used as data dependency. */
bytes payload = 3; /** Content of the payload for the task. */
string payload_name = 4; /** Name that will be associated to the result created for the payload. */
}

message InitKeyedDataStream {
Expand All @@ -61,8 +62,8 @@ message DataChunk {
}

message TaskRequestHeader {
repeated string expected_output_keys = 1;
repeated string data_dependencies = 2;
repeated string expected_output_keys = 1; /** Given names to the expected outputs that will be created implicitly. IDs are returned after task creation */
repeated string data_dependencies = 2; /** IDs of the results that will be used as data dependency. */
}

message InitTaskRequest {
Expand Down
1 change: 1 addition & 0 deletions Protos/V1/result_status.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ enum ResultStatus {
RESULT_STATUS_CREATED = 1; /** Result is created and task is created, submitted or dispatched. */
RESULT_STATUS_COMPLETED = 2; /** Result is completed with a completed task. */
RESULT_STATUS_ABORTED = 3; /** Result is aborted. */
RESULT_STATUS_WAIT_FOR_DATA = 4; /** Result is created and needs data to be added. */

/** NOTFOUND is encoded as 127 to make it small while still leaving enough room for future status extensions
*
Expand Down
Loading

0 comments on commit 359c033

Please sign in to comment.