1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// use crate::network::TransportType;
// use std::path::PathBuf;
// struct TrainingServerStartParameters {}
// /// Placeholder for server coordination logic
// pub struct ServerCoordinator {
// transport_type: TransportType,
// }
// impl ServerCoordinator {
// pub fn new(transport_type: TransportType) -> Self {
// Self { transport_type }
// }
// }
// pub struct TrainingServerBuilder {
// network_type: TransportType,
// actor_count: Option<i64>,
// default_device: Option<Device>,
// default_model: Option<CModule>,
// algorithm_name: Option<String>,
// config_path: Option<PathBuf>,
// }
// impl TrainingServerBuilder {
// /// Create a new builder with required network type
// pub fn builder(network_type: TransportType) -> Self {
// Self {
// network_type,
// actor_count: None,
// default_device: None,
// default_model: None,
// algorithm_name: None,
// config_path: None,
// }
// }
// pub fn actor_count(mut self, count: i64) -> Self {
// self.actor_count = Some(count);
// self
// }
// pub fn default_device(mut self, device: Device) -> Self {
// self.default_device = Some(device);
// self
// }
// pub fn default_model(mut self, model: CModule) -> Self {
// self.default_model = Some(model);
// self
// }
// pub fn algorithm_name(mut self, name: String) -> Self {
// self.algorithm_name = Some(name.into());
// self
// }
// pub fn config_path(mut self, path: PathBuf) -> Self {
// self.config_path = Some(path.into());
// self
// }
// pub async fn build(self) -> Result<TrainingServer, String> {
// let _actor_count = self.actor_count.unwrap_or(1);
// let _default_device = self.default_device.unwrap_or(Device::Cpu);
// let _default_model = self.default_model;
// let _algorithm_name = self
// .algorithm_name
// .unwrap_or_else(|| "default_algorithm".to_string());
// let _config_path = self
// .config_path
// .unwrap_or_else(|| PathBuf::from("config.json"));
// // Initialize the server with the provided parameters
// let server = TrainingServer::new(self.network_type);
// Ok(server)
// }
// }
// pub struct TrainingServer {
// coordinator: ServerCoordinator,
// }
// impl TrainingServer {
// pub fn new(network_type: TransportType) -> Self {
// Self {
// coordinator: ServerCoordinator::new(network_type),
// }
// }
// pub async fn start(self) {}
// }