benchmark-repository-rs/examples/test.rs

49 lines
1.3 KiB
Rust

extern crate benchmark_repository;
extern crate pretty_env_logger;
extern crate yaml_rust;
use benchmark_repository::BenchmarkRepository;
use std::fs;
use std::path::Path;
use std::process::Command;
use yaml_rust::YamlLoader;
fn main()
{
pretty_env_logger::init();
let mut benchmark_repository = BenchmarkRepository::new("gitea@git.luehne.de:patrick/benchmark-template.git", Path::new("cache").to_path_buf(), "gitea");
let content = benchmark_repository.read_file(Path::new("instances.yml"), "config").unwrap();
let instances = &YamlLoader::load_from_str(&content).unwrap()[0];
for instance in instances.as_vec().unwrap()
{
let fruit = instance["fruit"].as_str().unwrap();
let time = instance["time"].as_i64().unwrap();
let job_key = format!("{}/{}", fruit, time);
if benchmark_repository.is_job_done(&job_key)
{
continue;
}
let job = benchmark_repository.create_job(job_key);
Command::new("sbatch")
.args(&["/home/pluehne/test-job.sh", "--nodes", "1", "--ntasks-per-node", "1", "-p", "kr"])
.env("JOB_RESULT_REPOSITORY_URL", &format!("file://{}", fs::canonicalize(&job.result_repository_path).unwrap().display()))
.env("JOB_ID", format!("{}", job.id))
.env("JOB_KEY", &job.key)
.env("FRUIT", fruit)
.env("TIME", format!("{}", time))
.output()
.expect("Could not execute command");
}
benchmark_repository.join();
}