diff --git a/bootstrap.sh b/bootstrap.sh index 8a905a9..1b4f326 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,24 +1,34 @@ #!/bin/bash +# Set Timezone (needed for python install) +ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + # Updates the package lists for upgrades and new package installations -sudo apt-get update +apt-get update +apt-get install sudo -y +apt-get install wget -y +sudo apt install -y software-properties-common cmake git -# Installs the 'sudo' package. The '-y' flag automatically answers yes to prompts. -apt-get install -y sudo python3.9 +# Installs the python 3.9 package. The '-y' flag automatically answers yes to prompts. +sudo add-apt-repository ppa:deadsnakes/ppa -y +sudo apt update +sudo apt install python3.9 -y +sudo apt install python3.9-distutils -y -# Install the needed packages -sudo apt install -y software-properties-common cmake python3-pip git +# Install pip +wget https://bootstrap.pypa.io/get-pip.py +python3.9 get-pip.py # Upgrades pip (Python package installer) to the latest version -sudo python3 -m pip install -U pip +sudo python3.9 -m pip install -U pip # Installs the Conan package manager -pip3 install conan==1.60.1 -pip3 install nheri-simcenter +python3.9 -m pip install conan==1.60.1 +python3.9 -m pip install nheri-simcenter -python3 --version +python3.9 --version -which python3 +which python3.9 which conan diff --git a/build_backend_apps.sh b/build_backend_apps.sh index 2fe2e68..5efc53c 100644 --- a/build_backend_apps.sh +++ b/build_backend_apps.sh @@ -1,6 +1,6 @@ #!/bin/bash -git clone --branch master --depth 1 https://github.com/NHERI-SimCenter/SimCenterBackendApplications.git +git clone --branch master https://github.com/NHERI-SimCenter/SimCenterBackendApplications.git cp ./SimCenterBackendApplications/modules/performUQ/SimCenterUQ/nataf_gsa/CMakeLists.txt.UBUNTU ./SimCenterBackendApplications/modules/performUQ/SimCenterUQ/nataf_gsa/CMakeLists.txt diff --git a/run_examples.sh b/run_examples.sh index a1c1134..6cc03f6 100644 --- a/run_examples.sh +++ b/run_examples.sh @@ -3,29 +3,90 @@ echo In folder $PWD # Clone the examples -git clone --branch master --depth 1 https://github.com/NHERI-SimCenter/quoFEM.git +git clone --depth 1 https://github.com/NHERI-SimCenter/quoFEM.git -# Create the working directoy -mkdir tmp.SimCenter -mkdir tmp.SimCenter/templatedir -cp -a $PWD/Examples/qfem-0001/src/. $PWD/tmp.SimCenter/templatedir/ +# make sure all packages are installed +python3 -m pip install --upgrade pip +python3 -m pip install nheri-simcenter --upgrade +python3 -m pip install GPy==1.13.2 -sudo apt-get install jq +# Read JSON from file +json_file="$PWD/quoFEM/Examples/Examples.json" -inputfile=$PWD/Examples/qfem-0001/src/input.json +# Install jq +sudo apt-get install -y jq +rm -rf cache +mkdir cache +# Iterate over array elements +jq -c '.Examples[]' "$json_file" | while read -r example; do -echo "doing jq =================" -echo $(cat $inputfile | jq '. + { "runDir": "'"$PWD/tmp.SimCenter"'" }') > $inputfile -echo $(cat $inputfile | jq '. + { "localAppDir": "'"$PWD/SimCenterBackendApplications"'" }') > $inputfile -echo $(cat $inputfile | jq '. + { "remoteAppDir": "'"$PWD/SimCenterBackendApplications"'" }') > $inputfile -echo $(cat $inputfile | jq '. + { "runType": "runningLocal" }') > $inputfile -echo "did jq ===================" + name=$(echo "$example" | jq -r '.name') + description=$(echo "$example" | jq -r '.description') + inputfile=$(echo "$example" | jq -r '.inputFile') + + inputfile="$PWD/quoFEM/Examples/$inputfile" + srcDir="$(dirname $inputfile)" + examplenumber="$(dirname $srcDir)" + examplenumber="$(basename $examplenumber)" -echo "catting the thing now ===================" -cat $inputfile + echo "===========================================" + echo "Example Number: $examplenumber" + echo "Example Name: $name" + echo "Example Description: $description" + echo "Input File: $inputfile" + echo "srcDir: $srcDir" + echo "---------------------------" + echo "Adding json params to input file..." + echo $(cat $inputfile | jq '. + { "runDir": "'"$PWD/tmp.SimCenter"'" }') > $inputfile + echo $(cat $inputfile | jq '. + { "localAppDir": "'"$PWD/SimCenterBackendApplications"'" }') > $inputfile + echo $(cat $inputfile | jq '. + { "remoteAppDir": "'"$PWD/SimCenterBackendApplications"'" }') > $inputfile + echo $(cat $inputfile | jq '. + { "runType": "runningLocal" }') > $inputfile + + echo "copying files" + rm -rf tmp.SimCenter + mkdir tmp.SimCenter + mkdir tmp.SimCenter/templatedir + + cp -a $srcDir/. $PWD/tmp.SimCenter/templatedir/ -ls $PWD/tmp.SimCenter/templatedir + if [[ "$examplenumber" == "qfem-0027" ]]; then + # do some stuff + cp -a $srcDir/model1/. $PWD/tmp.SimCenter/templatedir/ + cp -a $srcDir/model2/. $PWD/tmp.SimCenter/templatedir/ + fi + if [[ "$examplenumber" == "qfem-0028" ]]; then + # do some stuff + echo "CAUGHT EXAMPLE 28" + echo "$srcDir" + cp -a "$srcDir/CouponCyclicTestData_every_20th_point/." "$PWD/tmp.SimCenter/templatedir/" + fi -# Run the example in the backend -python $PWD/SimCenterBackendApplications/applications/Workflow/qWHALE.py "runningLocal" $inputfile $PWD/SimCenterBackendApplications/applications/Workflow/WorkflowApplications.json + + #echo "Input file contents:" + #python3 -m json.tool $inputfile + + #echo "Template dir contents" + #ls $PWD/tmp.SimCenter/templatedir + + # Run the example in the backend + echo "Running python:" + echo "===============" + python3 $PWD/SimCenterBackendApplications/applications/Workflow/qWHALE.py "runningLocal" $inputfile $PWD/SimCenterBackendApplications/applications/Workflow/WorkflowApplications.json + mkdir "cache/tmp.SimCenter.$examplenumber/" + cp -r tmp.SimCenter/. "cache/tmp.SimCenter.$examplenumber/" +done + +# Check with archives have a dakotaTab.out file +echo "" +echo "" +echo "======================================" +for dir in $PWD/cache/*; do + if [ -f "$dir/dakotaTab.out" ]; then + echo "$dir: PASS" + # Do something if the file exists + else + echo "$dir: FAIL" + # Do something else if the file does not exist + fi +done \ No newline at end of file