Skip to content

Commit 3ab82cd

Browse files
committed
add peer id to spec
1 parent 1eeaf9a commit 3ab82cd

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
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.6.4"
10+
version = "0.6.5"
1111
license = "Apache-2.0"
1212
readme = "README.md"
1313

compute/src/node/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ impl DriaComputeNode {
131131
model_perf,
132132
config.version,
133133
config.exec_platform.clone(),
134+
p2p_client.peer_id,
134135
);
135136
Ok((
136137
DriaComputeNode {

compute/src/utils/specs.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use dkn_executor::Model;
2+
use dkn_p2p::libp2p::PeerId;
23
use dkn_utils::{
34
payloads::{SpecModelPerformance, Specs},
45
SemanticVersion,
@@ -18,6 +19,8 @@ pub struct SpecCollector {
1819
version: String,
1920
/// Execution platform, mainly for diagnostics.
2021
exec_platform: String,
22+
/// Peer ID of the node, used for identification in the network.
23+
peer_id: String,
2124
// GPU adapter infos, showing information about the available GPUs.
2225
// gpus: Vec<wgpu::AdapterInfo>,
2326
}
@@ -28,6 +31,7 @@ impl SpecCollector {
2831
model_perf: HashMap<Model, SpecModelPerformance>,
2932
version: SemanticVersion,
3033
exec_platform: String,
34+
peer_id: PeerId,
3135
) -> Self {
3236
log::info!("Creating spec collector with version {version} and platform {exec_platform} and models {models:?}");
3337
SpecCollector {
@@ -39,6 +43,7 @@ impl SpecCollector {
3943
.collect(),
4044
version: version.to_string(),
4145
exec_platform,
46+
peer_id: peer_id.to_string(),
4247
// gpus: wgpu::Instance::default()
4348
// .enumerate_adapters(wgpu::Backends::all())
4449
// .into_iter()
@@ -70,7 +75,8 @@ impl SpecCollector {
7075
models: self.models.clone(),
7176
version: self.version.clone(),
7277
model_perf: self.model_perf.clone(),
73-
exec_platform: self.exec_platform.clone(),
78+
exec_platform: Some(self.exec_platform.clone()),
79+
peer_id: Some(self.peer_id.clone()),
7480
// gpus: self.gpus.clone(),
7581
}
7682
}
@@ -94,6 +100,7 @@ mod tests {
94100
patch: 1,
95101
},
96102
"testing".to_string(),
103+
PeerId::random(),
97104
);
98105
let specs = spec_collector.collect().await;
99106
assert!(specs.total_mem > 0);
@@ -106,7 +113,7 @@ mod tests {
106113
assert!(!specs.models.is_empty());
107114
assert_eq!(specs.model_perf.len(), 3);
108115
assert_eq!(specs.version, "4.5.1");
109-
assert_eq!(specs.exec_platform, "testing");
116+
assert_eq!(specs.exec_platform, Some("testing".to_string()));
110117

111118
// should be serializable to JSON
112119
assert!(serde_json::to_string_pretty(&specs).is_ok())

utils/src/payloads/specs.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub struct SpecsResponse {
2323

2424
/// The specs of a node, containing information about the hardware and software it runs on.
2525
///
26-
/// These are stored in a database / cache.
26+
/// Optional values are done so for backwards compatibility, as some fields were added later.
2727
#[derive(Debug, Serialize, Deserialize)]
2828
pub struct Specs {
2929
/// Total memory in bytes
@@ -47,7 +47,11 @@ pub struct Specs {
4747
/// Node version, e.g. `0.1.0`.
4848
pub version: String,
4949
/// Name of the execution platform, e.g. Docker file or Launcher.
50-
pub exec_platform: String,
50+
#[serde(skip_serializing_if = "Option::is_none")]
51+
pub exec_platform: Option<String>,
52+
/// Peer id of the node.
53+
#[serde(skip_serializing_if = "Option::is_none")]
54+
pub peer_id: Option<String>,
5155
// GPU adapter infos, showing information about the available GPUs.
5256
// gpus: Vec<wgpu::AdapterInfo>,
5357
}

0 commit comments

Comments
 (0)