Skip to content

Commit

Permalink
All current tests pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
joaander committed May 13, 2024
1 parent f28ed09 commit da0e8c5
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 78 deletions.
8 changes: 4 additions & 4 deletions src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ mod tests {
let partition = Partition::default();

let resources = Resources {
processes: Processes::PerDirectory(1),
processes: Some(Processes::PerDirectory(1)),
threads_per_process: Some(2),
gpus_per_process: Some(3),
..Resources::default()
Expand All @@ -461,7 +461,7 @@ mod tests {
setup();

let resources = Resources {
processes: Processes::PerDirectory(1),
processes: Some(Processes::PerDirectory(1)),
threads_per_process: Some(2),
gpus_per_process: Some(3),
..Resources::default()
Expand Down Expand Up @@ -564,12 +564,12 @@ mod tests {
};

let cpu_resources = Resources {
processes: Processes::PerDirectory(1),
processes: Some(Processes::PerDirectory(1)),
..Resources::default()
};

let gpu_resources = Resources {
processes: Processes::PerDirectory(1),
processes: Some(Processes::PerDirectory(1)),
gpus_per_process: Some(1),
..Resources::default()
};
Expand Down
3 changes: 3 additions & 0 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ pub(crate) fn evaluate_json_comparison(
(_, None) => None,
(_, _) => Some(false),
}

// TODO: Greater than or equal to
// TODO: Less than or equal to
}

#[cfg(test)]
Expand Down
8 changes: 4 additions & 4 deletions src/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,14 @@ mod tests {
assert_eq!(mpi.prefix(&one_proc, 1), "mpirun -n 1 ");

let procs_per_directory = Resources {
processes: Processes::PerDirectory(2),
processes: Some(Processes::PerDirectory(2)),
..Resources::default()
};
assert_eq!(mpi.prefix(&procs_per_directory, 11), "mpirun -n 22 ");
assert_eq!(mpi.prefix(&procs_per_directory, 1), "mpirun -n 2 ");

let all = Resources {
processes: Processes::PerDirectory(6),
processes: Some(Processes::PerDirectory(6)),
threads_per_process: Some(3),
gpus_per_process: Some(8),
..Resources::default()
Expand All @@ -297,14 +297,14 @@ mod tests {
assert_eq!(mpi.prefix(&one_proc, 1), "srun --ntasks=1 ");

let procs_per_directory = Resources {
processes: Processes::PerDirectory(2),
processes: Some(Processes::PerDirectory(2)),
..Resources::default()
};
assert_eq!(mpi.prefix(&procs_per_directory, 11), "srun --ntasks=22 ");
assert_eq!(mpi.prefix(&procs_per_directory, 1), "srun --ntasks=2 ");

let all = Resources {
processes: Processes::PerDirectory(6),
processes: Some(Processes::PerDirectory(6)),
threads_per_process: Some(3),
gpus_per_process: Some(8),
..Resources::default()
Expand Down
24 changes: 12 additions & 12 deletions src/scheduler/bash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,18 +318,18 @@ mod tests {

fn setup() -> (Action, Vec<PathBuf>, HashMap<String, Launcher>) {
let resources = Resources {
processes: Processes::PerDirectory(2),
processes: Some(Processes::PerDirectory(2)),
threads_per_process: Some(4),
gpus_per_process: Some(1),
walltime: Walltime::PerSubmission(
Duration::new(true, 0, 240, 0).expect("Valid duration."),
walltime: Some(Walltime::PerSubmission(
Duration::new(true, 0, 240, 0).expect("Valid duration.")),
),
};

let action = Action {
name: Some("action".to_string()),
command: Some("command {directory}".to_string()),
launchers: vec!["mpi".into()],
launchers: Some(vec!["mpi".into()]),
resources,
..Action::default()
};
Expand Down Expand Up @@ -429,8 +429,8 @@ mod tests {
#[parallel]
fn execution_openmp() {
let (mut action, directories, launchers) = setup();
action.resources.processes = Processes::PerSubmission(1);
action.launchers = vec!["openmp".into()];
action.resources.processes = Some(Processes::PerSubmission(1));
action.launchers = Some(vec!["openmp".into()]);
action.command = Some("command {directories}".to_string());

let script = BashScriptBuilder::new("cluster", &action, &directories, &launchers)
Expand All @@ -445,7 +445,7 @@ mod tests {
#[parallel]
fn execution_mpi() {
let (mut action, directories, launchers) = setup();
action.launchers = vec!["mpi".into()];
action.launchers = Some(vec!["mpi".into()]);
action.command = Some("command {directories}".to_string());

let script = BashScriptBuilder::new("cluster", &action, &directories, &launchers)
Expand Down Expand Up @@ -504,9 +504,9 @@ mod tests {
#[parallel]
fn more_variables() {
let (mut action, directories, launchers) = setup();
action.resources.processes = Processes::PerSubmission(10);
action.resources.processes = Some(Processes::PerSubmission(10));
action.resources.walltime =
Walltime::PerDirectory(Duration::new(true, 0, 60, 0).expect("Valid duration."));
Some(Walltime::PerDirectory(Duration::new(true, 0, 60, 0).expect("Valid duration.")));
action.resources.threads_per_process = None;
action.resources.gpus_per_process = None;

Expand Down Expand Up @@ -547,7 +547,7 @@ mod tests {
#[parallel]
fn launcher_required() {
let (mut action, directories, launchers) = setup();
action.launchers = vec![];
action.launchers = Some(vec![]);
action.command = Some("command {directories}".to_string());

let result = BashScriptBuilder::new("cluster", &action, &directories, &launchers).build();
Expand All @@ -559,8 +559,8 @@ mod tests {
#[parallel]
fn too_many_launchers() {
let (mut action, directories, launchers) = setup();
action.resources.processes = Processes::PerSubmission(1);
action.launchers = vec!["mpi".into(), "mpi".into()];
action.resources.processes = Some(Processes::PerSubmission(1));
action.launchers = Some(vec!["mpi".into(), "mpi".into()]);
action.command = Some("command {directories}".to_string());

let result = BashScriptBuilder::new("cluster", &action, &directories, &launchers).build();
Expand Down
8 changes: 4 additions & 4 deletions src/scheduler/slurm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ mod tests {
let action = Action {
name: Some("action".to_string()),
command: Some("command {directory}".to_string()),
launchers: vec!["mpi".into()],
launchers: Some(vec!["mpi".into()]),
..Action::default()
};

Expand Down Expand Up @@ -328,7 +328,7 @@ mod tests {
fn ntasks() {
let (mut action, directories, slurm) = setup();

action.resources.processes = Processes::PerDirectory(3);
action.resources.processes = Some(Processes::PerDirectory(3));

let script = slurm
.make_script(&action, &directories)
Expand Down Expand Up @@ -483,7 +483,7 @@ mod tests {

let slurm = Slurm::new(cluster, launchers.by_cluster("cluster"));

action.resources.processes = Processes::PerSubmission(81);
action.resources.processes = Some(Processes::PerSubmission(81));

let script = slurm
.make_script(&action, &directories)
Expand Down Expand Up @@ -511,7 +511,7 @@ mod tests {

let slurm = Slurm::new(cluster, launchers.by_cluster("cluster"));

action.resources.processes = Processes::PerSubmission(81);
action.resources.processes = Some(Processes::PerSubmission(81));
action.resources.gpus_per_process = Some(1);

let script = slurm
Expand Down
Loading

0 comments on commit da0e8c5

Please sign in to comment.