Skip to content

Commit 1c437af

Browse files
committed
added more specs info
1 parent 9acae3b commit 1c437af

File tree

4 files changed

+31
-15
lines changed

4 files changed

+31
-15
lines changed

compute/src/node/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ impl DriaComputeNode {
126126
.map(|s| s.score)
127127
.unwrap_or_default();
128128

129+
let spec_collector = SpecCollector::new(model_names.clone(), config.version);
129130
Ok((
130131
DriaComputeNode {
131132
config,
@@ -149,7 +150,7 @@ impl DriaComputeNode {
149150
num_heartbeats: 0,
150151
// specs
151152
specs_reqs: HashSet::new(),
152-
spec_collector: SpecCollector::new(model_names),
153+
spec_collector,
153154
},
154155
p2p_client,
155156
task_batch_worker,

compute/src/reqres/specs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl SpecRequester {
2727
let specs_request = SpecsRequest {
2828
specs_id: uuid,
2929
specs,
30-
models: node.config.workflows.get_model_names(), // FIXME: we have these in specs already?
30+
address: node.config.address.clone(),
3131
};
3232

3333
let specs_message = node.new_message(

compute/src/utils/specs.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use dkn_utils::payloads::Specs;
1+
use dkn_utils::{payloads::Specs, SemanticVersion};
22
use sysinfo::{CpuRefreshKind, MemoryRefreshKind, RefreshKind};
33

44
pub struct SpecCollector {
@@ -7,21 +7,24 @@ pub struct SpecCollector {
77
system: sysinfo::System,
88
/// Used models.
99
models: Vec<String>,
10+
/// Version string.
11+
version: String,
1012
// GPU adapter infos, showing information about the available GPUs.
1113
// gpus: Vec<wgpu::AdapterInfo>,
1214
}
1315

14-
impl Default for SpecCollector {
15-
fn default() -> Self {
16-
Self::new(vec![])
17-
}
18-
}
16+
// impl Default for SpecCollector {
17+
// fn default() -> Self {
18+
// Self::new(vec![], SemanticVersion::default())
19+
// }
20+
// }
1921

2022
impl SpecCollector {
21-
pub fn new(models: Vec<String>) -> Self {
23+
pub fn new(models: Vec<String>, version: SemanticVersion) -> Self {
2224
SpecCollector {
2325
system: sysinfo::System::new_with_specifics(Self::get_refresh_specifics()),
2426
models,
27+
version: version.to_string(),
2528
// gpus: wgpu::Instance::default()
2629
// .enumerate_adapters(wgpu::Backends::all())
2730
// .into_iter()
@@ -51,6 +54,7 @@ impl SpecCollector {
5154
arch: std::env::consts::ARCH.to_string(),
5255
lookup: public_ip_address::perform_lookup(None).await.ok(),
5356
models: self.models.clone(),
57+
version: self.version.clone(),
5458
// gpus: self.gpus.clone(),
5559
}
5660
}
@@ -61,7 +65,14 @@ mod tests {
6165

6266
#[tokio::test]
6367
async fn test_print_specs() {
64-
let mut spec_collector = SpecCollector::new(vec!["gpt-4o".to_string()]);
68+
let mut spec_collector = SpecCollector::new(
69+
vec!["gpt-4o".to_string()],
70+
SemanticVersion {
71+
major: 0,
72+
minor: 1,
73+
patch: 0,
74+
},
75+
);
6576
let specs = spec_collector.collect().await;
6677
assert!(specs.total_mem > 0);
6778
assert!(specs.free_mem > 0);
@@ -70,5 +81,7 @@ mod tests {
7081
assert!(!specs.os.is_empty());
7182
assert!(!specs.arch.is_empty());
7283
assert!(specs.lookup.is_some());
84+
assert!(!specs.models.is_empty());
85+
assert_eq!(specs.version, "0.1.0");
7386
}
7487
}

utils/src/payloads/specs.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ pub const SPECS_TOPIC: &str = "specs";
88
pub struct SpecsRequest {
99
/// UUID of the specs request, prevents replays.
1010
pub specs_id: Uuid,
11-
/// Node specs, flattened during serialization.
11+
/// Node specs.
1212
pub specs: Specs,
13-
/// Model names available in the node.
14-
pub models: Vec<String>,
13+
/// Address of the node, used by frontend etc.
14+
/// instead of using the peer id.
15+
pub address: String,
1516
}
1617

1718
#[derive(Serialize, Deserialize)]
@@ -20,7 +21,6 @@ pub struct SpecsResponse {
2021
pub specs_id: Uuid,
2122
}
2223

23-
/// Machine info & location.
2424
#[derive(Debug, Serialize, Deserialize)]
2525
pub struct Specs {
2626
/// Total memory in bytes
@@ -37,8 +37,10 @@ pub struct Specs {
3737
pub arch: String,
3838
/// Public IP lookup response.
3939
pub lookup: Option<public_ip_address::response::LookupResponse>,
40-
/// Used models.
40+
/// Models server by this node.
4141
pub models: Vec<String>,
42+
/// Node version, e.g. `0.1.0`.
43+
pub version: String,
4244
// GPU adapter infos, showing information about the available GPUs.
4345
// gpus: Vec<wgpu::AdapterInfo>,
4446
}

0 commit comments

Comments
 (0)