benchmark-repository-rs/examples/test.rs

79 lines
2.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 00:53:57 +01:00
let mut benchmark_repository = BenchmarkRepository::new("gitea@git.luehne.de:patrick/tplp-planning-benchmark.git", Path::new("cache").to_path_buf(), "gitea", "Potassco Bot", "bot@potassco.org");
2018-09-28 16:19:14 +02:00
2018-09-28 16:53:20 +02:00
let content = benchmark_repository.read_file(Path::new("configurations.yml"), "config").unwrap();
2018-09-28 16:19:14 +02:00
let configurations = &YamlLoader::load_from_str(&content).unwrap()[0]["configurations"];
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];
2018-10-12 17:37:08 +02:00
let mut i = 0;
2018-09-28 16:19:14 +02:00
for configuration in configurations.as_vec().unwrap()
{
for (instance_set_id, instance_set) in instances.as_hash().unwrap()
{
for instance in instance_set.as_vec().unwrap()
{
let configuration_id = configuration["id"].as_str().unwrap();
let instance_set_id = instance_set_id.as_str().unwrap();
let instance_ipc = instance["ipc"].as_str().unwrap();
let instance_domain = instance["domain"].as_str().unwrap();
let instance_number = instance["instance"].as_i64().unwrap();
let file_name_base = format!("{}/{}/{}/{}", configuration_id, instance_ipc, instance_domain, instance_number);
let file_name_output = format!("{}.out", file_name_base);
2018-10-04 17:33:03 +02:00
if benchmark_repository.file_exists(Path::new(&file_name_output), "results")
2018-09-28 16:19:14 +02:00
{
println!("done: [{}, {}, {}/{}/{}]", configuration_id, instance_set_id, instance_ipc, instance_domain, instance_number);
continue;
}
2019-03-02 00:53:57 +01:00
let job = benchmark_repository.create_result_repository();
2018-10-12 17:37:08 +02:00
Command::new("sbatch")
2019-03-02 00:55:28 +01:00
.args(&["/home/pluehne/test-job.sh", "--nodes", "1", "--ntasks-per-node", "1", "-p", "kr"])
2019-03-02 00:53:57 +01:00
.env("JOB_RESULT_REPOSITORY_URL", &format!("file://{}", fs::canonicalize(&job.result_repository_path).unwrap().display()))
.env("JOB_ID", format!("{}", job.id))
2018-10-12 17:37:08 +02:00
.output()
.expect("Could not execute command");
i += 1;
if i > 10
{
break;
}
}
if i > 10
{
break;
2018-09-28 16:19:14 +02:00
}
}
2018-10-12 17:37:08 +02:00
if i > 10
{
break;
}
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
}