Skip to content

Commit 86b7d7c

Browse files
authored
Merge pull request #905 from EnergySystemsModellingLab/add-no-debug-model-option
Fix `regenerate_all_data.sh` script when user has set `debug_model = true`
2 parents 21b4efa + 3068b6f commit 86b7d7c

4 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/cli.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ pub struct RunOpts {
3636
#[arg(long)]
3737
pub overwrite: bool,
3838
/// Whether to write additional information to CSV files
39-
#[arg(long)]
40-
pub debug_model: bool,
39+
#[arg(long, value_name = "BOOL", num_args = 0..=1, default_missing_value = "true")]
40+
pub debug_model: Option<bool>,
4141
}
4242

4343
/// The available commands.
@@ -116,8 +116,8 @@ pub fn handle_run_command(
116116
};
117117

118118
// These settings can be overridden by command-line arguments
119-
if opts.debug_model {
120-
settings.debug_model = true;
119+
if let Some(opt) = opts.debug_model {
120+
settings.debug_model = opt;
121121
}
122122
if opts.overwrite {
123123
settings.overwrite = true;

tests/regenerate_all_data.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
#!/bin/sh
2+
set -euf
23

34
mydir=$(dirname "$0")
45
cd "$mydir"
56

6-
echo Cleaning output folder
7-
rm -rf data/*
8-
97
echo Building MUSE2
108
examples=$(cargo run example list 2> /dev/null)
119

1210
for example in $examples; do
1311
echo Generating data for example: $example
1412

1513
# We only need debug files for the simple model
16-
unset extra_args
14+
extra_args=--overwrite
1715
if [ $example = simple ]; then
18-
extra_args=--debug-model
16+
extra_args+=" --debug-model"
17+
else
18+
extra_args+=" --debug-model=false"
1919
fi
2020

2121
env MUSE2_LOG_LEVEL=off cargo run example run $extra_args -o "data/$example" "$example" 2> /dev/null

tests/regression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn run_regression_test_debug_opt(example_name: &str, debug_model: bool) {
4343
let opts = RunOpts {
4444
output_dir: Some(output_dir.clone()),
4545
overwrite: false,
46-
debug_model: true, // NB: Always enable this as it helps to have the files for debugging
46+
debug_model: Some(true), // NB: Always enable this as it helps to have the files for debugging
4747
};
4848
handle_example_run_command(example_name, &opts, Some(Settings::default())).unwrap();
4949

tests/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn test_handle_run_command() {
2525
let opts = RunOpts {
2626
output_dir: Some(output_dir),
2727
overwrite: false,
28-
debug_model: false,
28+
debug_model: None,
2929
};
3030
handle_run_command(&get_model_dir(), &opts, Some(Settings::default())).unwrap();
3131

0 commit comments

Comments
 (0)