From 9dde5c4bb3cf26925ec58de36e0c52c31777f27a Mon Sep 17 00:00:00 2001 From: Rodrigo Vargas Honorato Date: Wed, 28 Aug 2024 16:22:31 +0200 Subject: [PATCH] Don't allow SLURML scheduler to be used together with `mode=batch` (#125) * update development files * fix bug in `ValidateExecutionModes` * update `TestValidateExecutionModes` --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 1 - example/example_haddock30.yml | 4 ++-- input/input.go | 6 +++--- input/input_test.go | 35 ++++++++++++++++++++++++++++++++- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 365d66d..ca59f88 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -32,7 +32,7 @@ RUN groupadd --gid $USER_GID $USERNAME \ #============================================================================================== # Install miniconda ENV CONDA_DIR /opt/conda -RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh \ +RUN wget --quiet --no-check-certificate https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh \ && /bin/bash ~/miniconda.sh -b -p /opt/conda ENV PATH=$CONDA_DIR/bin:$PATH diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1db92e2..4cba2b1 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,7 +3,6 @@ "dockerfile": "Dockerfile", }, "features": { - "ghcr.io/devcontainers/features/go:1": {}, "ghcr.io/devcontainers/features/git:1": {}, }, "postCreateCommand": "sudo bash /app/start.sh", diff --git a/example/example_haddock30.yml b/example/example_haddock30.yml index 27c1247..d0bcfaf 100644 --- a/example/example_haddock30.yml +++ b/example/example_haddock30.yml @@ -50,7 +50,7 @@ scenarios: topoaa: autohis: true rigidbody: - sampling: 2 + sampling: 5 cmrest: true - name: random-restraints @@ -64,7 +64,7 @@ scenarios: topoaa: autohis: true rigidbody: - sampling: 2 + sampling: 5 ranair: true #----------------------------------------------- diff --git a/input/input.go b/input/input.go index 26c3247..c02b579 100644 --- a/input/input.go +++ b/input/input.go @@ -226,16 +226,16 @@ func ValidateRunCNSParams(known map[string]interface{}, params map[string]interf // ValidateExecutionModes checks if the execution modes are valid func (inp *Input) ValidateExecutionModes() error { - if inp.Slurm == (SlurmParams{}) { + if inp.Slurm != (SlurmParams{}) { // Check if the executable is HADDOCK3 if utils.IsHaddock24(inp.General.HaddockDir) { - err := errors.New("cannot use `use_slurm` with HADDOCK2") + err := errors.New("cannot use SLURM with HADDOCK2") return err } else if utils.IsHaddock3(inp.General.HaddockDir) { // We need to check if the Scenarios are using the correct execution modes for _, scenario := range inp.Scenarios { if scenario.Parameters.General["mode"] != "local" { - err := errors.New("cannot use `use_slurm` with `mode: " + scenario.Parameters.General["mode"].(string) + "`") + err := errors.New("SLURM can only be used with `mode: local`") return err } } diff --git a/input/input_test.go b/input/input_test.go index fc562d0..aea8e8b 100644 --- a/input/input_test.go +++ b/input/input_test.go @@ -675,6 +675,7 @@ func TestValidateExecutionModes(t *testing.T) { type fields struct { General GeneralStruct + Slurm SlurmParams Scenarios []Scenario } tests := []struct { @@ -688,6 +689,9 @@ func TestValidateExecutionModes(t *testing.T) { General: GeneralStruct{ HaddockDir: haddock3Dir, }, + Slurm: SlurmParams{ + Cpus_per_task: 42, + }, Scenarios: []Scenario{ { Name: "true-interface", @@ -707,6 +711,9 @@ func TestValidateExecutionModes(t *testing.T) { General: GeneralStruct{ HaddockDir: haddock2Dir, }, + Slurm: SlurmParams{ + Cpus_per_task: 42, + }, Scenarios: []Scenario{}, }, wantErr: true, @@ -717,12 +724,15 @@ func TestValidateExecutionModes(t *testing.T) { General: GeneralStruct{ HaddockDir: haddock3Dir, }, + Slurm: SlurmParams{ + Cpus_per_task: 42, + }, Scenarios: []Scenario{ { Name: "true-interface", Parameters: ParametersStruct{ General: map[string]any{ - "mode": "anything", + "mode": "batch", }, }, }, @@ -730,11 +740,34 @@ func TestValidateExecutionModes(t *testing.T) { }, wantErr: true, }, + { + name: "valid-haddock3", + fields: fields{ + General: GeneralStruct{ + HaddockDir: haddock3Dir, + }, + Slurm: SlurmParams{ + Cpus_per_task: 42, + }, + Scenarios: []Scenario{ + { + Name: "true-interface", + Parameters: ParametersStruct{ + General: map[string]any{ + "mode": "local", + }, + }, + }, + }, + }, + wantErr: false, + }, } for _, tt := range tests { inp := &Input{ General: tt.fields.General, Scenarios: tt.fields.Scenarios, + Slurm: tt.fields.Slurm, } if err := inp.ValidateExecutionModes(); (err != nil) != tt.wantErr { t.Errorf("Input.ValidateExecutionModes() error = %v, wantErr %v", err, tt.wantErr)