<commit_before>#!/usr/bin/env bash
# DeepDive Installer
set -eu

: ${RELEASE:=v0.7.0}                        # the DeepDive release version to install
: ${PREFIX:=~/local/deepdive}               # the path to install deepdive

: ${INSTALLER_BRANCH:=${BRANCH:-v0.7.x}}    # the branch from which the installer scripts should be downloaded
INSTALLER_HOME_URL=https://github.com/HazyResearch/deepdive/raw/"${INSTALLER_BRANCH}"/util/install
INSTALLER_HOME_DIR=$(dirname "$0")/install

# run the correct installer directly from GitHub if BRANCH is specified
[[ -z "${BRANCH:-}" || -n "${INSTALLER_REMOTE_EXEC:-}" ]] ||
    INSTALLER_REMOTE_EXEC=true \
    exec bash <(set -x; curl -fsSL "${INSTALLER_HOME_URL}.sh") "$@"

running_from_git=true; [[ -e "$INSTALLER_HOME_DIR"/../../.git ]] || running_from_git=false
has() { type "$@"; } &>/dev/null
error() { echo "$@"; false; } >&2

# common installers ###########################################################
# installs DeepDive's build dependencies
install_deepdive_build_deps() { false; }
# installs DeepDive's runtime dependencies
install_deepdive_runtime_deps() { false; }
# fetches DeepDive source tree
install_deepdive_git_repo() {
    if $running_from_git; then
        cd "$INSTALLER_HOME_DIR"/../..
    else
        git clone --recursive --branch "$INSTALLER_BRANCH" https://github.com/HazyResearch/deepdive.git
        cd deepdive
    fi
}
# installs DeepDive from source by going through the full build
install_deepdive_from_source() {
    # prepare fetching and building source
    run_installer_for deepdive_build_deps
    run_installer_for deepdive_git_repo
    # install DeepDive from source
    make install PREFIX="$PREFIX"
    # install runtime dependencies
    run_installer_for deepdive_runtime_deps
}
# installs DeepDive with a release binary
install_deepdive_release() {
    local os=$(uname)
    local tarball="deepdive-${RELEASE}-${os}.tar.gz"
    local url="https://github.com/HazyResearch/deepdive/releases/download/${RELEASE}/$tarball"
    # showing what is going on
    (
    set -x
    rm -f "$tarball"
    # download tarball
    curl -fLRO "$url" || wget -N "$url"
    # unpack tarball
    mkdir -p "$PREFIX"
    tar xzvf "$tarball" -C "$PREFIX"
    )
    echo
    echo "DeepDive release $RELEASE has been installed at $PREFIX"
    echo "Please add the following line to your ~/.bashrc:"
    echo '  export PATH="$PREFIX"/bin:"$PATH"'
}
# installs DeepDive with a release binary and runtime dependencies
install_deepdive() {<commit_msg>Fixes binary installer to stop on failure<commit_after>#!/usr/bin/env bash
# DeepDive Installer
set -eu

: ${RELEASE:=v0.7.0}                        # the DeepDive release version to install
: ${PREFIX:=~/local/deepdive}               # the path to install deepdive

: ${INSTALLER_BRANCH:=${BRANCH:-v0.7.x}}    # the branch from which the installer scripts should be downloaded
INSTALLER_HOME_URL=https://github.com/HazyResearch/deepdive/raw/"${INSTALLER_BRANCH}"/util/install
INSTALLER_HOME_DIR=$(dirname "$0")/install

# run the correct installer directly from GitHub if BRANCH is specified
[[ -z "${BRANCH:-}" || -n "${INSTALLER_REMOTE_EXEC:-}" ]] ||
    INSTALLER_REMOTE_EXEC=true \
    exec bash <(set -x; curl -fsSL "${INSTALLER_HOME_URL}.sh") "$@"

running_from_git=true; [[ -e "$INSTALLER_HOME_DIR"/../../.git ]] || running_from_git=false
has() { type "$@"; } &>/dev/null
error() { echo "$@"; false; } >&2

# common installers ###########################################################
# installs DeepDive's build dependencies
install_deepdive_build_deps() { false; }
# installs DeepDive's runtime dependencies
install_deepdive_runtime_deps() { false; }
# fetches DeepDive source tree
install_deepdive_git_repo() {
    if $running_from_git; then
        cd "$INSTALLER_HOME_DIR"/../..
    else
        git clone --recursive --branch "$INSTALLER_BRANCH" https://github.com/HazyResearch/deepdive.git
        cd deepdive
    fi
}
# installs DeepDive from source by going through the full build
install_deepdive_from_source() {
    # prepare fetching and building source
    run_installer_for deepdive_build_deps
    run_installer_for deepdive_git_repo
    # install DeepDive from source
    make install PREFIX="$PREFIX"
    # install runtime dependencies
    run_installer_for deepdive_runtime_deps
}
# installs DeepDive with a release binary
install_deepdive_release() {
    local os=$(uname)
    local tarball="deepdive-${RELEASE}-${os}.tar.gz"
    local url="https://github.com/HazyResearch/deepdive/releases/download/${RELEASE}/$tarball"
    (
    # showing what is going on
    set -x
    rm -f "$tarball"
    # download tarball
    curl -fLRO "$url" || wget -N "$url"
    # unpack tarball
    mkdir -p "$PREFIX"
    tar xzvf "$tarball" -C "$PREFIX"
    ) || return $?
    echo
    echo "DeepDive release $RELEASE has been installed at $PREFIX"
    echo "Please add the following line to your ~/.bashrc:"
    echo '  export PATH="$PREFIX"/bin:"$PATH"'
}
# installs DeepDive with a release binary and runtime dependencies
install_deepdive() {
{'fraction_non_alphanumeric': 0.14570582428430404, 'fraction_numerical': 0.002764067127344521, 'mean_word_length': 3.8155893536121672, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2682136', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1603, 'n_words': 419}