Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
27c0701
Migrate storage gRPC error codes to tonic::Status
sitaowang1998 Jun 26, 2026
00c3196
Implement the missing storage gRPC services
sitaowang1998 Jun 26, 2026
b41f226
Refactor ready-task builder to take a task-id closure instead of a trait
sitaowang1998 Jun 26, 2026
1e35e9c
Add ResendReadyTasks and DeleteResourceGroup services with job-gone h…
sitaowang1998 Jun 26, 2026
a1ee868
Merge branch 'main' into storage-grpc-migration
sitaowang1998 Jun 26, 2026
b4fece6
Merge storage-grpc-migration (with main #342) into storage-grpc-services
sitaowang1998 Jun 26, 2026
9c601f1
Merge branch 'storage-grpc-services' into add-missing-services
sitaowang1998 Jun 26, 2026
b98b085
Rename map_inbound_status to inbound_status_to_error to match main's …
sitaowang1998 Jun 26, 2026
b241c34
Rename map_inbound_status and map_liveness_status to match main's sta…
sitaowang1998 Jun 26, 2026
ff31980
Merge storage-grpc-migration (status_to_error rename) into storage-gr…
sitaowang1998 Jun 26, 2026
22dbe6a
Merge storage-grpc-services (status_to_error rename) into add-missing…
sitaowang1998 Jun 26, 2026
429fdbb
Merge branch 'storage-grpc-migration' of github.com:sitaowang1998/spi…
sitaowang1998 Jun 26, 2026
25fc42d
Merge origin/main into storage-grpc-migration
sitaowang1998 Jun 27, 2026
72b1021
Merge storage-grpc-migration (with main #358) into storage-grpc-services
sitaowang1998 Jun 27, 2026
f4790c9
Merge storage-grpc-services (with main #358/#360) into add-missing-se…
sitaowang1998 Jun 27, 2026
86fe70a
Add project skeleton
sitaowang1998 Jun 27, 2026
11381cd
Merge branch 'storage-grpc-migration'
sitaowang1998 Jun 27, 2026
697c49a
Add error
sitaowang1998 Jun 27, 2026
24fb358
Add grpc client connection
sitaowang1998 Jun 27, 2026
e0cf5da
Add job orchestration client
sitaowang1998 Jun 27, 2026
391ed65
Add resource group grpc client
sitaowang1998 Jun 27, 2026
44c1b81
Add tests
sitaowang1998 Jun 27, 2026
c84d324
Update proto.
LinZhihao-723 Jun 28, 2026
9c2f88f
Merge origin/main (tonic 0.14 bump) into storage-grpc-migration
sitaowang1998 Jun 28, 2026
2cf1432
Merge storage-grpc-migration (tonic 0.14 + common.Void responses) int…
sitaowang1998 Jun 28, 2026
7849212
Merge storage-grpc-services (tonic 0.14 + common.Void responses) into…
sitaowang1998 Jun 28, 2026
896eef6
Remove session id 0 check
sitaowang1998 Jun 28, 2026
3c0d0e8
Use void for empty resposne
sitaowang1998 Jun 28, 2026
c137a3b
Map inbound queue closed to internal error
sitaowang1998 Jun 28, 2026
0bba7ae
Merge branch 'storage-grpc-migration' into storage-grpc-services
sitaowang1998 Jun 28, 2026
2aa8d8e
Map inbound queue closed to internal error on the server
sitaowang1998 Jun 28, 2026
d809a62
Merge branch 'storage-grpc-services' into add-missing-services
sitaowang1998 Jun 28, 2026
3e8b1d7
Update resend_ready_tasks doc to drop InboundClosed reference
sitaowang1998 Jun 28, 2026
40c55a9
Merge origin/main into client
sitaowang1998 Jun 28, 2026
add524c
Merge remote-tracking branch 'origin/main' into client
sitaowang1998 Jun 28, 2026
925219a
Merge origin/main into storage-grpc-services
sitaowang1998 Jun 29, 2026
9b7f0b6
Merge branch 'storage-grpc-services' into add-missing-services
sitaowang1998 Jun 29, 2026
ec89ff5
Address comment
sitaowang1998 Jun 29, 2026
3ec8e32
Fix build_ready_tasks docstring to reference actual lane marker types
sitaowang1998 Jun 29, 2026
c998dac
Merge storage-grpc-services into add-missing-services
sitaowang1998 Jun 29, 2026
3a3f712
docs(spider-client): Document Unauthenticated error for cancel_job
sitaowang1998 Jun 29, 2026
ac3f9da
Address comment
sitaowang1998 Jun 29, 2026
4e1d1d8
Merge branch 'client' of github.com:sitaowang1998/spider into client
sitaowang1998 Jun 29, 2026
ccdb787
Bug fix
sitaowang1998 Jun 29, 2026
a342b49
Remove mock test
sitaowang1998 Jun 29, 2026
de929da
Add scheduler service
sitaowang1998 Jun 29, 2026
182d09d
Update doc
sitaowang1998 Jun 29, 2026
dcbefaa
Refactor structure and visibility
sitaowang1998 Jun 29, 2026
a82298d
Add grpc server
sitaowang1998 Jun 29, 2026
bea09d5
Fix docstring
sitaowang1998 Jun 29, 2026
16b7a0e
Merge branch 'main' into client
sitaowang1998 Jun 29, 2026
09c351b
Merge branch 'main' into scheduler-service
sitaowang1998 Jun 29, 2026
3baaf8b
Fix merge
sitaowang1998 Jun 29, 2026
7c82fef
Merge branch 'scheduler-service' into scheduler-grpc-server
sitaowang1998 Jun 29, 2026
c7b2216
Implement scheduler runtime.
LinZhihao-723 Jun 30, 2026
351b00f
Merge branch 'scheduler-runtime' into scheduler-grpc-server
sitaowang1998 Jun 30, 2026
b3d3407
Add scheduler grpc server
sitaowang1998 Jun 30, 2026
c876a54
Fix toml
sitaowang1998 Jun 30, 2026
6b7207e
Merge branch 'main' into client
sitaowang1998 Jun 30, 2026
ad69055
Merge branch 'main' into add-missing-services
sitaowang1998 Jun 30, 2026
04e3e1e
Merge branch 'oss-main' into scheduler-runtime
LinZhihao-723 Jun 30, 2026
50a562f
Merge branch 'scheduler-runtime' into scheduler-grpc-server
sitaowang1998 Jun 30, 2026
bbf288d
Fix merge
sitaowang1998 Jul 1, 2026
5edb5b8
Merge branch 'main' into scheduler-grpc-server
sitaowang1998 Jul 1, 2026
41f0a80
Fix grpc status
sitaowang1998 Jul 1, 2026
b80c288
Merge add-missing-services into huntsman-dev
sitaowang1998 Jul 1, 2026
e21a1a7
Merge scheduler-grpc-server into huntsman-dev
sitaowang1998 Jul 1, 2026
7b70971
Merge client into huntsman-dev
sitaowang1998 Jul 1, 2026
605e780
Add run scripts
sitaowang1998 Jul 2, 2026
071c074
Add an example
sitaowang1998 Jul 2, 2026
7f7d0ae
Add log level setting
sitaowang1998 Jul 3, 2026
2ce54a3
chore(spider-stack): Tune default local-stack config for concurrent s…
LinZhihao-723 Jul 3, 2026
1c23f65
feat(examples): Add CLP-search-over-Spider benchmark harness.
LinZhihao-723 Jul 3, 2026
21464a9
Add script to run ems
sitaowang1998 Jul 3, 2026
1abf7c6
Merge branch 'huntsman-dev-e2e' of https://github.com/sitaowang1998/s…
LinZhihao-723 Jul 3, 2026
a8ac3da
Add neural network benchmark code
sitaowang1998 Jul 3, 2026
0db7cdd
feat(spider): Instrument EM and scheduler with per-task benchmark tim…
LinZhihao-723 Jul 3, 2026
d9ced5d
feat(examples): Extend CLP-search harness with metrics, archive shuff…
LinZhihao-723 Jul 3, 2026
1be19e6
chore(spider-stack): Tune scheduler/storage queues and poll intervals…
LinZhihao-723 Jul 3, 2026
34ddbe4
Merge branch 'huntsman-dev-e2e' of https://github.com/sitaowang1998/s…
LinZhihao-723 Jul 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
resolver = "3"
members = [
"components/spider-client",
"components/spider-core",
"components/spider-derive",
"components/spider-execution-manager",
Expand All @@ -11,15 +12,22 @@ members = [
"components/spider-tdl",
"components/spider-tdl-derive",
"components/spider-utils",
"examples/huntsman/clp-search/client",
"examples/huntsman/clp-search/pool-ref",
"examples/huntsman/clp-search/tasks",
"examples/huntsman/complex/client",
"examples/huntsman/complex/tasks",
"examples/huntsman/complex/types",
"examples/huntsman/nn/client",
"examples/huntsman/nn/tasks",
"tests/huntsman/em-runtime",
"tests/huntsman/integration-test-tasks",
"tests/huntsman/task-executor",
"tests/huntsman/tdl-integration",
"tests/huntsman/test-utils",
]
default-members = [
"components/spider-client",
"components/spider-core",
"components/spider-derive",
"components/spider-execution-manager",
Expand Down
16 changes: 16 additions & 0 deletions components/spider-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "spider-client"
version = "0.1.0"
edition = "2024"

[lib]
name = "spider_client"
path = "src/lib.rs"

[dependencies]
spider-core = { path = "../spider-core" }
spider-proto-rust = { path = "../spider-proto-rust" }
spider-utils = { path = "../spider-utils" }
thiserror = "2.0.18"
tokio = { version = "1.52.3", features = ["macros"] }
tonic = "0.14.6"
184 changes: 184 additions & 0 deletions components/spider-client/src/client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
//! [`SpiderClient`] — the top-level handle holding the gRPC connection pools.

use std::num::NonZeroUsize;

use spider_core::{
job::JobState,
task::TaskGraph,
types::{
id::{JobId, ResourceGroupId},
io::{TaskInput, TaskOutput},
},
};
use tonic::transport::Endpoint;

use crate::{
error::ClientError,
grpc::{job::JobOrchestrationClient, resource_group::ResourceGroupManagementClient},
};

/// User-facing client for the Spider storage gRPC services.
///
/// Wraps a [`JobOrchestrationClient`] and a [`ResourceGroupManagementClient`] against the same
/// storage endpoint, so callers who need both job-lifecycle and resource-group operations get a
/// single handle and one [`SpiderClient::connect`] call. Callers who need only one service may
/// construct the inner client directly.
#[derive(Debug, Clone)]
pub struct SpiderClient {
job_orchestration: JobOrchestrationClient,
resource_group: ResourceGroupManagementClient,
}

impl SpiderClient {
/// Connects pools of `pool_size` connections to the storage gRPC endpoint.
///
/// Both the job-orchestration and resource-group-management services are reached through the
/// same `endpoint`.
///
/// # Returns
///
/// A new [`SpiderClient`] connected to `endpoint` on success.
///
/// # Errors
///
/// Returns [`ClientError::Transport`] if tonic cannot establish a connection to `endpoint`.
pub async fn connect(endpoint: Endpoint, pool_size: NonZeroUsize) -> Result<Self, ClientError> {
let (job_orchestration, resource_group) = tokio::try_join!(
JobOrchestrationClient::connect(endpoint.clone(), pool_size),
ResourceGroupManagementClient::connect(endpoint, pool_size),
)?;

Ok(Self {
job_orchestration,
resource_group,
})
}

/// Serializes and zstd-compresses the task graph and inputs, registers the job, and returns
/// its assigned id. Delegates to [`JobOrchestrationClient::submit_job`].
///
/// # Returns
///
/// The [`JobId`] the storage server assigned to the registered job on success.
///
/// # Errors
///
/// See [`JobOrchestrationClient::submit_job`].
pub async fn submit_job(
&self,
resource_group_id: ResourceGroupId,
task_graph: &TaskGraph,
inputs: Vec<TaskInput>,
) -> Result<JobId, ClientError> {
self.job_orchestration
.submit_job(resource_group_id, task_graph, inputs)
.await
}

/// Starts a registered job. Delegates to [`JobOrchestrationClient::start_job`].
///
/// # Returns
///
/// The job's [`JobState`] after the start request is accepted on success.
///
/// # Errors
///
/// See [`JobOrchestrationClient::start_job`].
pub async fn start_job(&self, job_id: JobId) -> Result<JobState, ClientError> {
self.job_orchestration.start_job(job_id).await
}

/// Cancels a job. Delegates to [`JobOrchestrationClient::cancel_job`].
///
/// # Returns
///
/// The job's [`JobState`] after the cancellation request is accepted on success.
///
/// # Errors
///
/// See [`JobOrchestrationClient::cancel_job`].
pub async fn cancel_job(&self, job_id: JobId) -> Result<JobState, ClientError> {
self.job_orchestration.cancel_job(job_id).await
}

/// Gets the current state of a job. Delegates to [`JobOrchestrationClient::get_job_state`].
///
/// # Returns
///
/// The job's current [`JobState`] on success.
///
/// # Errors
///
/// See [`JobOrchestrationClient::get_job_state`].
pub async fn get_job_state(&self, job_id: JobId) -> Result<JobState, ClientError> {
self.job_orchestration.get_job_state(job_id).await
}

/// Gets a job's task outputs. Delegates to [`JobOrchestrationClient::get_job_outputs`].
///
/// # Returns
///
/// The job's outputs, deserialized from the storage wire format into opaque msgpack payloads,
/// on success.
///
/// # Errors
///
/// See [`JobOrchestrationClient::get_job_outputs`].
pub async fn get_job_outputs(&self, job_id: JobId) -> Result<Vec<TaskOutput>, ClientError> {
self.job_orchestration.get_job_outputs(job_id).await
}

/// Gets a job's error message. Delegates to [`JobOrchestrationClient::get_job_error`].
///
/// # Returns
///
/// The job's error message on success.
///
/// # Errors
///
/// See [`JobOrchestrationClient::get_job_error`].
pub async fn get_job_error(&self, job_id: JobId) -> Result<String, ClientError> {
self.job_orchestration.get_job_error(job_id).await
}

/// Registers an external resource group and returns its server-assigned id. Delegates to
/// [`ResourceGroupManagementClient::add_resource_group`].
///
/// # Returns
///
/// The [`ResourceGroupId`] the storage server assigned to the registered resource group on
/// success.
///
/// # Errors
///
/// See [`ResourceGroupManagementClient::add_resource_group`].
pub async fn add_resource_group(
&self,
external_resource_group_id: String,
password: Vec<u8>,
) -> Result<ResourceGroupId, ClientError> {
self.resource_group
.add_resource_group(external_resource_group_id, password)
.await
}

/// Verifies a resource group's password. Delegates to
/// [`ResourceGroupManagementClient::verify_resource_group`].
///
/// # Returns
///
/// `Ok(())` on success.
///
/// # Errors
///
/// See [`ResourceGroupManagementClient::verify_resource_group`].
pub async fn verify_resource_group(
&self,
resource_group_id: ResourceGroupId,
password: Vec<u8>,
) -> Result<(), ClientError> {
self.resource_group
.verify_resource_group(resource_group_id, password)
.await
}
}
Loading