diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2016-07-20 15:42:41 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2016-07-20 15:42:41 -0400 |
commit | de413e7ae293f2b919e2e75369c1ecb8a0c83975 (patch) | |
tree | 143ea097ea9e740c48b62335d468e9b0543be7b3 | |
download | astroconda-control-de413e7ae293f2b919e2e75369c1ecb8a0c83975.tar.gz |
Initial commit
-rwxr-xr-x | bin/build.sh | 360 | ||||
-rwxr-xr-x | bin/build_hmm.sh | 81 | ||||
-rwxr-xr-x | bin/docs_jwst.sh | 36 | ||||
-rwxr-xr-x | bin/prerelease.sh | 11 | ||||
-rwxr-xr-x | bin/tests_dev27.sh | 36 | ||||
-rwxr-xr-x | bin/tests_jwst_dev27.sh | 33 | ||||
-rwxr-xr-x | bin/tests_okify.sh | 40 | ||||
-rwxr-xr-x | bin/tests_public27.sh | 36 | ||||
-rwxr-xr-x | bin/update_all.sh | 51 | ||||
-rw-r--r-- | etc/manifest-dev.lst | 79 | ||||
-rw-r--r-- | etc/manifest-oneoff.lst | 1 | ||||
-rw-r--r-- | etc/manifest-public.lst | 78 | ||||
-rw-r--r-- | include/conda_porcelain.sh | 142 | ||||
-rw-r--r-- | include/host_config.sh | 13 | ||||
-rw-r--r-- | include/logger.sh | 22 | ||||
-rwxr-xr-x | include/midnight_special.sh | 18 | ||||
-rw-r--r-- | include/post-common.sh | 45 | ||||
-rw-r--r-- | include/pre-common.sh | 71 | ||||
-rw-r--r-- | include/sysinfo.sh | 70 | ||||
-rw-r--r-- | include/texlive.sh | 21 | ||||
-rwxr-xr-x | interactive.sh | 4 |
21 files changed, 1248 insertions, 0 deletions
diff --git a/bin/build.sh b/bin/build.sh new file mode 100755 index 0000000..177c47c --- /dev/null +++ b/bin/build.sh @@ -0,0 +1,360 @@ +#!/bin/bash +# +# A steuermann compatible conda build script. +# +# This differs from the original build script in that it does not iterate over +# many Python or Numpy versions in an attempt to be fully comprehensive. +# Instead, since we're being "controlled", so we TELL steuermann what we want +# the script to perform at a high level (not this script), rather than making +# assumptions about what is needed/wanted at build-time. +# +# The build script uses "porcelain", and is not to be confused with "fragile". +# +# Conda uses lock files to determine whether its build (or installation) +# system is currently in use. Traditionally this means only ONE build may be +# active at a time. Porcelain installs its own miniconda into a completely +# unique temporary directory so that eliminates the problem entirely. The +# "conda build" subsystems never talk to one another while executing. + +# You may run multiple builds at the same time so long as you activate +# porcelain [correctly] per-run. +# +# Porcelain is a write-once-remove-immediately, "WORI", enviroment. Yes, +# the name does imply "worry". Be sure to either copy or move important data +# out of $PORCELAIN_PREFIX or $TMPDIR prior to exiting the script or calling +# "porcelain_deinit" directly. +# +# A signal handler is in place to run "porcelain_deinit" automatically on +# exit regardless of exit method. Signals and general exit calls are ALL +# handled equally. +# +# If you do, you will quickly fill up the partition. Builds can be as large +# as 4GB, and potentially larger as time goes on. Don't be a doofus; always +# run "porcelain_deinit". You have been warned. +# +# Never run a build outside of the "midnight_special" environment. The IRAF +# account is a total mess. "midnight_special" performs a magical ritutal +# that reassigns $HOME and effectively carpet bombs the original environment. +# Please do not modify "midnight_special" for any reason. +# + +source /eng/ssb/auto/astroconda/include/midnight_special.sh +source /eng/ssb/auto/astroconda/include/sysinfo.sh +source /eng/ssb/auto/astroconda/include/conda_porcelain.sh +source /eng/ssb/auto/astroconda/include/logger.sh + +function warning_sleep +{ + wtime=$1 + if [[ -z $wtime ]]; then + wtime=30 + fi + + echo "YOU PROBABLY DO NOT WANT THIS!" + echo "Sleeping for $wtime second(s) just in case." + #sleep $wtime + echo "Continuing..." +} + +function repo_transfer +{ + porcelain_verify + + local repo_local="$PORCELAIN_DESTDIR/conda-bld/$repo_arch" + local path="$1" + + if [[ -z $path ]]; then + echo "transfer_repo requires a path." + exit 1 + fi + + if [[ $path == *${repo_arch} ]]; then + echo "tranfer_repo received an invalid path: $path" + echo "(Remove the trailing /$repo_arch)" + exit 1 + fi + + echo "Transfering local repository $repo_local to $path" + rsync -aHv \ + --exclude='repodata*' \ + --exclude='.index*' \ + "$repo_local" \ + "$path/" + + retval=$? + if [[ $retval > 0 ]]; then + exit $? + fi +} + +function repo_index +{ + local path="$1" + if [[ -z $path ]]; then + echo "index_repo requires a path" + exit 1 + fi + + if [[ ! -d $path ]]; then + echo "$path does not exist." + exit 1 + fi + + echo "Indexing remote repository: $path" + conda index $path + + retval=$? + if [[ $retval > 0 ]]; then + exit $retval + fi +} + +function usage +{ + printf "%s: [-h] [-bm] (-p|-d)\n" $(basename $0) + echo " + Optional: + + --bootstrap -B Build regardless if package exists upstream + (Dangerous) + --branch [branch] -b Desired git branch + (OMIT trailing os-arch; e.g. /linux-64) + --help -h This message + --manifest [file] -m Ordered build list + + Required: + + --public -p Use public (astroconda) + --dev -d Use dev (astroconda-dev) + --deposit [path] -D Destination for completed packages + --numpy [version] -N NumPy linkage version + --python [version] -P Python linksage version + " +} + +# 775 | 664 +umask 002 + +build_bootstrap=0 +muarg_public=0 +muarg_dev=0 + + +if [[ $# < 1 ]]; then + usage + exit 1 +fi + +while [[ $# > 0 ]] +do + key="$1" + case "$key" in + --help|-h) + usage + exit 0 + ;; + --branch|-b) + repo_git_branch="$2" + if [[ $repo_git_branch == -* ]] || [[ -z $repo_git_branch ]]; then + echo "--branch/-b requires an argument." + exit 1 + fi + shift + ;; + --deposit|-D) + repo_deposit="$2" + if [[ $repo_deposit == -* ]] || [[ -z $repo_deposit ]]; then + echo "--deposit requires an argument." + exit 1 + fi + shift + ;; + --python|-P) + build_python="$2" + if [[ $build_python == -* ]] || [[ -z $build_python ]]; then + echo "--python requires an argument." + exit 1 + fi + shift + ;; + --numpy|-N) + build_numpy="$2" + if [[ $build_numpy == -* ]] || [[ -z $build_numpy ]]; then + echo "--numpy requires an argument." + exit 1 + fi + shift + ;; + --public|-p) + muarg_public=1 + if [[ $muarg_dev != 0 ]]; then + echo "--public is mutually exclusive with --dev" + exit 1 + fi + repo_git=https://github.com/astroconda/astroconda-contrib + repo_conda=http://ssb.stsci.edu/astroconda + ;; + --dev|-d) + muarg_dev=1 + if [[ $muarg_public != 0 ]]; then + echo "--dev is mutually exclusive with --public" + exit 1 + fi + repo_git=https://github.com/astroconda/astroconda-dev + repo_conda=http://ssb.stsci.edu/conda-dev + ;; + --manifest|-m) + build_manifest="$2" + if [[ ! -f $build_manifest ]]; then + echo "'$build_manifest' does not exist." + exit 1 + fi + shift + ;; + --bootstrap|-B) + build_bootstrap=1 + ;; + *) + usage + echo "Unknown argument: $1" + echo + exit 1 + ;; + esac + shift +done + +if [[ -z $repo_git ]]; then + echo "Missing argument: --public or --dev is required" + exit 1 +elif [[ -z $repo_deposit ]]; then + echo "--deposit is required" + exit 1 +elif [[ -z $build_python ]]; then + echo "--python is required" + exit 1 +elif [[ -z $build_numpy ]]; then + echo "--numpy is required" + exit 1 +fi + +if [[ -z $repo_git_branch ]]; then + repo_git_branch=master +fi + +if [[ ! -d $repo_deposit ]]; then + mkdir -p $repo_deposit + retval=$? + if [[ $? > 0 ]]; then + echo "Unable to create $repo_deposit" + exit 1 + fi +fi + +# Set repository tail +repo_arch=`conda_arch` + +echo repo_git_branch=$repo_git_branch +echo repo_git=$repo_git +echo repo_deposit=$repo_deposit +echo repo_arch=`conda_arch` +echo build_python=$build_python +echo build_numpy=$build_numpy +echo build_manifest=$build_manifest + +if [[ $build_bootstrap != 0 ]]; then + echo "BOOTSTRAP MODE ACTIVE (DANGEROUS)" + warning_sleep 90 +fi + +if [[ -z $build_manifest ]]; then + echo "No manifest defined; building alphabetically." + warning_sleep 90 +fi + +build_command="conda build \ + --quiet \ + --python=$build_python \ + --numpy=$build_numpy \ + --override-channels \ + -c defaults" + +if [[ $build_bootstrap == 0 ]]; then + build_command="$build_command --skip-existing -c $repo_conda" +else + echo "Bootstrap mode is active... FINAL WARNING!" + warning_sleep 10 +fi + + +porcelain_init + +# Setup logging +if [[ -n $sm_base ]]; then + sm_logs="$sm_base/$sm_run/$sm_node" +fi + +if [[ -n $sm_logs ]]; then + if [[ ! -d $sm_logs ]]; then + echo "Initializing steuermann log directory: $sm_logs" + mkdir -p $sm_logs + fi +fi + +# Take note that we are testing $sm_base, not $sm_logs. +if [[ -n $sm_base ]]; then + LOGDIR="$sm_logs" +else + LOGDIR="$PORCELAIN_PREFIX/logs" + mkdir -p "$LOGDIR" +fi + +# Begin build processs +pushd "$PORCELAIN_PREFIX" + porcelain_get_installer + porcelain_run_installer + + conda install --yes --quiet conda-build=1.18.1 conda=3.19.1 + if [[ $? > 0 ]]; then + echo "Unable to install conda-build, so stopping." + exit 1 + fi + echo + + git clone $repo_git + if [[ $? > 0 ]]; then + echo "Unable to clone recipe repository $repo_git, so stopping." + exit 1 + fi + echo + + pushd "$(basename $repo_git)" + if [[ -n $build_manifest ]]; then + for pkg in $(cat $build_manifest) + do + if [[ -z $pkg ]] || [[ $pkg == \#* ]]; then + continue + fi + + logger $LOGDIR/${pkg}.log $build_command $pkg + done + else + # Pretty much the worst thing you could ever WANT to do... + # this will build things you DO NOT WANT. Use a manifest! + for pkg in * + do + [[ ! -f $pkg/meta.yaml ]] && continue + logger $LOGDIR/${pkg}.log $build_command $pkg + done + fi + + echo '----' + logger repo_transfer.log repo_transfer "$repo_deposit" + echo '----' + logger repo_index.log repo_index "$repo_deposit/$repo_arch" + echo '----' + popd +popd + +porcelain_deinit + diff --git a/bin/build_hmm.sh b/bin/build_hmm.sh new file mode 100755 index 0000000..a73b9ee --- /dev/null +++ b/bin/build_hmm.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# +# A steuermann compatible conda build script. +# +# This differs from the original build script in that it does not iterate over +# many Python or Numpy versions in an attempt to be fully comprehensive. +# Instead, since we're being "controlled", so we TELL steuermann what we want +# the script to perform at a high level (not this script), rather than making +# assumptions about what is needed/wanted at build-time. +# +# The build script uses "porcelain", and is not to be confused with "fragile". +# +# Conda uses lock files to determine whether its build (or installation) +# system is currently in use. Traditionally this means only ONE build may be +# active at a time. Porcelain installs its own miniconda into a completely +# unique temporary directory so that eliminates the problem entirely. The +# "conda build" subsystems never talk to one another while executing. + +# You may run multiple builds at the same time so long as you activate +# porcelain [correctly] per-run. +# +# Porcelain is a write-once-remove-immediately, "WORI", enviroment. Yes, +# the name does imply "worry". Be sure to either copy or move important data +# out of $PORCELAIN_PREFIX or $TMPDIR prior to calling "porcelain_deinit". +# +# DO NOT FORGET TO RUN "porcelain_deinit". +# +# If you do, you will quickly fill up the partition. Builds can be as large +# as 4GB, and potentially larger as time goes on. Don't be a doofus; always +# run "porcelain_deinit". You have been warned. +# +# Never run a build outside of the "midnight_special" environment. The IRAF +# account is a total mess. "midnight_special" performs a magical ritutal +# that reassigns $HOME and effectively carpet bombs the original environment. +# Please do not modify "midnight_special" for any reason. +# + +echo "BEFORE..." +printenv | sort +echo + +source /eng/ssb/auto/astroconda/include/midnight_special.sh +source /eng/ssb/auto/astroconda/include/sysinfo.sh +source /eng/ssb/auto/astroconda/include/logger.sh +source /eng/ssb/auto/astroconda/include/conda_porcelain.sh + +echo "AFTER..." +printenv | sort +echo + +porcelain_init + +# Setup logging +if [[ -n $sm_base ]]; then + sm_logs="$sm_base/$sm_run/$sm_node" +fi + +if [[ -n $sm_logs ]]; then + if [[ ! -d $sm_logs ]]; then + echo "Initializing steuermann log directory: $sm_logs" + mkdir -p $sm_logs + fi +fi + +# Take note that we are testing $sm_base, not $sm_logs. +if [[ -n $sm_base ]]; then + LOGDIR="$sm_logs" +else + LOGDIR="$PORCELAIN_PREFIX/logs" + mkdir -p "$LOGDIR" +fi +# Begin build processs +pushd "$PORCELAIN_PREFIX" + porcelain_get_installer + porcelain_run_installer + + logger $LOGDIR/a_test_file.log echo this output should be logged +popd + +porcelain_deinit + diff --git a/bin/docs_jwst.sh b/bin/docs_jwst.sh new file mode 100755 index 0000000..1542cdd --- /dev/null +++ b/bin/docs_jwst.sh @@ -0,0 +1,36 @@ +#!/bin/bash +source /eng/ssb/auto/astroconda/include/midnight_special.sh +source /eng/ssb/auto/astroconda/include/conda_porcelain.sh +source /eng/ssb/auto/astroconda/include/texlive.sh + +porcelain_init + +pushd "$PORCELAIN_PREFIX" + porcelain_get_installer + porcelain_run_installer + + build_env="$(basename $PORCELAIN_PREFIX)" + depot=/eng/ssb/websites/ssbpublic/doc/jwst_git + + repo_conda=http://ssb.stsci.edu/conda-dev + repo_git=https://github.com/stsci-jwst/jwst + repo_git_branch=master + + conda create -n "$build_env" \ + --yes \ + --quiet \ + --override-channels \ + -c defaults \ + -c $repo_conda sphinx=1.3.5 jwst stsci.sphinxext + + source activate $build_env + + git clone "$repo_git" + pushd "$(basename $repo_git)" + git checkout $repo_git_branch + docs/mkdocs.sh -o "$depot" + popd +popd + +porcelain_deinit + diff --git a/bin/prerelease.sh b/bin/prerelease.sh new file mode 100755 index 0000000..f616e8d --- /dev/null +++ b/bin/prerelease.sh @@ -0,0 +1,11 @@ +#!/bin/bash +SRC=/eng/ssb/websites/ssbpublic/conda-dev +DST=/eng/ssb/websites/ssbpublic/astroconda-prerelease/ + +( cd $SRC \ + && rsync -aH --relative */*jwst* $DST \ + && conda index "$DST/linux-64" \ + && conda index "$DST/osx-64" \ + && cbc_repo2html "$DST/linux-64/repodata.json" > "$DST/linux-64/index.html" \ + && cbc_repo2html "$DST/osx-64/repodata.json" > "$DST/osx-64/index.html" +) diff --git a/bin/tests_dev27.sh b/bin/tests_dev27.sh new file mode 100755 index 0000000..a1cd0b9 --- /dev/null +++ b/bin/tests_dev27.sh @@ -0,0 +1,36 @@ +#!/bin/bash +source /eng/ssb/auto/astroconda/include/midnight_special.sh +source /eng/ssb/auto/astroconda/include/pre-common.sh + +# Set context (used here and in post-common.sh) +name=conda +context=dev +repo=http://ssb.stsci.edu/conda-dev + +# Activate environment +source activate rt_${context}27 + +# Update environment +conda update -q -y --override-channels -c defaults -c $repo --all + +source /eng/ssb/auto/astroconda/include/post-common.sh + +# Assign tests to run +tests=( + $test_from/astrolib + $test_from/stsci_python + $test_from/betadrizzle + $test_from/axe + $test_from/hstcal + $test_from/stsdas +) + +# Nuke existing logs, run the tests, import the tests +set -x + +[[ -d $LOGDIR ]] && [[ $LOGDIR != ^/$ ]] && rm -f "$LOGDIR/*" +pushd $LOGDIR + time pdkrun --parallel=${CPU_COUNT} -r "${tests[@]}" +popd +cat ${PDK_LOG}* | ssh iraf@ssb "irafdev ; pdk import -" + diff --git a/bin/tests_jwst_dev27.sh b/bin/tests_jwst_dev27.sh new file mode 100755 index 0000000..bb8878b --- /dev/null +++ b/bin/tests_jwst_dev27.sh @@ -0,0 +1,33 @@ +#!/bin/bash +source /eng/ssb/auto/astroconda/include/midnight_special.sh +source /eng/ssb/auto/astroconda/include/pre-common.sh + +# Set context (used here and in post-common.sh) +name=conda +context=dev +repo=http://ssb.stsci.edu/conda-dev + +# Activate environment +source activate rt_${context}27 + +# Update environment +conda update -q -y --override-channels -c defaults -c $repo --all + +source /eng/ssb/auto/astroconda/include/post-common.sh + +# Assign tests to run +tests=( + $test_from/general + $test_from/more_tests + $test_from/test_functions +) + +# Nuke existing logs, run the tests, import the tests +set -x + +[[ -d $LOGDIR ]] && [[ $LOGDIR != ^/$ ]] && rm -f "$LOGDIR/*" +pushd $LOGDIR + time pdkrun --parallel=${CPU_COUNT} -r "${tests[@]}" +popd +cat ${PDK_LOG}* | ssh iraf@ssb "irafdev ; pdk import -" + diff --git a/bin/tests_okify.sh b/bin/tests_okify.sh new file mode 100755 index 0000000..b46c43d --- /dev/null +++ b/bin/tests_okify.sh @@ -0,0 +1,40 @@ +#!/bin/bash +source /eng/ssb/auto/astroconda/include/midnight_special.sh +source /eng/ssb/auto/astroconda/include/pre-common.sh + +if [ "$groupdir" = "" ] +then + groupdir=/eng/ssb +else + echo groupdir is: + echo $groupdir +fi + + +# find our host name because it is used in the name of the okify file +h=`hostname -s` +echo $h + +# where the okify files are +cd "$groupdir/tests/pdk_updates" + +ls -l + +if [[ ! -f $h.ok ]]; then + echo no $h.ok + exit 0 +fi + +# not processing directly from the active file +rm -f $h.ok.process +mv $h.ok $h.ok.process + +echo START + +pdk ok -w $h.ok.process +status=$? + +echo END + +exit $status + diff --git a/bin/tests_public27.sh b/bin/tests_public27.sh new file mode 100755 index 0000000..1fa26b3 --- /dev/null +++ b/bin/tests_public27.sh @@ -0,0 +1,36 @@ +#!/bin/bash +source /eng/ssb/auto/astroconda/include/midnight_special.sh +source /eng/ssb/auto/astroconda/include/pre-common.sh + +# Set context (used here and in post-common.sh) +name=conda +context=public +repo=http://ssb.stsci.edu/astroconda + +# Activate environment +source activate rt_${context}27 + +# Update environment +conda update -q -y --override-channels -c defaults -c $repo --all + +source /eng/ssb/auto/astroconda/include/post-common.sh + +# Assign tests to run +tests=( + $test_from/astrolib + $test_from/stsci_python + $test_from/betadrizzle + $test_from/axe + $test_from/hstcal + $test_from/stsdas +) + +# Nuke existing logs, run the tests, import the tests +set -x + +[[ -d $LOGDIR ]] && [[ $LOGDIR != ^/$ ]] && rm -f "$LOGDIR/*" +pushd $LOGDIR + time pdkrun --parallel=${CPU_COUNT} -r "${tests[@]}" +popd +cat ${PDK_LOG}* | ssh iraf@ssb "irafdev ; pdk import -" + diff --git a/bin/update_all.sh b/bin/update_all.sh new file mode 100755 index 0000000..11a5024 --- /dev/null +++ b/bin/update_all.sh @@ -0,0 +1,51 @@ +#!/bin/bash +source /eng/ssb/auto/astroconda/include/midnight_special.sh +source /eng/ssb/auto/astroconda/include/pre-common.sh + +repo_base=http://ssb.stsci.edu +contexts=( dev public ) +versions=( 27 35 ) + +echo '----' +echo 'Updating base installation:' +conda update -q -y --all + +echo '----' +for context in "${contexts[@]}" +do + for version in "${versions[@]}" + do + case "$context" in + dev) + repo="$repo_base/conda-dev" + ;; + public) + repo="$repo_base/astroconda" + ;; + *) + echo "No repository available for: $context" + exit 1 + ;; + esac + + environ="rt_${context}${version}" + if [[ ! -d ~/miniconda3/envs/$environ ]]; then + echo '!!!!' + echo "No Conda environment for: $environ" + echo "Skipping..." + continue + fi + echo '----' + echo "Updating $context from $repo:" + conda update -q -y --override-channels -c defaults -c $repo -n $environ --all + echo '----' + echo "Forcing pandokia to exist:" + conda install -q -y --override-channels -c defaults -c $repo -n $environ pandokia + done +done + +echo '----' +echo 'Updating regression tests:' +svn_update `for d in /srv/rt/*; do [[ -d $d/.svn ]] && echo $d; done` +echo '----' + diff --git a/etc/manifest-dev.lst b/etc/manifest-dev.lst new file mode 100644 index 0000000..bbc4a50 --- /dev/null +++ b/etc/manifest-dev.lst @@ -0,0 +1,79 @@ +stsci.tools +stsci.imagestats +metapackages/stsci-data-analysis +metapackages/stsci-hst +metapackages/stsci + +acstools +appdirs +aprio +asdf-standard +asdf +astroimtools +astrolib.coords +asv +calcos +cfitsio +costools +crds +cube-tools +d2to1 +decorator +drizzle +drizzlepac +ds9 +fftw +fitsblender +ginga +glueviz +glue-vispy-viewers +gwcs +hstcal +htc_utils +imexam +jwst +nictools +opuscoords +pandokia +photutils +poppy +purge_path +pydrizzle +pyds9 +pyfftw +pyneb +pyqtgraph +pyraf +pyregion +pysynphot +python-daemon +pytools +pywcs +reftools +relic +selenium +shunit2 +specview +specviz +sphere +sphinx_rtd_theme +sphinxcontrib-programoutput +stginga +stistools +stsci.convolve +stsci.distutils +stsci.image +stsci.imagemanip +stsci.ndimage +stsci.numdisplay +stsci.skypac +stsci.sphere +stsci.sphinxext +stsci.stimage +stwcs +wcstools +webbpsf-data +webbpsf +wfc3tools +wfpc2tools +xpa diff --git a/etc/manifest-oneoff.lst b/etc/manifest-oneoff.lst new file mode 100644 index 0000000..f357e04 --- /dev/null +++ b/etc/manifest-oneoff.lst @@ -0,0 +1 @@ +jwst diff --git a/etc/manifest-public.lst b/etc/manifest-public.lst new file mode 100644 index 0000000..787e2d8 --- /dev/null +++ b/etc/manifest-public.lst @@ -0,0 +1,78 @@ +stsci.tools +stsci.imagestats +stsci-data-analysis +stsci-hst +stsci + +acstools +appdirs +aprio +asdf-standard +asdf +astroimtools +astrolib.coords +asv +calcos +cfitsio +costools +crds +cube-tools +d2to1 +decorator +drizzle +drizzlepac +ds9 +fftw +fitsblender +ginga +glueviz +glue-vispy-viewers +gwcs +hstcal +htc_utils +imexam +nictools +opuscoords +pandokia +photutils +poppy +purge_path +pydrizzle +pyds9 +pyfftw +pyneb +pyqtgraph +pyraf +pyregion +pysynphot +python-daemon +pytools +pywcs +reftools +relic +selenium +shunit2 +specview +specviz +sphere +sphinx_rtd_theme +sphinxcontrib-programoutput +stginga +stistools +stsci.convolve +stsci.distutils +stsci.image +stsci.imagemanip +stsci.ndimage +stsci.numdisplay +stsci.skypac +stsci.sphere +stsci.sphinxext +stsci.stimage +stwcs +wcstools +webbpsf-data +webbpsf +wfc3tools +wfpc2tools +xpa diff --git a/include/conda_porcelain.sh b/include/conda_porcelain.sh new file mode 100644 index 0000000..d4de1b7 --- /dev/null +++ b/include/conda_porcelain.sh @@ -0,0 +1,142 @@ +#!/bin/sh +source /eng/ssb/auto/astroconda/include/sysinfo.sh +porcelain_continuum_url=https://repo.continuum.io/miniconda +porcelain_continuum_script=Miniconda3-latest-${sysinfo_platform}-${sysinfo_arch}.sh +PORCELAIN_ALREADY_DEAD=0 +PORCELAIN_SIGNALED=0 + +function porcelain_init +{ + echo "Porcelain initializing..." + if [[ -z $HOME ]]; then + echo "\$HOME is not set, dying." + exit 1 + fi + + export TMPDIR="$HOME/bldtmp" + + if [[ ! -d $TMPDIR ]]; then + mkdir -p $TMPDIR + if [[ $? != 0 ]]; then + echo "Cannot create temporary storage directory '$TMPDIR', dying." + exit 1 + fi + fi + + export PORCELAIN_PREFIX=`mktemp -d -t porcelain.XXXXXXXXXX` + export PORCELAIN_TMPDIR="$PORCELAIN_PREFIX/tmp" + export PORCELAIN_DESTDIR="$PORCELAIN_PREFIX/porcelain" + export PATH="$PORCELAIN_DESTDIR/bin:$PATH" + echo "Prepended $PORCELAIN_DESTDIR/bin to PATH..." + + if [[ ! -d $PORCELAIN_TMPDIR ]]; then + mkdir -p "$PORCELAIN_TMPDIR" + fi + + export TMPDIR="$PORCELAIN_TMPDIR" + echo "Redirected TMPDIR to $PORCELAIN_TMPDIR" + echo "(Always use \$TMPDIR instead of /tmp for destructible storage)" + + echo "Activating signal handler... (will deinit on exit)" + trap porcelain_signal SIGINT SIGKILL SIGTERM EXIT +} + +function porcelain_verify +{ + local override="$1" + /bin/echo -n "Running safety check... " + + if [[ $override == '-f' ]] || [[ $override == '--force' ]]; then + echo "done (forced)" + return 0 + fi + + if [[ -z $TMPDIR ]]; then + echo "failed" + echo "TMPDIR='$TMPDIR'; we have lost trust in our environment. Dying." + exit 1 + fi + + if [[ ! -d $PORCELAIN_PREFIX ]]; then + echo "failed" + echo "PORCELAIN_PREFIX='$PORCELAIN_PREFIX'; mktemp must have failed. Dying." + exit 1 + fi + + # Note: we don't care about PORCELAIN_DESTDIR + echo "done" +} + +function porcelain_get_installer +{ + porcelain_verify + + retries=3 + wtime=5 + success=0 + count=0 + + echo "Obtaining $porcelain_continuum_script..." + + while [[ $count != $retries ]] + do + $sysinfo_fetch $sysinfo_fetch_args "$porcelain_continuum_url/$porcelain_continuum_script" + if [[ $? == 0 ]]; then + success=1 + break + fi + + echo "Retrying in $wtime second(s)..." + sleep $wtime + count=$(( count + 1 )) + done + + if [[ $success != 1 ]]; then + echo "Dying..." + exit 1 + fi +} + +function porcelain_run_installer +{ + porcelain_verify + + bash $porcelain_continuum_script -b -p $PORCELAIN_DESTDIR + if [[ $? > 0 ]]; then + echo "Dying..." + exit 1 + fi +} + +function porcelain_deinit +{ + if [[ $PORCELAIN_ALREADY_DEAD != 0 ]]; then + return + fi + + porcelain_verify + + echo "Deinitializing porcelain..." + if [[ -d $PORCELAIN_PREFIX ]]; then + echo "Removing $PORCELAIN_PREFIX" + rm -rf "$PORCELAIN_PREFIX" + fi + export PORCELAIN_ALREADY_DEAD=1 +} + +# Given the chance this script could be killed in a number of different +# ways, resulting in files left behind... we need to be pretty damn +# thourough. +function porcelain_signal +{ + retval=$? + if [[ $PORCELAIN_SIGNALED != 0 ]]; then + exit $? + fi + + export PORCELAIN_SIGNALED=1 + porcelain_deinit + + exit $? +} + diff --git a/include/host_config.sh b/include/host_config.sh new file mode 100644 index 0000000..a97778d --- /dev/null +++ b/include/host_config.sh @@ -0,0 +1,13 @@ +#(DEFAULT) +NEW_HOME=/srv/iraf + +#JWST +if [[ $HOSTNAME == *jwcalibdev* ]]; then + NEW_HOME=/data4/iraf_conda +fi + +#OSX +if [[ `uname -s` == Darwin ]]; then + NEW_HOME=/Users/shared/iraf_conda +fi + diff --git a/include/logger.sh b/include/logger.sh new file mode 100644 index 0000000..b8806e1 --- /dev/null +++ b/include/logger.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +function logger +{ + local logfile="$1" + if [[ $logfile != *.log ]]; then + echo "logger: log file is missing .log prefix, '$logfile'" + exit 1 + fi + + shift + + # Bash magic: return this exit value for the first pipe command + echo "Writing log: $logfile" + set -o pipefail + "$@" 2>&1 | tee $logfile + retval=$? + set +o pipefail + + return $retval +} + diff --git a/include/midnight_special.sh b/include/midnight_special.sh new file mode 100755 index 0000000..5781588 --- /dev/null +++ b/include/midnight_special.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# Yeah, we're not dealing with the existing environment. Too many things can go wrong here. +# DROP EVERYTHING and start fresh in a different home directory +source /eng/ssb/auto/astroconda/include/host_config.sh + +#[[ "$USER" != "" ]] && exec -c $0 +export sm_base="$PWD" + +unset $(/usr/bin/env \ + | egrep '^(\w+)=(.*)$' \ + | egrep -vw 'SHLVL|USER|LANG|sm_run|sm_node|sm_logs|sm_base|node_dir|workdir|hostname' \ + | /usr/bin/cut -d= -f1) +export PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin +export HOME=$NEW_HOME +export TERM=xterm +source /etc/profile +source /etc/bashrc +#printenv diff --git a/include/post-common.sh b/include/post-common.sh new file mode 100644 index 0000000..0ea77b6 --- /dev/null +++ b/include/post-common.sh @@ -0,0 +1,45 @@ +if [[ -z $context ]]; then + context=unknown +fi + +if [[ -z $name ]]; then + name=unknown +fi + +if [[ -z $test_to ]]; then + echo "\$test_to undefined. I refuse to continue. Did you forget to include pre-common?" + exit 1 +fi + +PYTHON_VERSION=$(python --version 2>&1 | awk '{ print $2 }') +CPU_COUNT=`python -c 'import multiprocessing as mp; print(mp.cpu_count()-1)'` + +DATETIME=$sm_run +if [[ -z $DATETIME ]]; then + echo "sm_run was undefined!" + DATETIME=broken_time_`date '+%Y-%m-%d-%H-%M-%s'` +fi + +export LOGDIR="$test_to/$context" +mkdir -p "$LOGDIR" + +if [[ -z $PDK_TESTRUN ]]; then + export PDK_TESTRUN=${name}-${DATETIME} +fi +export PDK_CONTEXT=$context:${PYTHON_VERSION} +export PDK_LOG="$LOGDIR/${HOSTNAME}-$PDK_TESTRUN" + +echo '----' +echo "Applying SHELL fix (thanks Continnum)..." +if [[ $SHELL == bash ]]; then + export SHELL=/bin/bash +elif [[ $SHELL == zsh ]]; then + export SHELL=/bin/zsh +else + # Don't ask why... + export SHELL=/bin/bash +fi + +echo '----' +printenv + diff --git a/include/pre-common.sh b/include/pre-common.sh new file mode 100644 index 0000000..ac14f6f --- /dev/null +++ b/include/pre-common.sh @@ -0,0 +1,71 @@ +function cleanup +{ + # Not a fan of ultra-verbose. This message will get lost. + set +x + echo "Trapped common exit signal (SIGINT | SIGTERM)" + /bin/echo + echo "TESTS WILL NOT BE IMPORTED" + /bin/echo + echo "Exiting..." + exit 1 +} +trap cleanup SIGINT SIGTERM + +test_from=/srv/rt +test_to=~/local/pillowfort + +if [[ `uname -s` == Darwin ]]; then + test_from=/Users/iraf/rt +fi + +if [[ $HOSTNAME == *jwcalibdev* ]]; then + test_from=/data1/jwst_rt +fi + +if [[ ! -d $test_to ]]; then + mkdir -p "$test_to" +fi + +export PATH=~/miniconda3/bin:$PATH +#export PATH=$PATH:~/local/fakedokia/bin +#export PYTHONPATH=~/local/fakedokia/lib +export CDBS=/grp/hst/cdbs/ +export crrefer=$CDBS +export PYSYN_CDBS=$CDBS + +function mkrt_paths +{ + args=("$@") + paths="" + + for elem in "${args[@]}" + do + path="$test_from/$elem" + if [[ ! -d $path ]]; then + echo "Warning: $path does not exist. Omitting." + continue + fi + paths+=($path) + done + printf $paths | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' +} + +function svn_update() +{ + args=("$@") + paths="" + + for elem in "${args[@]}" + do + if [[ ! -d $elem ]]; then + echo "Warning: $elem does not exist. Omitting." + continue + fi + + pushd "$elem" &>/dev/null + echo "Updating $elem ..." + svn up --non-interactive --accept theirs-conflict + popd &>/dev/null + + done +} diff --git a/include/sysinfo.sh b/include/sysinfo.sh new file mode 100644 index 0000000..76dbca8 --- /dev/null +++ b/include/sysinfo.sh @@ -0,0 +1,70 @@ +function check_which +{ + path="$1" + which $path &>/dev/null + status=$? + echo "$status" +} + +# For conda INSTALLERS +sysinfo_platform=`uname` +case $sysinfo_platform in + Darwin) + sysinfo_platform="MacOSX" + ;; + *) ;; +esac + +sysinfo_arch=`uname -m` +case $sysinfo_arch in + i*86) + sysinfo_arch="x86" + ;; + *) ;; +esac + +case $sysinfo_platform in + Linux) + sysinfo_fetch="wget" + sysinfo_fetch_args="-q" + ;; + *) + sysinfo_fetch="curl" + sysinfo_fetch_args="-s -L -O" + ;; +esac + +# For conda BUILDS +function conda_arch +{ + local platform= + local arch= + + case `uname` in + Linux) + platform="linux" + ;; + Darwin) + platform="osx" + ;; + *) + echo "Unsupported platform." + exit 1 + ;; + esac + + case `uname -m` in + i*86) + arch=32 + ;; + x86_64) + arch=64 + ;; + *) + echo "Unsupported architecture." + exit 1 + ;; + esac + + echo "${platform}-${arch}" +} diff --git a/include/texlive.sh b/include/texlive.sh new file mode 100644 index 0000000..a13b2d0 --- /dev/null +++ b/include/texlive.sh @@ -0,0 +1,21 @@ +#!/bin/bash +source /eng/ssb/auto/astroconda/include/sysinfo.sh + +TL_HOME=/eng/ssb/sw/texlive + +# Be realistic - I already know what's in there... 32/64-linux +if [[ $sysinfo_platform != Linux ]]; then + echo "FATAL: $TL_HOME does not contain libraries for your platform." + exit 1 +fi + +TL_PLATFORM=`$TL_HOME/install-tl --print-platform` +export PATH="$TL_HOME/bin/${TL_PLATFORM}:$PATH" + +if [[ `which latex` != $TL_HOME/* ]]; then + echo "WARNING: TexLive is not where we wanted it to be! $TL_HOME may be broken or missing." +else + echo "Using TexLive: $TL_HOME" +fi + + diff --git a/interactive.sh b/interactive.sh new file mode 100755 index 0000000..2ddaa3f --- /dev/null +++ b/interactive.sh @@ -0,0 +1,4 @@ +#!/bin/bash +source /eng/ssb/auto/astroconda/include/midnight_special.sh +export TERM=xterm +PS1="[special] \u@\h:\w$ " bash |