Skip to content

Commit 8bd8f1b

Browse files
authored
Merge pull request #197 from firstbatchxyz/erhant/task-id-is-string
feat: task id is now string
2 parents 68da651 + 89b602a commit 8bd8f1b

File tree

6 files changed

+25
-19
lines changed

6 files changed

+25
-19
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ default-members = ["compute"]
77

88
[workspace.package]
99
edition = "2021"
10-
version = "0.5.6"
10+
version = "0.5.7"
1111
license = "Apache-2.0"
1212
readme = "README.md"
1313

compute/src/node/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ pub struct DriaComputeNode {
4848
task_request_batch_tx: Option<mpsc::Sender<TaskWorkerInput>>,
4949
/// Task worker transmitter to send single tasks.
5050
task_request_single_tx: Option<mpsc::Sender<TaskWorkerInput>>,
51-
// Single tasks, key is `row_id`
51+
/// Single tasks, key is `row_id`, which has negligible probability of collision.
5252
pub pending_tasks_single: HashMap<Uuid, TaskWorkerMetadata>,
53-
// Batchable tasks, key is `row_id`
53+
// Batchable tasks, key is `row_id`, which has negligible probability of collision.
5454
pub pending_tasks_batch: HashMap<Uuid, TaskWorkerMetadata>,
5555
/// Completed single tasks count
5656
completed_tasks_single: usize,

compute/src/reqres/task.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl TaskResponder {
3434
log::error!(
3535
"Task {}/{} failed due to parsing error: {}",
3636
task.file_id,
37-
task.task_id,
37+
task.row_id,
3838
err_string
3939
);
4040

@@ -106,7 +106,7 @@ impl TaskResponder {
106106
"Publishing {} result for {}/{}",
107107
"task".yellow(),
108108
task_metadata.file_id,
109-
task_metadata.task_id
109+
task_output.row_id
110110
);
111111

112112
// TODO: will get better token count from `TaskWorkerOutput`
@@ -134,7 +134,7 @@ impl TaskResponder {
134134
log::error!(
135135
"Task {}/{} failed: {}",
136136
task_metadata.file_id,
137-
task_metadata.task_id,
137+
task_output.row_id,
138138
err_string
139139
);
140140

compute/src/workers/task.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use uuid::Uuid;
1010
/// This is put into a map before execution, and then removed after the task is done.
1111
pub struct TaskWorkerMetadata {
1212
pub model_name: String,
13-
pub task_id: Uuid,
13+
pub task_id: String,
1414
pub file_id: Uuid,
1515
/// If for any reason this object is dropped before `channel` is responded to,
1616
/// the task will be lost and the channel will be abruptly closed, causing an error on

utils/src/payloads/tasks.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ pub const TASK_RESULT_TOPIC: &str = "results";
1212
/// `result` and `error` are mutually-exclusive, only one of them can be `Some`:
1313
/// - if `result` is `Some`, then it contains the result.
1414
/// - if `error` is `Some`, then it contains the error message.
15+
///
16+
/// Each task belongs to a file (uniquely identified by `file_id`), and has a unique identifier (`row_id`).
17+
/// THe `task_id` is a custom identifier given by a user.
1518
#[derive(Debug, Clone, Serialize, Deserialize)]
1619
#[serde(rename_all = "camelCase")]
1720
pub struct TaskResponsePayload {
18-
/// The unique identifier of the task.
19-
pub row_id: Uuid,
20-
/// The custom identifier of the task.
21-
pub task_id: Uuid,
2221
/// The file that this task is associated with.
2322
pub file_id: Uuid,
23+
/// The unique identifier of the task.
24+
pub row_id: Uuid,
25+
/// The custom identifier of the task, not necessarily unique.
26+
pub task_id: String,
2427
/// Name of the model used for this task.
2528
pub model: String,
2629
/// Stats about the task execution.
@@ -38,15 +41,18 @@ pub struct TaskResponsePayload {
3841
}
3942

4043
/// A generic task request, given by Dria.
44+
///
45+
/// Each task belongs to a file (uniquely identified by `file_id`), and has a unique identifier (`row_id`).
46+
/// THe `task_id` is a custom identifier given by a user.
4147
#[derive(Debug, Clone, Serialize, Deserialize)]
4248
#[serde(rename_all = "camelCase")]
4349
pub struct TaskRequestPayload<T> {
44-
/// The unique identifier of the task.
45-
pub row_id: Uuid,
46-
/// The unique identifier of the task.
47-
pub task_id: Uuid,
4850
/// The file that this task is associated with.
4951
pub file_id: Uuid,
52+
/// The unique identifier of the task.
53+
pub row_id: Uuid,
54+
/// The custom identifier of the task, not necessarily unique.
55+
pub task_id: String,
5056
/// The input to the compute function.
5157
pub input: T,
5258
}

0 commit comments

Comments
 (0)