Skip to content
Snippets Groups Projects
Commit dc9072d3 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Add runnable script and virtualenv

parent 41cd9f88
Branches
No related tags found
No related merge requests found
Pipeline #2437 failed
...@@ -25,9 +25,9 @@ from jinja2 import Environment, FileSystemLoader ...@@ -25,9 +25,9 @@ from jinja2 import Environment, FileSystemLoader
load_dotenv() load_dotenv()
weatherdata_path="in/" weatherdata_path = os.getenv("WEATHER_DATA_DIR")
tmp_path="tmp/" tmp_path = "tmp/"
out_path="out/" out_path = os.getenv("DATA_DIR")
# TODO: Make this truly independent of time zones/Norwegian conditions? # TODO: Make this truly independent of time zones/Norwegian conditions?
utc_offset = "+02:00" utc_offset = "+02:00"
......
Jinja2
netCDF4
pytz
python-dotenv
\ No newline at end of file
#!/bin/bash
# Copyright (C) 2023 NIBIO <http://www.nibio.no/>.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Configures environment and logging before running the model
# @author: Tor-Einar Skog <tor-einar.skog@nibio.no>
# First: Test that we have CDO and GDAL installed
if ! command -v cdo &> /dev/null
then
echo "ERROR: CDO could not be found. Exiting."
exit
fi
if ! command -v gdal_merge.py &> /dev/null
then
echo "ERROR: GDAL is either not installed, or not built with Python support. Exiting."
exit
fi
# Defines HOME_DIR
source .env
# Check for HOME_DIR
if [ -z "${HOME_DIR}" ]
then
echo "ERROR: \$HOME_DIR is not set. Please declare it in an .env file"
exit
fi
# Paths to scripts and requirements
APP_PATH=${HOME_DIR}PSILARTEMP/
LOG_FILE=${APP_PATH}log/PSILARTEMP.log
REQUIREMENTS=${APP_PATH}requirements.txt
cd $APP_PATH
# Create and activate the virtual environment
python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install --upgrade pip
pip install -r $REQUIREMENTS
# Run the model
echo "==== `date`: Running model" &>> "$LOG_FILE"
python3 $APP_PATH/PSILARTEMP.py &>> "$LOG_FILE"
echo "==== `date`: DONE running model" &>> "$LOG_FILE"
# Deactivate the virtual environment
deactivate
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment