sbatch-rs
Sbatch command generator in rust
Overview
This is a simple library which allows you to generate sbatch commands in rust in a programmatic way with error checking.
SbatchOption
The SbatchOption enum is a complete enumeration of all the options that can be passed to sbatch. For example:
use SbatchOption;
let job_name = JobName;
let cpu = NTasks;
let time = Time;
Each SbatchOption takes either Nothing, a String, or an Option as an argument. The rational against using say u32 for the number of tasks is that it would prevent the use of variables. For example, this is valid:
use SbatchOption;
let cpu = NTasks;
Sbatch
The Sbatch struct is a builder which allows you to build up an sbatch command with error checking.
use ;
// Create a new `Sbatch` instance
let sbatch = new
.add_option.unwrap
.add_option.unwrap
.add_option.unwrap
.set_script.unwrap
.build;
// Verify that the `sbatch` command was built properly
assert!;
assert_eq!;
Dependency
For complex dependencies, you can use the Dependency struct to build up a dependency string, which can then be used to create a SbatchOption::Dependency option.
use ;
// Create a new `And` dependency
let mut dependency = new_and;
.push? // Using the DependencyType enum
.push_after_time_delay.unwrap? // Using the helper function
.build?;
assert_eq!;
// Now use the string to create a SbatchOption::Dependency
let sbatch_dependency = Dependency;