From e95ab38dbacdf739ee406c290974551d06e56471 Mon Sep 17 00:00:00 2001 From: lb584 <lb584@cam.ac.uk> Date: Thu, 19 Oct 2023 13:13:54 +0100 Subject: [PATCH] adding new Processor-specific runner scripts --- .../run/launchDockerRunner_lb584_Local.sh | 2 +- scripts/run_Depo_Processor.sh | 17 +++++++++ scripts/run_utils.sh | 37 +++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 scripts/run_Depo_Processor.sh create mode 100755 scripts/run_utils.sh diff --git a/configs/docker/run/launchDockerRunner_lb584_Local.sh b/configs/docker/run/launchDockerRunner_lb584_Local.sh index 65597aa..60017f6 100755 --- a/configs/docker/run/launchDockerRunner_lb584_Local.sh +++ b/configs/docker/run/launchDockerRunner_lb584_Local.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -docker run -dt -v "/media/scratch/lb584_scratch/projects/ews_aws/ews_3/code:/storage/app/EWS_prod/code" \ +docker run -it -v "/media/scratch/lb584_scratch/projects/ews_aws/ews_3/code:/storage/app/EWS_prod/code" \ -v "/media/scratch/lb584_scratch/projects/ews_aws/ews_3/regions:/storage/app/EWS_prod/regions" \ -v "/media/scratch/lb584_scratch/projects/ews_aws/ews_3/envs/credentials:/storage/app/EWS_prod/envs/credentials" \ -w "/storage/app/EWS_prod/code" \ diff --git a/scripts/run_Depo_Processor.sh b/scripts/run_Depo_Processor.sh new file mode 100644 index 0000000..b582733 --- /dev/null +++ b/scripts/run_Depo_Processor.sh @@ -0,0 +1,17 @@ + +source ./run_utils.sh + +setup_conda_env + +# get path of this script (to point to files within the same git repo) +proc_path="$(dirname "$(readlink -f "$0")")" + +# run the processor with all arguments +processor=${proc_path}/../coordinator/ProcessorDeposition.py +printf "processor is %s\n\n" "$processor" +python "${processor}" "$@" +exit_code=$? + +teardown_conda_env + +exit $exit_code diff --git a/scripts/run_utils.sh b/scripts/run_utils.sh new file mode 100755 index 0000000..2313dd6 --- /dev/null +++ b/scripts/run_utils.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +function setup_conda_env() { + # directory containing all environment + envs=/storage/app/EWS_prod/envs + + # directory containing all custom python packages + bin=/storage/app/EWS_prod/code/ + + # provide custom python packages so they can be imported + flagdir=${bin}/flagdir/ + epimodel=${bin}/epimodel/ + advisory=${bin}/advisory_builder/ + met_processing=${bin}/met_extractor_v2/ + met_processor=${bin}/environmental_suitability/ + plotting=${bin}/plotting/ + post_processing=${bin}/post_processing/ + source_gen=${bin}/source_gen/ + + export PYTHONPATH=$PYTHONPATH:$flagdir:$epimodel:$advisory:$met_processing:$met_processor:$plotting:$source_gen:$post_processing + + # provide path to email credentials for logging + + export EMAIL_CRED=${envs}/credentials/Cred_gmail.json + + # activate conda environment of python modules so they can be imported + #TODO: Move conda_env from bin to envs + conda_env=${envs}/conda/py3EWS + source /storage/app/miniconda3/bin/activate ${conda_env} +} + +function teardown_conda_env() { + # deactivate conda environment + source /storage/app/miniconda3/bin/deactivate ${conda_env} + +} + -- GitLab