diff --git a/src/worker.rs b/src/worker.rs index 71c576d..98c551d 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -89,7 +89,7 @@ impl Worker { let Some(run) = self.request_run(server).await else { return false; }; - let run = RunInProgress::new(server.name.clone(), server.server_config, run); + let run = RunInProgress::new(server.name.clone(), run); *server.current_run.lock().unwrap() = Some(run.clone()); drop(guard); diff --git a/src/worker/run.rs b/src/worker/run.rs index 622ec5e..cf4cf8a 100644 --- a/src/worker/run.rs +++ b/src/worker/run.rs @@ -1,4 +1,5 @@ mod internal; +mod repo; use std::{ collections::HashMap, @@ -9,9 +10,9 @@ use log::{error, warn}; use tokio::{select, sync::Notify}; use crate::{ - config::WorkerServerConfig, primitive::Source, shared::{BenchMethod, FinishedRun, Measurement, Run, UnfinishedRun}, + somehow, }; use super::server::Server; @@ -26,17 +27,15 @@ const SCROLLBACK: usize = 50; #[derive(Clone)] pub struct RunInProgress { server_name: String, - server_config: &'static WorkerServerConfig, run: Run, output: Arc>>, abort: Arc, } impl RunInProgress { - pub fn new(server_name: String, server_config: &'static WorkerServerConfig, run: Run) -> Self { + pub fn new(server_name: String, run: Run) -> Self { Self { server_name, - server_config, run, output: Arc::new(Mutex::new(vec![])), abort: Arc::new(Notify::new()), @@ -80,16 +79,18 @@ impl RunInProgress { self.output.lock().unwrap().push((Source::Stderr, line)); } + async fn execute_bench_method(&self, server: &Server) -> somehow::Result> { + match &self.run.bench_method { + BenchMethod::Internal => self.execute_internal(server).await, + BenchMethod::Repo { hash } => self.execute_repo(server, hash).await, + } + } + pub async fn perform(&self, server: &Server) -> Option { // TODO Log system info - let run_future = match &self.run.bench_method { - BenchMethod::Internal => self.perform_internal(server), - BenchMethod::Repo { hash } => todo!(), - }; - let result = select! { - result = run_future => result, + result = self.execute_bench_method(server) => result, _ = self.abort.notified() => { warn!("Run for {} was aborted", server.name); Ok(None) diff --git a/src/worker/run/internal.rs b/src/worker/run/internal.rs index e221678..3b580bf 100644 --- a/src/worker/run/internal.rs +++ b/src/worker/run/internal.rs @@ -153,7 +153,7 @@ fn measurements(counts: Counts) -> HashMap { } impl RunInProgress { - pub(super) async fn perform_internal( + pub(super) async fn execute_internal( &self, server: &Server, ) -> somehow::Result> { diff --git a/src/worker/run/repo.rs b/src/worker/run/repo.rs index da43877..df36671 100644 --- a/src/worker/run/repo.rs +++ b/src/worker/run/repo.rs @@ -1,15 +1,19 @@ -use std::sync::{Arc, Mutex}; +use crate::{somehow, worker::server::Server}; -use tokio::sync::mpsc; +use super::{Finished, RunInProgress}; -use crate::somehow; +impl RunInProgress { + pub(super) async fn execute_repo( + &self, + server: &Server, + hash: &str, + ) -> somehow::Result> { + // TODO Design bench repo specification (benchmark, compare) + // TODO Decide on better name? "benchmark repo", "bench repo", "eval repo"? + // TODO Implement specification + let repo_dir = server.download_repo(&self.run.hash).await?; + let bench_repo_dir = server.download_bench_repo(hash).await?; -use super::{Run, RunStatus}; - -pub async fn run( - run: Arc>, - hash: String, - abort_rx: mpsc::UnboundedReceiver<()>, -) -> somehow::Result { - todo!() + todo!() + } } diff --git a/src/worker/server.rs b/src/worker/server.rs index 5df9fa0..5d40e2a 100644 --- a/src/worker/server.rs +++ b/src/worker/server.rs @@ -98,6 +98,8 @@ impl Server { }, ); + debug!("Downloading repo from {url}"); + let response = self .client .get(url) @@ -117,6 +119,8 @@ impl Server { }, ); + debug!("Downloading bench repo from {url}"); + let response = self .client .get(url)