1
- use dkn_utils:: payloads:: Specs ;
1
+ use dkn_utils:: { payloads:: Specs , SemanticVersion } ;
2
2
use sysinfo:: { CpuRefreshKind , MemoryRefreshKind , RefreshKind } ;
3
3
4
4
pub struct SpecCollector {
@@ -7,21 +7,24 @@ pub struct SpecCollector {
7
7
system : sysinfo:: System ,
8
8
/// Used models.
9
9
models : Vec < String > ,
10
+ /// Version string.
11
+ version : String ,
10
12
// GPU adapter infos, showing information about the available GPUs.
11
13
// gpus: Vec<wgpu::AdapterInfo>,
12
14
}
13
15
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
+ // }
19
21
20
22
impl SpecCollector {
21
- pub fn new ( models : Vec < String > ) -> Self {
23
+ pub fn new ( models : Vec < String > , version : SemanticVersion ) -> Self {
22
24
SpecCollector {
23
25
system : sysinfo:: System :: new_with_specifics ( Self :: get_refresh_specifics ( ) ) ,
24
26
models,
27
+ version : version. to_string ( ) ,
25
28
// gpus: wgpu::Instance::default()
26
29
// .enumerate_adapters(wgpu::Backends::all())
27
30
// .into_iter()
@@ -51,6 +54,7 @@ impl SpecCollector {
51
54
arch : std:: env:: consts:: ARCH . to_string ( ) ,
52
55
lookup : public_ip_address:: perform_lookup ( None ) . await . ok ( ) ,
53
56
models : self . models . clone ( ) ,
57
+ version : self . version . clone ( ) ,
54
58
// gpus: self.gpus.clone(),
55
59
}
56
60
}
@@ -61,7 +65,14 @@ mod tests {
61
65
62
66
#[ tokio:: test]
63
67
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
+ ) ;
65
76
let specs = spec_collector. collect ( ) . await ;
66
77
assert ! ( specs. total_mem > 0 ) ;
67
78
assert ! ( specs. free_mem > 0 ) ;
@@ -70,5 +81,7 @@ mod tests {
70
81
assert ! ( !specs. os. is_empty( ) ) ;
71
82
assert ! ( !specs. arch. is_empty( ) ) ;
72
83
assert ! ( specs. lookup. is_some( ) ) ;
84
+ assert ! ( !specs. models. is_empty( ) ) ;
85
+ assert_eq ! ( specs. version, "0.1.0" ) ;
73
86
}
74
87
}
0 commit comments