#!/bin/bash

function setup_virtual_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
  coordinator=${bin}/coordinator/
  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:$coordinator:$epimodel:$advisory:$met_processing:$met_processor:$plotting:$source_gen:$post_processing

  # provide path to email credentials for logging

  export LOGGING_CONFIG=${bin}/coordinator/configs/logger/log_config.json
  export EMAIL_CRED=${envs}/credentials/Cred_gmail.json

  # activate venv environment of python modules so they can be imported
  venv=${envs}/venv;
  source ${venv}/ews_prod/bin/activate;
}

function teardown_virtual_env() {
  # deactivate conda environment
  deactivate;
}

