From 20593006d22000c05e309baa54fe73cf2fbecb6f Mon Sep 17 00:00:00 2001 From: Garrett Edmonds Date: Fri, 30 Aug 2024 16:32:59 -0500 Subject: [PATCH 1/4] SimCenter DesignSafe VM v0.0.1 --- .../simcenter-designsafe-vm/Dockerfile | 33 ++++++ applications/simcenter-designsafe-vm/app.json | 100 ++++++++++++++++++ .../get_folder_mount_path.py | 44 ++++++++ .../simcenter-designsafe-vm/tapisjob_app.sh | 67 ++++++++++++ 4 files changed, 244 insertions(+) create mode 100644 applications/simcenter-designsafe-vm/Dockerfile create mode 100644 applications/simcenter-designsafe-vm/app.json create mode 100644 applications/simcenter-designsafe-vm/get_folder_mount_path.py create mode 100644 applications/simcenter-designsafe-vm/tapisjob_app.sh diff --git a/applications/simcenter-designsafe-vm/Dockerfile b/applications/simcenter-designsafe-vm/Dockerfile new file mode 100644 index 0000000..6500525 --- /dev/null +++ b/applications/simcenter-designsafe-vm/Dockerfile @@ -0,0 +1,33 @@ +## taccaci/designsafe-simcenter-vm:0.0.1 ## + +FROM ubuntu:20.04 + +LABEL maintainer="TACC-ACI-WMA " + +ARG DEBIAN_FRONTEND=noninteractive + +ENV TZ=Etc/UTC + +RUN apt-get update && apt-get install -y \ + python3-pip + +RUN pip install --upgrade \ + pip \ + setuptools \ + wheel + +RUN pip install \ + h5py \ + numpy \ + pandas \ + xarray \ + tables \ + netcdf4 \ + h5netcdf \ + scipy + +RUN useradd --create-home ubuntu + +USER ubuntu + +SHELL ["/bin/bash", "-c"] \ No newline at end of file diff --git a/applications/simcenter-designsafe-vm/app.json b/applications/simcenter-designsafe-vm/app.json new file mode 100644 index 0000000..9613950 --- /dev/null +++ b/applications/simcenter-designsafe-vm/app.json @@ -0,0 +1,100 @@ +{ + "id": "SimCenter-DesignSafeVM", + "version": "0.0.1", + "description": "An app for extracting the physics-based motion from OpenSees results.", + "owner": "${apiUserId}", + "enabled": true, + "runtime": "ZIP", + "runtimeVersion": null, + "runtimeOptions": null, + "containerImage": "tapis://cloud.data/corral/tacc/aci/CEP/applications/v3/simcenter-designsafe-vm/simcenter-designsafe-vm.zip", + "jobType": "FORK", + "maxJobs": -1, + "maxJobsPerUser": -1, + "strictFileInputs": true, + "jobAttributes": { + "description": "Extract the physics-based motion of your OpenSees results on a virtual machine.", + "dynamicExecSystem": false, + "execSystemConstraints": null, + "execSystemId": "wma-exec-01", + "execSystemExecDir": "${JobWorkingDir}", + "execSystemInputDir": "${JobWorkingDir}", + "execSystemOutputDir": "${JobWorkingDir}", + "execSystemLogicalQueue": "development", + "archiveSystemId": "cloud.data", + "archiveSystemDir": "HOST_EVAL($HOME)/tapis-jobs-archive/${JobCreateDate}/${JobName}-${JobUUID}", + "archiveOnAppError": true, + "isMpi": false, + "mpiCmd": null, + "cmdPrefix": null, + "parameterSet": { + "appArgs": [], + "schedulerOptions": [], + "envVariables": [ + { + "key": "inputScript", + "value": "", + "description": "The filename of the main OpenSees input script.", + "inputMode": "REQUIRED", + "notes": { + "label": "Main Script" + } + }, + { + "key": "dataDirectory", + "value": "", + "description": "The path directory containing your data to be processed. Defaults to My Projects if not provided.", + "inputMode": "INCLUDE_ON_DEMAND", + "notes": { + "label": "Data Directory", + "selectionMode": "directory" + } + }, + { + "key": "_UserProjects", + "value": "", + "description": "User Project UUIDs and Project IDs", + "inputMode": "INCLUDE_ON_DEMAND", + "notes": { + "isHidden": true + } + } + ], + "archiveFilter": { + "includes": [], + "excludes": [], + "includeLaunchFiles": true + } + }, + "fileInputs": [ + { + "name": "Input Directory", + "description": "The directory containing your main OpenSees script and all necessary files. Defaults to My Data if not provided.", + "inputMode": "OPTIONAL", + "autoMountLocal": true, + "sourceUrl": null, + "targetPath": "*", + "envKey": "inputDirectory" + } + ], + "fileInputArrays": [], + "nodeCount": 1, + "coresPerNode": 1, + "memoryMB": 256000, + "maxMinutes": 1440, + "subscriptions": [], + "tags": [] + }, + "tags": [ + "portalName: CEP", + "portalName: DesignSafe" + ], + "notes": { + "label": "SimCenter DesignSafe (VM)", + "helpUrl": "https://www.designsafe-ci.org/user-guide/tools/simulation/opensees/opensees/", + "hideNodeCountAndCoresPerNode": true, + "icon": null, + "category": "Analysis", + "isInteractive": false + } +} diff --git a/applications/simcenter-designsafe-vm/get_folder_mount_path.py b/applications/simcenter-designsafe-vm/get_folder_mount_path.py new file mode 100644 index 0000000..d7cc0bf --- /dev/null +++ b/applications/simcenter-designsafe-vm/get_folder_mount_path.py @@ -0,0 +1,44 @@ +import sys + + +def set_mount_path(inputFolder, corralPrefix, tapisPrefix): + inputDir = inputFolder.replace(tapisPrefix,'') + mountPath = corralPrefix + inputDir # /corral/projects/NHERI/shared/gedmonds/LAS/LAS_converted/" + return mountPath + + +def main(): + folderToMount = sys.argv[1] + + prefixArr = [ + [ + "/corral/main/projects/NHERI/shared/", # "SHARED_PREFIX" + "tapis://designsafe.storage.default/" #"SHARED_TAPISPREFIX" + ], + [ + "/corral/main/projects/NHERI/projects/", # "PROJECT_PREFIX" + "tapis://project-" # "PROJECT_TAPISPREFIX" + ], + [ + "/corral/main/projects/NHERI/published/", # "PUBLISHED_PREFIX" + "tapis://designsafe.storage.published" # "PUBLISHED_TAPISPREFIX" + ], + [ + "/corral/main/projects/NHERI/community/", # "COMMUNITY_PREFIX" + "tapis://designsafe.storage.community" # "COMMUNITY_TAPISPREFIX": + ] + ] + + mountPath = None + + for prefixGroup in prefixArr: + corralPrefix = prefixGroup[0] + tapisPrefix = prefixGroup[1] + if tapisPrefix in folderToMount: + mountPath = set_mount_path(folderToMount, corralPrefix, tapisPrefix) + break + + print(mountPath) + +if __name__ == "__main__": + main() diff --git a/applications/simcenter-designsafe-vm/tapisjob_app.sh b/applications/simcenter-designsafe-vm/tapisjob_app.sh new file mode 100644 index 0000000..1097957 --- /dev/null +++ b/applications/simcenter-designsafe-vm/tapisjob_app.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +handle_error() { + local EXITCODE=$1 + echo "Phyiscs-based extractor job exited with an error status. $EXITCODE" >&2 + echo "$EXITCODE" > "${_tapisExecSystemOutputDir}/tapisjob.exitcode" + exit $EXITCODE +} + +set -x + +PBESCRIPT="${inputScript##*/}" +echo "PBESCRIPT is $PBESCRIPT" + +inputPath="`pwd`/${inputDirectory}" +INPUTDIR=${inputPath} +if [ -z ${inputDirectory} ]; then + INPUTDIR="/corral/projects/NHERI/shared/${_tapisJobOwner}" +fi + +#dataPath="`pwd`/${dataDirectory}" +DATADIR_NAME="${dataDirectory##*/}" +DATADIR=`python3 get_folder_mount_path.py $dataDirectory` + +DATADIR_MOUNT="--bind ${DATADIR}:/home/jovyan/work/projects/$DATADIR_NAME" +if [ -z ${dataDirectory} ]; then + projects_dir="$HOME/MyProjects" + + mkdir -p "$projects_dir" + IFS=' ' read -r -a projects <<< "${_UserProjects}" + for project in "${projects[@]}"; do + IFS=',' read -r uuid projectId <<< "$project" + target_path="/corral/main/projects/NHERI/projects/$uuid" + symlink_path="$projects_dir/$projectId" + + if [ -e "$target_path" ]; then + if [ ! -e "$symlink_path" ]; then + ln -s "$target_path" "$symlink_path" + echo "TACC: Project Links: Created symlink: $symlink_path -> $target_path" + else + echo "TACC: Project Links: Symlink already exists: $symlink_path" + fi + else + echo "TACC: Project Links: Target path does not exist: $target_path" + fi + done + DATADIR_MOUNT="--bind ${projects_dir}:/home/jovyan/work/projects" +fi + +echo "Running $PBESCRIPT" + +apptainer run \ + --writable-tmpfs \ + --memory 10G \ + --bind $INPUTDIR:"/data/" \ + --bind "/corral/main/projects/NHERI/shared/${_tapisJobOwner}":"/home/jovyan/work/MyData" \ + --bind /corral/main/projects/NHERI/public/projects:/home/jovyan/work/NEES:ro \ + --bind /corral/main/projects/NHERI/community:/home/jovyan/work/CommunityData:ro \ + --bind /corral/main/projects/NHERI/published:/home/jovyan/work/NHERI-Published:ro \ + --bind /corral/main/projects/NHERI/projects \ + $DATADIR_MOUNT \ + docker://taccaci/designsafe-simcenter-vm:0.0.1 /bin/sh -c "cd /data; python3 /data/$PBESCRIPT" + +if [ ! $? ]; then + handle_error 1 + exit +fi From 03159b3a8bc25f1db3867ee48449655c86557d5c Mon Sep 17 00:00:00 2001 From: Garrett Edmonds Date: Thu, 5 Sep 2024 10:45:31 -0500 Subject: [PATCH 2/4] Change container mount paths to remove user --- applications/simcenter-designsafe-vm/tapisjob_app.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/applications/simcenter-designsafe-vm/tapisjob_app.sh b/applications/simcenter-designsafe-vm/tapisjob_app.sh index 1097957..ea92402 100644 --- a/applications/simcenter-designsafe-vm/tapisjob_app.sh +++ b/applications/simcenter-designsafe-vm/tapisjob_app.sh @@ -22,7 +22,7 @@ fi DATADIR_NAME="${dataDirectory##*/}" DATADIR=`python3 get_folder_mount_path.py $dataDirectory` -DATADIR_MOUNT="--bind ${DATADIR}:/home/jovyan/work/projects/$DATADIR_NAME" +DATADIR_MOUNT="--bind ${DATADIR}:/home/${_tapisJobOwner}/work/projects/$DATADIR_NAME" if [ -z ${dataDirectory} ]; then projects_dir="$HOME/MyProjects" @@ -44,7 +44,7 @@ if [ -z ${dataDirectory} ]; then echo "TACC: Project Links: Target path does not exist: $target_path" fi done - DATADIR_MOUNT="--bind ${projects_dir}:/home/jovyan/work/projects" + DATADIR_MOUNT="--bind ${projects_dir}:/home/${_tapisJobOwner}/work/projects" fi echo "Running $PBESCRIPT" @@ -53,10 +53,10 @@ apptainer run \ --writable-tmpfs \ --memory 10G \ --bind $INPUTDIR:"/data/" \ - --bind "/corral/main/projects/NHERI/shared/${_tapisJobOwner}":"/home/jovyan/work/MyData" \ - --bind /corral/main/projects/NHERI/public/projects:/home/jovyan/work/NEES:ro \ - --bind /corral/main/projects/NHERI/community:/home/jovyan/work/CommunityData:ro \ - --bind /corral/main/projects/NHERI/published:/home/jovyan/work/NHERI-Published:ro \ + --bind "/corral/main/projects/NHERI/shared/${_tapisJobOwner}":"/home/${_tapisJobOwner}/work/MyData" \ + --bind /corral/main/projects/NHERI/public/projects:/home/NEES:ro \ + --bind /corral/main/projects/NHERI/community:/home/CommunityData:ro \ + --bind /corral/main/projects/NHERI/published:/home/NHERI-Published:ro \ --bind /corral/main/projects/NHERI/projects \ $DATADIR_MOUNT \ docker://taccaci/designsafe-simcenter-vm:0.0.1 /bin/sh -c "cd /data; python3 /data/$PBESCRIPT" From 06e8572b2ae71b0745909b4b432ceacb42a08c51 Mon Sep 17 00:00:00 2001 From: Garrett Edmonds Date: Thu, 7 Nov 2024 14:45:45 -0600 Subject: [PATCH 3/4] Handle case of DATADIR mount not being found + removing 'work' from some container mount paths --- applications/simcenter-designsafe-vm/tapisjob_app.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/applications/simcenter-designsafe-vm/tapisjob_app.sh b/applications/simcenter-designsafe-vm/tapisjob_app.sh index ea92402..c99e41b 100644 --- a/applications/simcenter-designsafe-vm/tapisjob_app.sh +++ b/applications/simcenter-designsafe-vm/tapisjob_app.sh @@ -22,8 +22,12 @@ fi DATADIR_NAME="${dataDirectory##*/}" DATADIR=`python3 get_folder_mount_path.py $dataDirectory` -DATADIR_MOUNT="--bind ${DATADIR}:/home/${_tapisJobOwner}/work/projects/$DATADIR_NAME" -if [ -z ${dataDirectory} ]; then +DATADIR_MOUNT="--bind ${DATADIR}:/home/${_tapisJobOwner}/projects/$DATADIR_NAME" +if [ -z ${dataDirectory} || -z ${DATADIR} ]; then + + if [ -z ${DATADIR} ]; then + echo "No valid mount found for Data Directory specified in job request; defaulting to mounting your projects." + fi projects_dir="$HOME/MyProjects" mkdir -p "$projects_dir" @@ -44,7 +48,7 @@ if [ -z ${dataDirectory} ]; then echo "TACC: Project Links: Target path does not exist: $target_path" fi done - DATADIR_MOUNT="--bind ${projects_dir}:/home/${_tapisJobOwner}/work/projects" + DATADIR_MOUNT="--bind ${projects_dir}:/home/${_tapisJobOwner}/projects" fi echo "Running $PBESCRIPT" @@ -53,7 +57,7 @@ apptainer run \ --writable-tmpfs \ --memory 10G \ --bind $INPUTDIR:"/data/" \ - --bind "/corral/main/projects/NHERI/shared/${_tapisJobOwner}":"/home/${_tapisJobOwner}/work/MyData" \ + --bind "/corral/main/projects/NHERI/shared/${_tapisJobOwner}":"/home/${_tapisJobOwner}/MyData" \ --bind /corral/main/projects/NHERI/public/projects:/home/NEES:ro \ --bind /corral/main/projects/NHERI/community:/home/CommunityData:ro \ --bind /corral/main/projects/NHERI/published:/home/NHERI-Published:ro \ From 01aa442548cdaee9332f44af289bc51606ee657c Mon Sep 17 00:00:00 2001 From: Garrett Edmonds Date: Thu, 7 Nov 2024 14:51:23 -0600 Subject: [PATCH 4/4] Decrease amount of memory dedicated for container by half --- applications/simcenter-designsafe-vm/tapisjob_app.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/simcenter-designsafe-vm/tapisjob_app.sh b/applications/simcenter-designsafe-vm/tapisjob_app.sh index c99e41b..a84d00e 100644 --- a/applications/simcenter-designsafe-vm/tapisjob_app.sh +++ b/applications/simcenter-designsafe-vm/tapisjob_app.sh @@ -55,7 +55,7 @@ echo "Running $PBESCRIPT" apptainer run \ --writable-tmpfs \ - --memory 10G \ + --memory 5G \ --bind $INPUTDIR:"/data/" \ --bind "/corral/main/projects/NHERI/shared/${_tapisJobOwner}":"/home/${_tapisJobOwner}/MyData" \ --bind /corral/main/projects/NHERI/public/projects:/home/NEES:ro \