MCPcopy Create free account
hub / github.com/drogus/crows / drive_progress

Function drive_progress

cli/src/output.rs:259–382  ·  view source on GitHub ↗
(
    client: &mut T,
    run_id: &RunId,
    worker_names: Vec<String>,
)

Source from the content-addressed store, hash-verified

257}
258
259pub async fn drive_progress<T>(
260 client: &mut T,
261 run_id: &RunId,
262 worker_names: Vec<String>,
263) -> anyhow::Result<()>
264where
265 T: ProgressFetcher,
266{
267 let mut stdout = stdout();
268
269 let progress_lines = worker_names.len() as u16;
270
271 let mut all_request_stats: Vec<RequestInfo> = Vec::new();
272 let mut all_iteration_stats: Vec<IterationInfo> = Vec::new();
273 let mut worker_states: HashMap<String, WorkerState> = HashMap::new();
274 let mut bars = HashMap::new();
275
276 for name in worker_names {
277 worker_states.insert(name.clone(), Default::default());
278
279 bars.insert(
280 name.clone(),
281 BarData {
282 worker_name: name.clone(),
283 left: Duration::from_secs(1),
284 ..Default::default()
285 },
286 );
287 }
288
289 loop {
290 let mut lines = Vec::new();
291 let result = client.get_run_status(run_id.clone()).await.unwrap();
292
293 if worker_states.values().all(|s| s.done) {
294 break;
295 }
296
297 for (worker_name, run_info) in result.unwrap().iter() {
298 let state = worker_states
299 .get_mut(worker_name)
300 .ok_or(anyhow!("Couldn't findt the worker"))?;
301 state.active_instances += run_info.active_instances_delta;
302 state.capacity += run_info.capacity_delta;
303
304 all_request_stats.extend(run_info.request_stats.clone());
305 all_iteration_stats.extend(run_info.iteration_stats.clone());
306
307 for log_line in &run_info.stdout {
308 lines.push(format!(
309 "[INFO][{worker_name}] {}",
310 String::from_utf8_lossy(log_line)
311 ));
312 }
313 for log_line in &run_info.stderr {
314 lines.push(format!(
315 "[ERROR][{worker_name}] {}",
316 String::from_utf8_lossy(log_line)

Callers 2

startFunction · 0.85
runFunction · 0.85

Calls 3

printFunction · 0.85
calculate_summaryFunction · 0.85
get_run_statusMethod · 0.45

Tested by

no test coverage detected