-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix script to run examples locally #285
Open
cniethammer
wants to merge
6
commits into
ls1mardyn:master
Choose a base branch
from
cniethammer:fix_local_example_run_script
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
788158f
Fix script to run examples locally
cniethammer ad059f4
Improve run script for local example execution
cniethammer 55b3f3b
Update examples/run-examples.sh
cniethammer f43bf95
Use basename to determine program name
cniethammer a07d2ab
Fix incorrect variable assignments
cniethammer 057f8e5
Comment default arguments that are specific to Open MPI
cniethammer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,19 @@ | ||
#!/bin/bash | ||
# Testscript running validation tests according to GitHub Actions but without comparison to master | ||
# | ||
# Copyright (c) 2023 Simon Homes | ||
# Copyright (c) 2023 Simon Homes | ||
# Copyright (c) 2024 Christoph Niethammer <[email protected]> | ||
# | ||
|
||
repoPath="$PWD/.." # Path to root directory | ||
|
||
export OMP_NUM_THREADS=2 | ||
|
||
inputlist="${repoPath}/examples/example-list.txt" | ||
logfileName="${repoPath}/examples/run-validation.log" | ||
rm -f ${logfileName} | ||
|
||
IFS=$'\n' | ||
for i in $(cat "${repoPath}/examples/example-list.txt" ) | ||
do | ||
# skip if comment or empty line | ||
if [[ $i == \#* || -z "$i" ]] | ||
then | ||
continue | ||
fi | ||
cd ${repoPath}/examples/$(dirname $i) | ||
cd ${repoPath}/examples | ||
./run-examples.sh -v --inputlist "${inputlist}" --logfile "${logfileName}" | ||
|
||
# run the examples | ||
printf "Running example: ${i} ... " | tee -a ${logfileName} | ||
EXE=${repoPath}/build/src/MarDyn | ||
|
||
mpirun --oversubscribe -np 4 ${EXE} $(basename $i) --steps=20 | tee -a ${logfileName} | ||
printf "done\n" | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,146 @@ | ||
#!/bin/bash | ||
# Testscript running all examples from example-list.txt | ||
# | ||
# Copyright (c) 2017 Christoph Niethammer <[email protected]> | ||
# Copyright (c) 2017-2024 Christoph Niethammer <[email protected]> | ||
# | ||
|
||
MARDYN_EXE="mpirun -np 1 $PWD/../src/MarDyn" | ||
MARDYN_OPTIONS="--steps 10 -v" | ||
# Some default values | ||
MARDYN_EXE="$PWD/../src/MarDyn" | ||
MARDYN_ARGS="--steps 20 -v" | ||
MPIRUN_EXE="mpirun" | ||
MPIRUN_ARGS="-n 4 --oversubscribe" | ||
cniethammer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
EXAMPLE_LIST_FILE=${EXAMPLE_LIST_FILE:=example-list.txt} | ||
LOGFILE=${LOGFILE:=$PWD/run-examples.log} | ||
cniethammer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#mapfile -t all_examples < $EXAMPLE_LIST_FILE # requires bash4 ... | ||
declare -a all_examples | ||
while IFS= read -r; do all_examples+=("$REPLY"); done < $EXAMPLE_LIST_FILE | ||
TEMP=$(getopt -o vh --long "help,inputlist:,logfile:,mardyn_args:,mardyn_exe:,mpirun_args:,mpirun_exe:,verbose" -- $@) | ||
cniethammer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if [ $? -ne 0 ]; then | ||
echo "Error parsing commandline" | ||
exit 1 | ||
fi | ||
|
||
eval set -- "$TEMP" | ||
unset TEMP | ||
|
||
function print_help() { | ||
cat <<EOF | ||
$0 is a script to execute MarDyn examples from a inputfile list file | ||
cniethammer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
A inputlist file contains one path per line to a configuration file to be passed to MarDyn. | ||
MarDyn is executed with one configuration file at a time. | ||
In the inputlist file empty lines and lines starting with '#' are ignored. | ||
|
||
Usage: | ||
$0 [OPTIONS ...] | ||
$0 [-h|--help] | ||
|
||
Options: | ||
-i,--inputlist <FILE> path to an inputfile list | ||
--logfile <FILE> path for the logfile | ||
--mpirun_exe <mpirun> mpirun command or path to mpirun executable | ||
--mpirun_args <ARGS> arguments to be passed to the mpirun command | ||
--mardyn_exe <MarDyn> path to a MarDyn executable | ||
--mardyn_args <ARGS> arguments to be passed to MarDyn for each input file | ||
-v,--verbose verbose output | ||
-h,--help show this help | ||
|
||
EOF | ||
} | ||
|
||
while true; do | ||
case "$1" in | ||
'--logfile') | ||
LOGFILE="$2" | ||
shift 2 | ||
continue | ||
;; | ||
'--mardyn_exe') | ||
MARDYN_EXE="$2" | ||
shift 2 | ||
continue | ||
;; | ||
'--mardyn_args') | ||
MARDYN_EXE="$2" | ||
shift 2 | ||
continue | ||
;; | ||
'--mpirun_exe') | ||
MARDYN_EXE="$2" | ||
shift 2 | ||
continue | ||
;; | ||
'--mpirun_args') | ||
MARDYN_EXE="$2" | ||
shift 2 | ||
continue | ||
cniethammer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
;; | ||
'--inputlist') | ||
EXAMPLE_LIST_FILE="$2" | ||
shift 2 | ||
continue | ||
;; | ||
'-v'|'--verbose') | ||
VERBOSE=true | ||
shift | ||
continue | ||
;; | ||
'-h'|'--help') | ||
PRINT_HELP_AND_EXIT=true | ||
shift | ||
break | ||
;; | ||
'--') | ||
shift | ||
break | ||
;; | ||
* ) | ||
echo "ERROR Unknown Option $1" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
if [ $PRINT_HELP_AND_EXIT ]; then | ||
print_help | ||
exit 0 | ||
fi | ||
|
||
|
||
all_examples=() | ||
failed_examples=() | ||
|
||
# definitions for esear color output to display | ||
Color_Off='\e[0m' # Text Reset | ||
IGreen='\e[0;92m' # Intense Green | ||
IRed='\e[0;91m' # Intense Red | ||
IMagenta='\e[0;95m' # magenta | ||
while IFS= read -r line ; do | ||
[[ "$line" =~ ^#.*$ ]] && continue | ||
[[ "$line" =~ ^$ ]] && continue | ||
cniethammer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
example="$line" | ||
if [ $VERBOSE ]; then | ||
echo "Going to run example file $example" | ||
fi | ||
all_examples+=("$example") | ||
done < "$EXAMPLE_LIST_FILE" | ||
|
||
if [ $VERBOSE ]; then | ||
echo "Writing test outputs to $LOGFILE" | ||
fi | ||
|
||
# definitions for easy color output if we are running in a terminal | ||
if [ -t 0 -a -t 1 -a -t 2 ]; then | ||
Color_Off='\e[0m' # Text Reset | ||
IGreen='\e[0;92m' # Intense Green | ||
IRed='\e[0;91m' # Intense Red | ||
IMagenta='\e[0;95m' # magenta | ||
fi | ||
|
||
logfile=$LOGFILE | ||
date > $logfile | ||
for example in ${all_examples[@]} | ||
do | ||
for example in ${all_examples[@]} ; do | ||
example_dir=$(dirname $example) | ||
example_inp_file=$(basename $example) | ||
echo -e -n "Running example ${IMagenta}$example_inp_file${Color_Off} in $example_dir ... " | ||
echo -e -n "Running example ${IMagenta}$example_inp_file${Color_Off} in ${IMagenta}$example_dir${Color_Off} ... " | ||
echo "Running example $example_inp_file in $example_dir" >> $logfile | ||
pushd "$example_dir" >/dev/null | ||
cmd="$MARDYN_EXE $MARDYN_OPTIONS $example_inp_file" | ||
cmd="$MPIRUN_EXE $MPIRUN_ARGS $MARDYN_EXE $MARDYN_ARGS $example_inp_file" | ||
echo $cmd >>$logfile | ||
{ $cmd ; } >>$logfile 2>&1 | ||
ret=$? | ||
|
@@ -43,6 +153,7 @@ do | |
echo "Running example $example_inp_file in $example_dir ... Result: failed" >> $logfile | ||
fi | ||
popd >/dev/null | ||
sleep 1 # sleep for 1 second to make cancelation with CTR-C easier | ||
done | ||
|
||
echo "----------------------------------------" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also use the options
--{mardyn,mpirun}_{exe,args}
here. Or we could just get rid of the entire file since its use case is already covered by the default settings ofrun-examples.sh
, isn't it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I could not find any use case inside the codebase/workflows so I would get rid of the validation.sh script then.