Skip to content

Commit

Permalink
Don't allow SLURML scheduler to be used together with mode=batch (#125
Browse files Browse the repository at this point in the history
)

* update development files

* fix bug in `ValidateExecutionModes`

* update `TestValidateExecutionModes`
  • Loading branch information
rvhonorato authored Aug 28, 2024
1 parent 3d1b806 commit 9dde5c4
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions example/example_haddock30.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ scenarios:
topoaa:
autohis: true
rigidbody:
sampling: 2
sampling: 5
cmrest: true

- name: random-restraints
Expand All @@ -64,7 +64,7 @@ scenarios:
topoaa:
autohis: true
rigidbody:
sampling: 2
sampling: 5
ranair: true

#-----------------------------------------------
6 changes: 3 additions & 3 deletions input/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
35 changes: 34 additions & 1 deletion input/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ func TestValidateExecutionModes(t *testing.T) {

type fields struct {
General GeneralStruct
Slurm SlurmParams
Scenarios []Scenario
}
tests := []struct {
Expand All @@ -688,6 +689,9 @@ func TestValidateExecutionModes(t *testing.T) {
General: GeneralStruct{
HaddockDir: haddock3Dir,
},
Slurm: SlurmParams{
Cpus_per_task: 42,
},
Scenarios: []Scenario{
{
Name: "true-interface",
Expand All @@ -707,6 +711,9 @@ func TestValidateExecutionModes(t *testing.T) {
General: GeneralStruct{
HaddockDir: haddock2Dir,
},
Slurm: SlurmParams{
Cpus_per_task: 42,
},
Scenarios: []Scenario{},
},
wantErr: true,
Expand All @@ -717,24 +724,50 @@ 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",
},
},
},
},
},
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)
Expand Down

0 comments on commit 9dde5c4

Please sign in to comment.