Prepare bench repo implementation
This commit is contained in:
parent
5d28a2f04a
commit
85aef26340
5 changed files with 32 additions and 23 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Mutex<Vec<(Source, String)>>>,
|
||||
abort: Arc<Notify>,
|
||||
}
|
||||
|
||||
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<Option<Finished>> {
|
||||
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<FinishedRun> {
|
||||
// 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)
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ fn measurements(counts: Counts) -> HashMap<String, Measurement> {
|
|||
}
|
||||
|
||||
impl RunInProgress {
|
||||
pub(super) async fn perform_internal(
|
||||
pub(super) async fn execute_internal(
|
||||
&self,
|
||||
server: &Server,
|
||||
) -> somehow::Result<Option<Finished>> {
|
||||
|
|
|
|||
|
|
@ -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<Option<Finished>> {
|
||||
// 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<Mutex<Run>>,
|
||||
hash: String,
|
||||
abort_rx: mpsc::UnboundedReceiver<()>,
|
||||
) -> somehow::Result<RunStatus> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue