benchmark-repository-rs/examples/test.rs

43 lines
1.3 KiB
Rust
Raw Normal View History

2018-09-28 16:19:14 +02:00
extern crate benchmark_repository;
extern crate pretty_env_logger;
extern crate yaml_rust;
2018-10-04 17:33:03 +02:00
use benchmark_repository::BenchmarkRepository;
2018-09-28 16:19:14 +02:00
2018-10-12 17:49:30 +02:00
use std::fs;
2018-09-28 16:19:14 +02:00
use std::path::Path;
2018-10-12 17:37:08 +02:00
use std::process::Command;
2018-10-04 17:33:03 +02:00
use yaml_rust::YamlLoader;
2018-09-28 16:19:14 +02:00
fn main()
{
pretty_env_logger::init();
2019-03-02 02:26:16 +01:00
let mut benchmark_repository = BenchmarkRepository::new("gitea@git.luehne.de:patrick/benchmark-template.git", Path::new("cache").to_path_buf(), "gitea");
2018-09-28 16:19:14 +02:00
2018-09-28 16:53:20 +02:00
let content = benchmark_repository.read_file(Path::new("instances.yml"), "config").unwrap();
2018-09-28 16:19:14 +02:00
let instances = &YamlLoader::load_from_str(&content).unwrap()[0];
2019-03-02 02:26:16 +01:00
for instance in instances.as_vec().unwrap()
2018-09-28 16:19:14 +02:00
{
2019-03-02 02:26:16 +01:00
let fruit = instance["fruit"].as_str().unwrap();
let time = instance["time"].as_i64().unwrap();
let job_key = format!("{}/{}", fruit, time);
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");
2018-09-28 16:19:14 +02:00
}
2018-10-12 17:37:08 +02:00
benchmark_repository.join();
2018-09-28 16:19:14 +02:00
}