Skip to content

Commit

Permalink
Merge pull request #18 from nsidc/fix-regression
Browse files Browse the repository at this point in the history
Fix regression
  • Loading branch information
mollyhardman authored Aug 15, 2024
2 parents 57ac5da + 4cd3c4a commit 551e170
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 7 deletions.
6 changes: 4 additions & 2 deletions regression_scripts/build_pmesdr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
# This script requires the name of a conda env to use to run the unit tests for CETB
# comparison utilities.

# If any simple step or pipeline fails, this script will fail
set -eo pipefail

error_exit() {
# Use for fatal program error
# Argument:
# optional string containing descriptive error message
# if no error message, prints "Unknown Error"
# Assumes caller has done set_pmesdr_environment.sh

echo "build_pmesdr.sh: ERROR: ${1:-"Unknown Error"}" 1>&2
return -1
Expand All @@ -29,5 +33,3 @@ cd ${PMESDR_TOP_DIR}/python
source activate $condaenv
nosetests test_cetb_utilities.py || error_exit "unit tests failed"

# End of example job shell script
#
6 changes: 4 additions & 2 deletions regression_scripts/git_pull.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash -l
# If any simple step or pipeline fails, this script will fail
set -eo pipefail

PROGNAME=$(basename $0)

Expand All @@ -7,14 +9,14 @@ error_exit() {
# Argument:
# optional string containing descriptive error message
# if no error message, prints "Unknown Error"
# Assumes user has done set_pmesdr_environment.sh

echo "${PROGNAME}: ERROR: ${1:-"Unknown Error"}" 1>&2
exit -1
return -1
}

printf "%s: On %s, fetching latest software changes...\n" ${PROGNAME} $(hostname)

source /projects/$USER/PMESDR_regression/src/prod/set_pmesdr_environment.sh
cd $PMESDR_TOP_DIR || error_exit "$LINENO: Error changing to PMESDR_TOP_DIR."
git pull || error_exit "$LINENO: Error on git pull."
git status
Expand Down
33 changes: 33 additions & 0 deletions regression_scripts/pull_build_and_run_regression.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash -l
#
# Re-builds a fresh copy of the system at PMESDR_TOP_DIR, runs unit tests and
# either quick or daily regression
#
# Assumes the user has set the bash environment with set_pmesdr_environment.sh
#

# If any simple step or pipeline fails, this script will fail
# thanks to this page for this tip:
# https://stackoverflow.com/questions/821396/aborting-a-shell-script-if-any-command-returns-a-non-zero-value
set -eo pipefail

error_exit() {
# Use for fatal program error
# Argument:
# optional string containing descriptive error message
# if no error message, prints "Unknown Error"

echo "pull_build_and_run_regression.sh: ERROR: ${1:-"Unknown Error"}" 1>&2
return 1
}

REGRESSIONTYPE=$1

source ${PMESDR_TOP_DIR}/regression_scripts/git_pull.sh || \
error_exit "failed to git pull from remote"
source ${PMESDR_TOP_DIR}/regression_scripts/build_pmesdr.sh ${PMESDR_CONDAENV} || \
error_exit "failed to build system"
source ${PMESDR_TOP_DIR}/regression_scripts/run_regression.sh \
${REGRESSIONTYPE} ${PMESDR_CONDAENV} || \
error_exit "failed to run regression"

7 changes: 5 additions & 2 deletions regression_scripts/run_regression.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
#
# It is assumed that the caller has set the system location to
# $PMESDR_TOP_DIR
#
#

# If any simple step or pipeline fails, this script will fail
set -eo pipefail

regressiontype=$1
condaenv=$2

Expand Down Expand Up @@ -42,7 +46,6 @@ echo "`basename $0`: Regression type is $regressiontype"
echo "`basename $0`: Conda env is $condaenv"
echo "`basename $0`: Make target is $maketarget"

source ${PMESDR_TOP_DIR}/src/prod/set_pmesdr_environment.sh
eval "$(conda shell.bash hook)"
conda activate ${condaenv}
date
Expand Down
13 changes: 12 additions & 1 deletion src/prod/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ BINDIR = $(TOPDIR)/bin
#
SHELL = /bin/sh

# Note that the extra activate is needed to ensure that the
# activate floats env to the front of PATH
# Thanks to this web site for the tip on how to use conda envs
# from a makefile:
# https://blog.ianpreston.ca/posts/2020-05-13-conda_envs.html
CONDA_ACTIVATE=source $$(conda info --base)/etc/profile.d/conda.sh ; conda activate ; conda activate

#
# C compiler options, debug or optimization settings
#
Expand Down Expand Up @@ -90,9 +97,13 @@ regression-setup:

conda-env:
conda create -y -n $(CONDAENV) gsx; \
conda activate $(CONDAENV); \
$(CONDA_ACTIVATE) $(CONDAENV); \
pip install pynose

clean-conda:
$(CONDA_ACTIVATE) base; \
conda remove -n $(CONDAENV) --all

unit-test:
${PMESDR_TOP_DIR}/regression_scripts/build_pmesdr.sh $(CONDAENV)

Expand Down

0 comments on commit 551e170

Please sign in to comment.