Skip to content

Commit ec9f4c6

Browse files
committed
fix new rustc lint warnings
1 parent 854c161 commit ec9f4c6

File tree

11 files changed

+61
-81
lines changed

11 files changed

+61
-81
lines changed

compute/src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl DriaComputeNodeConfig {
6363
}
6464
}
6565
Err(err) => {
66-
log::error!("No secret key provided: {}", err);
66+
log::error!("No secret key provided: {err}");
6767
panic!("Please provide a secret key.");
6868
}
6969
};
@@ -81,11 +81,11 @@ impl DriaComputeNodeConfig {
8181

8282
// print address
8383
let address = hex::encode(public_key_to_address(&public_key));
84-
log::info!("Node Address: 0x{}", address);
84+
log::info!("Node Address: 0x{address}");
8585

8686
// to this here to log the peer id at start
8787
let peer_id = secret_to_keypair(&secret_key).public().to_peer_id();
88-
log::info!("Node PeerID: {}", peer_id);
88+
log::info!("Node PeerID: {peer_id}");
8989

9090
// parse listen address
9191
let p2p_listen_addr_str = env::var("DKN_P2P_LISTEN_ADDR")

compute/src/main.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ async fn main() -> Result<()> {
3636

3737
// log about env usage
3838
match dotenv_result {
39-
Ok(_) => log::info!("Loaded environment file from {}", env_path),
40-
Err(e) => log::warn!("Could not load environment file from {}: {}", env_path, e),
39+
Ok(_) => log::info!("Loaded environment file from {env_path}"),
40+
Err(err) => log::warn!("Could not load environment file from {env_path}: {err}"),
4141
}
4242

4343
// task tracker for multiple threads
@@ -52,14 +52,14 @@ async fn main() -> Result<()> {
5252
env::var("DKN_EXIT_TIMEOUT").map(|s| s.to_string().parse::<u64>())
5353
{
5454
// the timeout is done for profiling only, and should not be used in production
55-
log::warn!("Waiting for {} seconds before exiting.", duration_secs);
55+
log::warn!("Waiting for {duration_secs} seconds before exiting.");
5656
tokio::time::sleep(tokio::time::Duration::from_secs(duration_secs)).await;
5757

5858
log::warn!("Exiting due to DKN_EXIT_TIMEOUT.");
5959
cancellation_token.cancel();
6060
} else if let Err(err) = wait_for_termination(cancellation_token.clone()).await {
6161
// if there is no timeout, we wait for termination signals here
62-
log::error!("Error waiting for termination: {:?}", err);
62+
log::error!("Error waiting for termination: {err:?}");
6363
log::error!("Cancelling due to unexpected error.");
6464
cancellation_token.cancel();
6565
};
@@ -104,7 +104,7 @@ async fn main() -> Result<()> {
104104
config.executors.get_model_names().join(", "),
105105
model_perf
106106
.iter()
107-
.map(|(model, perf)| format!("{}: {}", model, perf))
107+
.map(|(model, perf)| format!("{model}: {perf}"))
108108
.collect::<Vec<_>>()
109109
.join("\n")
110110
);
@@ -124,10 +124,7 @@ async fn main() -> Result<()> {
124124
batch_size <= TaskWorker::MAX_BATCH_SIZE,
125125
"batch size too large"
126126
);
127-
log::info!(
128-
"Spawning batch executor worker thread. (batch size {})",
129-
batch_size
130-
);
127+
log::info!("Spawning batch executor worker thread. (batch size {batch_size})");
131128
task_tracker.spawn(async move { worker_batch.run_batch(batch_size).await });
132129
}
133130

compute/src/node/core.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ impl DriaComputeNode {
5353
// a task is completed by the worker & should be responded to the requesting peer
5454
task_response_msg_opt = self.task_output_rx.recv() => {
5555
if let Some(task_response_msg) = task_response_msg_opt {
56-
if let Err(e) = self.send_task_output(task_response_msg).await {
57-
log::error!("Error responding to task: {:?}", e);
56+
if let Err(err) = self.send_task_output(task_response_msg).await {
57+
log::error!("Error responding to task: {err:?}");
5858
}
5959
} else {
6060
log::error!("task_output_rx channel closed unexpectedly, we still have {} batch and {} single tasks.", self.pending_tasks_batch.len(), self.pending_tasks_single.len());
@@ -117,8 +117,8 @@ impl DriaComputeNode {
117117
self.handle_diagnostic_refresh().await;
118118

119119
// shutdown channels
120-
if let Err(e) = self.shutdown().await {
121-
log::error!("Could not shutdown the node gracefully: {:?}", e);
120+
if let Err(err) = self.shutdown().await {
121+
log::error!("Could not shutdown the node gracefully: {err:?}");
122122
}
123123
}
124124

compute/src/node/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl DriaComputeNode {
8181

8282
// dial the RPC node
8383
let dria_rpc = if let Some(addr) = config.initial_rpc_addr.take() {
84-
log::info!("Using initial RPC address: {}", addr);
84+
log::info!("Using initial RPC address: {addr}");
8585
DriaRPC::new(addr, config.network).expect("could not get RPC to connect to")
8686
} else {
8787
DriaRPC::new_for_network(config.network, &config.version)
@@ -92,7 +92,7 @@ impl DriaComputeNode {
9292
// we are using the major.minor version as the P2P version
9393
// so that patch versions do not interfere with the protocol
9494
let protocol = DriaP2PProtocol::new_major_minor(config.network.protocol_name());
95-
log::info!("Using identity: {}", protocol);
95+
log::info!("Using identity: {protocol}");
9696

9797
// create p2p client
9898
let (p2p_client, p2p_commander, request_rx) = DriaP2PClient::new(

compute/src/node/reqres.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,24 @@ impl DriaComputeNode {
3030
request_id,
3131
channel,
3232
} => {
33-
log::debug!("Received a request ({}) from {}", request_id, peer_id);
33+
log::debug!("Received a request ({request_id}) from {peer_id}");
3434

3535
// ensure that message is from the known RPCs
3636
if self.dria_rpc.peer_id != peer_id {
37-
log::warn!("Received request from unauthorized source: {}", peer_id);
37+
log::warn!("Received request from unauthorized source: {peer_id}");
3838
log::debug!("Allowed source: {}", self.dria_rpc.peer_id);
39-
} else if let Err(e) = self.handle_request(peer_id, &request, channel).await {
40-
log::error!("Error handling request: {:?}", e);
39+
} else if let Err(err) = self.handle_request(peer_id, &request, channel).await {
40+
log::error!("Error handling request: {err:?}");
4141
}
4242
}
4343

4444
DriaReqResMessage::Response {
4545
response,
4646
request_id,
4747
} => {
48-
log::debug!("Received a response ({}) from {}", request_id, peer_id);
49-
if let Err(e) = self.handle_response(peer_id, request_id, response).await {
50-
log::error!("Error handling response: {:?}", e);
48+
log::debug!("Received a response ({request_id}) from {peer_id}");
49+
if let Err(err) = self.handle_response(peer_id, request_id, response).await {
50+
log::error!("Error handling response: {err:?}");
5151
}
5252
}
5353
};
@@ -65,7 +65,7 @@ impl DriaComputeNode {
6565
data: Vec<u8>,
6666
) -> Result<()> {
6767
if peer_id != self.dria_rpc.peer_id {
68-
log::warn!("Received response from unauthorized source: {}", peer_id);
68+
log::warn!("Received response from unauthorized source: {peer_id}");
6969
log::debug!("Allowed source: {}", self.dria_rpc.peer_id);
7070
}
7171

@@ -126,7 +126,7 @@ impl DriaComputeNode {
126126

127127
let (task_input, task_metadata) =
128128
TaskResponder::parse_task_request(self, &task_request, channel).await?;
129-
if let Err(e) = match task_input.task.is_batchable() {
129+
if let Err(err) = match task_input.task.is_batchable() {
130130
// this is a batchable task, send it to batch worker
131131
// and keep track of the task id in pending tasks
132132
true => match self.task_request_batch_tx {
@@ -149,7 +149,7 @@ impl DriaComputeNode {
149149
None => eyre::bail!("Single task received but no worker available."),
150150
},
151151
} {
152-
log::error!("Could not send task to worker: {:?}", e);
152+
log::error!("Could not send task to worker: {err:?}");
153153
};
154154

155155
Ok(())

compute/src/workers/task.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl TaskWorker {
139139
);
140140
debug_assert!(num_tasks != 0, "number of tasks cant be zero");
141141

142-
log::info!("Processing {} tasks in batch", num_tasks);
142+
log::info!("Processing {num_tasks} tasks in batch");
143143
let mut batch = tasks.into_iter().map(|b| (b, &self.publish_tx));
144144
match num_tasks {
145145
1 => {
@@ -235,8 +235,8 @@ impl TaskWorker {
235235
stats: input.stats,
236236
};
237237

238-
if let Err(e) = publish_tx.send(output).await {
239-
log::error!("Error sending task result: {}", e);
238+
if let Err(err) = publish_tx.send(output).await {
239+
log::error!("Error sending task result: {err}");
240240
}
241241
}
242242
}

executor/src/executors/ollama.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl OllamaClient {
105105
}
106106
}
107107
};
108-
log::info!("Found local Ollama models: {:#?}", local_models);
108+
log::info!("Found local Ollama models: {local_models:#?}");
109109

110110
// check external models & pull them if available
111111
// iterate over models and remove bad ones
@@ -114,13 +114,13 @@ impl OllamaClient {
114114
for model in models.iter() {
115115
// pull the model if it is not in the local models
116116
if !local_models.contains(&model.to_string()) {
117-
log::warn!("Model {} not found in Ollama", model);
117+
log::warn!("Model {model} not found in Ollama");
118118
if self.auto_pull {
119119
self.try_pull(model)
120120
.await
121121
.wrap_err("could not pull model")?;
122122
} else {
123-
log::error!("Please download missing model with: ollama pull {}", model);
123+
log::error!("Please download missing model with: ollama pull {model}");
124124
log::error!("Or, set OLLAMA_AUTO_PULL=true to pull automatically.");
125125
eyre::bail!("required model not pulled in Ollama");
126126
}
@@ -145,7 +145,7 @@ impl OllamaClient {
145145
if models.is_empty() {
146146
log::warn!("No Ollama models passed the performance test! Try using a more powerful machine OR smaller models.");
147147
} else {
148-
log::info!("Ollama checks are finished, using models: {:#?}", models);
148+
log::info!("Ollama checks are finished, using models: {models:#?}");
149149
}
150150

151151
Ok(model_performances)
@@ -155,10 +155,7 @@ impl OllamaClient {
155155
async fn try_pull(&self, model: &Model) -> Result<ollama_rs::models::pull::PullModelStatus> {
156156
// TODO: add pull-bar here
157157
// if auto-pull is enabled, pull the model
158-
log::info!(
159-
"Downloading missing model {} (this may take a while)",
160-
model
161-
);
158+
log::info!("Downloading missing model {model} (this may take a while)");
162159
self.ollama_rs_client
163160
.pull_model(model.to_string(), false)
164161
.await
@@ -173,10 +170,10 @@ impl OllamaClient {
173170
const TEST_PROMPT: &str = "Please write a poem about Kapadokya.";
174171
const WARMUP_PROMPT: &str = "Write a short poem about hedgehogs and squirrels.";
175172

176-
log::info!("Testing model {}", model);
173+
log::info!("Measuring {model}");
177174

178175
// run a dummy generation for warm-up
179-
log::debug!("Warming up Ollama for model {}", model);
176+
log::debug!("Warming up Ollama for {model}");
180177
if let Err(err) = self
181178
.ollama_rs_client
182179
.generate(GenerationRequest::new(
@@ -185,7 +182,7 @@ impl OllamaClient {
185182
))
186183
.await
187184
{
188-
log::warn!("Ignoring model {model}: {err}");
185+
log::warn!("Ignoring {model}: {err}");
189186
return SpecModelPerformance::ExecutionFailed;
190187
}
191188

@@ -199,7 +196,7 @@ impl OllamaClient {
199196
)
200197
.await
201198
else {
202-
log::warn!("Ignoring model {model}: Timed out");
199+
log::warn!("Ignoring {model}: Timed out");
203200
return SpecModelPerformance::Timeout;
204201
};
205202

@@ -211,18 +208,17 @@ impl OllamaClient {
211208
* 1_000_000_000f64;
212209

213210
if tps >= PERFORMANCE_MIN_TPS {
214-
log::info!("Model {model} passed the test with tps: {tps}");
211+
log::info!("{model} passed the test with tps: {tps}");
215212
SpecModelPerformance::PassedWithTPS(tps)
216213
} else {
217214
log::warn!(
218-
"Ignoring model {model}: tps too low ({tps:.3} < {:.3})",
219-
PERFORMANCE_MIN_TPS
215+
"Ignoring {model}: tps too low ({tps:.3} < {PERFORMANCE_MIN_TPS:.3})"
220216
);
221217
SpecModelPerformance::FailedWithTPS(tps)
222218
}
223219
}
224220
Err(err) => {
225-
log::warn!("Ignoring model {model} due to: {err}");
221+
log::warn!("Ignoring {model} due to: {err}");
226222
SpecModelPerformance::ExecutionFailed
227223
}
228224
}

executor/src/manager.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,7 @@ impl DriaExecutorsManager {
126126
self.providers.retain(|provider, (_, models)| {
127127
let ok = !models.is_empty();
128128
if !ok {
129-
log::warn!(
130-
"Provider {} has no models left, removing it from the config.",
131-
provider
132-
)
129+
log::warn!("Provider {provider} has no models left, removing it from the config.")
133130
}
134131
ok
135132
});

executor/src/models.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ impl FromStr for Model {
5858
/// On failure, returns the original string back as the `Err` value.
5959
fn from_str(value: &str) -> Result<Self, Self::Err> {
6060
// serde requires quotes (for JSON)
61-
serde_json::from_str::<Self>(&format!("\"{}\"", value))
62-
.map_err(|e| format!("Model {} invalid: {}", value, e))
61+
serde_json::from_str::<Self>(&format!("\"{value}\""))
62+
.map_err(|err| format!("Model {value} invalid: {err}"))
6363
}
6464
}
6565

@@ -204,8 +204,8 @@ impl FromStr for ModelProvider {
204204
/// On failure, returns the original string back as the `Err` value.
205205
fn from_str(value: &str) -> Result<Self, Self::Err> {
206206
// serde requires quotes (for JSON)
207-
serde_json::from_str::<Self>(&format!("\"{}\"", value))
208-
.map_err(|e| format!("Model provider {} invalid: {}", value, e))
207+
serde_json::from_str::<Self>(&format!("\"{value}\""))
208+
.map_err(|err| format!("Model provider {value} invalid: {err}"))
209209
}
210210
}
211211

0 commit comments

Comments
 (0)