From 37797cd83c9733fe7f5e00517e5c9c7a9a8aa8b1 Mon Sep 17 00:00:00 2001 From: Noam Elisha <noam.elisha@berkeley.edu> Date: Wed, 18 Dec 2024 11:51:17 -0800 Subject: [PATCH 01/13] add testing infra --- pbe_input_cleaner.py | 12 +++++++ run_examples.sh | 84 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 pbe_input_cleaner.py create mode 100644 run_examples.sh diff --git a/pbe_input_cleaner.py b/pbe_input_cleaner.py new file mode 100644 index 0000000..2294521 --- /dev/null +++ b/pbe_input_cleaner.py @@ -0,0 +1,12 @@ +import sys + +if __name__ == "__main__": + path = sys.argv[1] + text = None + with open(path, "r") as f: + text = f.read() + + text = text.replace("{Current_Dir}", "templatedir") + + with open(path, "w") as f: + f.write(text) \ No newline at end of file diff --git a/run_examples.sh b/run_examples.sh new file mode 100644 index 0000000..df9d5b5 --- /dev/null +++ b/run_examples.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +echo In folder $PWD + +# Clone the examples +git clone --branch master https://github.com/NHERI-SimCenter/PBE.git + +# 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 + +# Read JSON from file +json_file="$PWD/PBE/Examples/Examples.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 + + name=$(echo "$example" | jq -r '.name') + description=$(echo "$example" | jq -r '.description') + inputfile=$(echo "$example" | jq -r '.inputFile') + + inputfile="$PWD/PBE/Examples/$inputfile" + srcDir="$(dirname $inputfile)" + examplenumber="$(dirname $srcDir)" + examplenumber="$(basename $examplenumber)" + + echo "===========================================" + echo "Example Number: $examplenumber" + echo "Example Name: $name" + echo "Example Description: $description" + echo "Input File: $inputfile" + echo "srcDir: $srcDir" + echo "---------------------------" + # Change {Current_Dir} in input to templatedir + python3 pbe_input_cleaner.py $inputfile + + # Add JSON Arguments to input + 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/ + + + + #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/sWHALE.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 From 19cc3b08d8d61f4fb33f72d60874a07c61affcf5 Mon Sep 17 00:00:00 2001 From: Noam-Elisha <67216690+Noam-Elisha@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:54:04 -0800 Subject: [PATCH 02/13] Create main.yml --- .github/workflows/main.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..fe8c505 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,29 @@ +name: Run quoFEM tests + +on: push + # workflow_dispatch: + # schedule: + # - cron: "0 5 * * *" + +jobs: + setup_and_test: + name: Setup and run tests + runs-on: ubuntu-latest + environment: quoFEM + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Bootstrap + run: | + chmod +x bootstrap.sh + sh ./bootstrap.sh + - name: Build SimCenter Applications + run: | + chmod +x build_backend_apps.sh + sh ./build_backend_apps.sh + - name: Run Examples + run: | + chmod +x run_examples.sh + sh ./run_examples.sh From f0403487c9d4c43ec3f98cbaf3f73100e529c361 Mon Sep 17 00:00:00 2001 From: Noam Elisha <noam.elisha@berkeley.edu> Date: Wed, 18 Dec 2024 11:54:45 -0800 Subject: [PATCH 03/13] added build backend for actions --- bootstrap.sh | 67 +++++++++++++++++++++++++++++++++++++++++++ build_backend_apps.sh | 37 ++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 bootstrap.sh create mode 100644 build_backend_apps.sh diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100644 index 0000000..207e448 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,67 @@ +#!/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 +apt-get update +apt-get install sudo -y +apt-get install wget -y +sudo apt install -y software-properties-common cmake git + +# 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 python3.9-dev python3.9-venv python3.9-distutils -y + +# 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.9 -m pip install -U pip + +# Installs the Conan package manager +python3.9 -m pip install conan==1.60.1 +python3.9 -m pip install nheri-simcenter + +python3.9 --version + +sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9.20 +sudo update-alternatives --install /usr/bin/python python3 /usr/bin/python3.9.20 +sudo update-alternatives --config python + +which python3 + +which conan + +wget https://github.com/snl-dakota/dakota/releases/download/v6.15.0/dakota-6.15.0-public-src-cli.tar.gz +sudo apt-get install -y cmake libboost-dev libboost-all-dev libopenmpi-dev openmpi-bin xorg-dev libmotif-dev libblas-dev liblapack-dev g++ +tar zxBf dakota-6.15.0-public-src-cli.tar.gz +mv dakota-6.15.0-public-src-cli dakota-6.15.0 +cd dakota-6.15.0 +mkdir build; cd build +cmake .. +make -j 16 +cd ../.. +export PATH=/quoFEM/dakota-6.15.0/build/src:$PATH +alias python3=python3.9 + +sudo apt-get install -y cmake liblapack-dev libomp-dev libssl-dev apt-transport-https ca-certificates wget +wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null +sudo apt-add-repository -y "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" +sudo apt-get update +sudo apt-get install -y cmake gfortran gcc g++ +git clone -b v3.7.0 --single-branch https://github.com/OpenSees/OpenSees.git +cd OpenSees +mkdir build; cd build +conan install .. --build missing +cmake .. +cmake --build . --config Release +cmake --install . +sudo mv ./lib/* /usr/local/lib +cd ../.. + + +echo 'export PATH=$PATH:/usr/local/OpenSees/bin:/usr/local/Dakota/bin' +source ~/.profile \ No newline at end of file diff --git a/build_backend_apps.sh b/build_backend_apps.sh new file mode 100644 index 0000000..2b7e135 --- /dev/null +++ b/build_backend_apps.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +git clone --depth 1 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 + +rm -fr ~/.conan + +sudo apt-get install -y liblapack-dev libomp-dev libssl-dev apt-transport-https ca-certificates \ + +sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + +sudo apt-get update + +sudo apt-get install -y gcc-11 g++-11 gfortran-11 + +export CC=gcc-11 + +export CXX=g++-11 + +export FC=gfortran-11 + +cd SimCenterBackendApplications + +mkdir build + +cd build + +conan install .. --build missing + +cmake .. + +cmake --build . --config Release + +cmake --install . + +cd ../.. From 3ecb8bd8785d45d980526d741c890d40329ecc47 Mon Sep 17 00:00:00 2001 From: Noam-Elisha <67216690+Noam-Elisha@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:55:37 -0800 Subject: [PATCH 04/13] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fe8c505..7bf0d26 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Run quoFEM tests +name: Run PBE tests on: push # workflow_dispatch: @@ -9,7 +9,7 @@ jobs: setup_and_test: name: Setup and run tests runs-on: ubuntu-latest - environment: quoFEM + environment: PBE steps: - name: Checkout From 91f08125a58f6b593978af8daee9439d8c2154b3 Mon Sep 17 00:00:00 2001 From: Noam-Elisha <67216690+Noam-Elisha@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:52:34 -0800 Subject: [PATCH 05/13] Update bootstrap.sh --- bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.sh b/bootstrap.sh index 207e448..8f29367 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -64,4 +64,4 @@ cd ../.. echo 'export PATH=$PATH:/usr/local/OpenSees/bin:/usr/local/Dakota/bin' -source ~/.profile \ No newline at end of file +~/.profile From 8af4f954392ae5b635da0d6dce981e9e7defd898 Mon Sep 17 00:00:00 2001 From: Noam-Elisha <67216690+Noam-Elisha@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:25:34 -0800 Subject: [PATCH 06/13] Update bootstrap.sh --- bootstrap.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bootstrap.sh b/bootstrap.sh index 8f29367..eba31b9 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,5 +1,9 @@ #!/bin/bash +echo 'export PATH=$PATH:/usr/local/OpenSees/bin:/usr/local/Dakota/bin' +sudo sh ~/.profile + + # Set Timezone (needed for python install) ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone From 09a0326eba2ecb4f852a80284cf9a6d180c6f8d5 Mon Sep 17 00:00:00 2001 From: Noam-Elisha <67216690+Noam-Elisha@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:26:47 -0800 Subject: [PATCH 07/13] Update bootstrap.sh --- bootstrap.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index eba31b9..271c277 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,11 +1,7 @@ #!/bin/bash -echo 'export PATH=$PATH:/usr/local/OpenSees/bin:/usr/local/Dakota/bin' -sudo sh ~/.profile - - # Set Timezone (needed for python install) -ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # Updates the package lists for upgrades and new package installations apt-get update @@ -68,4 +64,4 @@ cd ../.. echo 'export PATH=$PATH:/usr/local/OpenSees/bin:/usr/local/Dakota/bin' -~/.profile +sudo sh ~/.profile From 263cf5238823c04400e28e2db2e9d93bb9d9bea4 Mon Sep 17 00:00:00 2001 From: Noam-Elisha <67216690+Noam-Elisha@users.noreply.github.com> Date: Wed, 18 Dec 2024 14:09:25 -0800 Subject: [PATCH 08/13] Update run_examples.sh --- run_examples.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/run_examples.sh b/run_examples.sh index df9d5b5..15d2cc1 100644 --- a/run_examples.sh +++ b/run_examples.sh @@ -1,5 +1,7 @@ #!/bin/bash + +export PATH=$PATH:/usr/local/OpenSees/bin:/usr/local/Dakota/bin echo In folder $PWD # Clone the examples @@ -81,4 +83,4 @@ for dir in $PWD/cache/*; do echo "$dir: FAIL" # Do something else if the file does not exist fi -done \ No newline at end of file +done From 69a97449c3733901651ed2102ce0008057daca88 Mon Sep 17 00:00:00 2001 From: Noam-Elisha <67216690+Noam-Elisha@users.noreply.github.com> Date: Wed, 18 Dec 2024 14:09:51 -0800 Subject: [PATCH 09/13] Update bootstrap.sh --- bootstrap.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index 271c277..fa6d4cd 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -62,6 +62,5 @@ cmake --install . sudo mv ./lib/* /usr/local/lib cd ../.. - -echo 'export PATH=$PATH:/usr/local/OpenSees/bin:/usr/local/Dakota/bin' +export PATH=$PATH:/usr/local/OpenSees/bin:/usr/local/Dakota/bin sudo sh ~/.profile From 2f41781f47f659eab08f957a40dedfb00005ee1e Mon Sep 17 00:00:00 2001 From: Noam-Elisha <67216690+Noam-Elisha@users.noreply.github.com> Date: Wed, 18 Dec 2024 14:10:23 -0800 Subject: [PATCH 10/13] Update run_examples.sh --- run_examples.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_examples.sh b/run_examples.sh index 15d2cc1..8de5a61 100644 --- a/run_examples.sh +++ b/run_examples.sh @@ -1,7 +1,7 @@ #!/bin/bash -export PATH=$PATH:/usr/local/OpenSees/bin:/usr/local/Dakota/bin +#export PATH=$PATH:/usr/local/OpenSees/bin:/usr/local/Dakota/bin echo In folder $PWD # Clone the examples From 1d2e7fa6a77087f88dadea5b37df286df7fc77e6 Mon Sep 17 00:00:00 2001 From: Noam-Elisha <67216690+Noam-Elisha@users.noreply.github.com> Date: Wed, 18 Dec 2024 14:48:01 -0800 Subject: [PATCH 11/13] Update run_examples.sh --- run_examples.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_examples.sh b/run_examples.sh index 8de5a61..15d2cc1 100644 --- a/run_examples.sh +++ b/run_examples.sh @@ -1,7 +1,7 @@ #!/bin/bash -#export PATH=$PATH:/usr/local/OpenSees/bin:/usr/local/Dakota/bin +export PATH=$PATH:/usr/local/OpenSees/bin:/usr/local/Dakota/bin echo In folder $PWD # Clone the examples From d09c5569a2662e83aad575aaa221bc0feeba6fa6 Mon Sep 17 00:00:00 2001 From: Noam-Elisha <67216690+Noam-Elisha@users.noreply.github.com> Date: Wed, 18 Dec 2024 17:00:01 -0800 Subject: [PATCH 12/13] Update bootstrap.sh --- bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.sh b/bootstrap.sh index fa6d4cd..d673c43 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -44,7 +44,7 @@ mkdir build; cd build cmake .. make -j 16 cd ../.. -export PATH=/quoFEM/dakota-6.15.0/build/src:$PATH +export PATH=/$PWD/dakota-6.15.0/build/src:$PATH alias python3=python3.9 sudo apt-get install -y cmake liblapack-dev libomp-dev libssl-dev apt-transport-https ca-certificates wget From 75235d0280f929bae5395b6d9b2e493cdcbef075 Mon Sep 17 00:00:00 2001 From: Noam-Elisha <67216690+Noam-Elisha@users.noreply.github.com> Date: Wed, 18 Dec 2024 17:00:24 -0800 Subject: [PATCH 13/13] Update bootstrap.sh --- bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.sh b/bootstrap.sh index d673c43..105258c 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -44,7 +44,7 @@ mkdir build; cd build cmake .. make -j 16 cd ../.. -export PATH=/$PWD/dakota-6.15.0/build/src:$PATH +export PATH=$PWD/dakota-6.15.0/build/src:$PATH alias python3=python3.9 sudo apt-get install -y cmake liblapack-dev libomp-dev libssl-dev apt-transport-https ca-certificates wget