#!/bin/bash

# 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_data_extraction/
met_processor=${bin}/environmental_suitability/
plotting=${bin}/plotting/
post_processing=${bin}/post_processing/ews-postprocessing/
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}

# 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
python ${proc_path}/Processor.py "$@"

# deactivate conda environment
source /storage/app/miniconda3/bin/deactivate ${conda_env}

