<commit_before>#!/bin/bash -eu

source config/ec2_ln

echo EC2_HOST=${EC2_HOST}
echo EC2_SSH_KEY=${EC2_SSH_KEY}
echo LNTYPE=${LNTYPE}
echo TRAINING_DATA_GZ=${TRAINING_DATA_GZ}
echo SUNFISH_REPO=${SUNFISH_REPO}
echo TARGET_BRANCH=${TARGET_BRANCH}
echo BUILD_TARGET=${BUILD_TARGET}
echo WORK_DIR=${WORK_DIR}

TRAINING_DATA_GZ_NAME=`basename ${TRAINING_DATA_GZ}`

YUM_PACKAGES="git gcc-c++ cmake"

if [ "x${LNTYPE}" == "xonline" ]; then
	CONF_FILE_PATH="config/online_learn.ini"
else
	CONF_FILE_PATH="config/batch_learn.ini"
fi
CONF_FILE_NAME=`basename ${CONF_FILE_PATH}`

REVISION_FILE=revision

DATE=`date "+%Y-%m-%d"`
DATE_FILE=date

EVAL_EX_BIN_GZ="eval-ex.bin.gz"
EVAL_EX_BIN="eval-ex.bin"

LOCAL_BACKUP_DIR=${BACKUP_DIR}/${DATE}_${NAME}_${EC2_HOST}

if [ -e ${LOCAL_BACKUP_DIR} ]; then
	echo "error: ${LOCAL_BACKUP_DIR} is already exists."
	exit 1
fi

mkdir -p ${LOCAL_BACKUP_DIR}
cp ${CONF_FILE_PATH} ${LOCAL_BACKUP_DIR}/

scp -i ${EC2_SSH_KEY} ${REMOTE_BACKUP_KEY} ec2-user@${EC2_HOST}:~/.ssh/id_rsa
scp -i ${EC2_SSH_KEY} ${TRAINING_DATA_GZ} ec2-user@${EC2_HOST}:~/
scp -i ${EC2_SSH_KEY} ${CONF_FILE_PATH} ec2-user@${EC2_HOST}:~/
if [ "x${SRC_EVAL_EX_BIN_GZ}" != "x" ]; then
	scp -i ${EC2_SSH_KEY} ${SRC_EVAL_EX_BIN_GZ} ec2-user@${EC2_HOST}:~/${EVAL_EX_BIN_GZ}
fi

ssh -i ${EC2_SSH_KEY} -t -t ec2-user@${EC2_HOST} <<EOF
	#!/bin/bash -eu<commit_msg>Update script<commit_after>#!/bin/bash -eu

source config/ec2_ln

echo EC2_HOST=${EC2_HOST}
echo EC2_SSH_KEY=${EC2_SSH_KEY}
echo LNTYPE=${LNTYPE}
echo TRAINING_DATA_GZ=${TRAINING_DATA_GZ}
echo SUNFISH_REPO=${SUNFISH_REPO}
echo TARGET_BRANCH=${TARGET_BRANCH}
echo BUILD_TARGET=${BUILD_TARGET}
echo WORK_DIR=${WORK_DIR}

TRAINING_DATA_GZ_NAME=training.dat.gz

YUM_PACKAGES="git gcc-c++ cmake"

if [ "x${LNTYPE}" == "xonline" ]; then
	CONF_FILE_PATH="config/online_learn.ini"
else
	CONF_FILE_PATH="config/batch_learn.ini"
fi
CONF_FILE_NAME=`basename ${CONF_FILE_PATH}`

REVISION_FILE=revision

DATE=`date "+%Y-%m-%d"`
DATE_FILE=date

EVAL_EX_BIN_GZ="eval-ex.bin.gz"
EVAL_EX_BIN="eval-ex.bin"

LOCAL_BACKUP_DIR=${BACKUP_DIR}/${DATE}_${NAME}_${EC2_HOST}

if [ -e ${LOCAL_BACKUP_DIR} ]; then
	echo "error: ${LOCAL_BACKUP_DIR} is already exists."
	exit 1
fi

mkdir -p ${LOCAL_BACKUP_DIR}
cp ${CONF_FILE_PATH} ${LOCAL_BACKUP_DIR}/

scp -i ${EC2_SSH_KEY} ${REMOTE_BACKUP_KEY} ec2-user@${EC2_HOST}:~/.ssh/id_rsa
scp -i ${EC2_SSH_KEY} ${TRAINING_DATA_GZ} ec2-user@${EC2_HOST}:~/${TRAINING_DATA_GZ_NAME}
scp -i ${EC2_SSH_KEY} ${CONF_FILE_PATH} ec2-user@${EC2_HOST}:~/
if [ "x${SRC_EVAL_EX_BIN_GZ}" != "x" ]; then
	scp -i ${EC2_SSH_KEY} ${SRC_EVAL_EX_BIN_GZ} ec2-user@${EC2_HOST}:~/${EVAL_EX_BIN_GZ}
fi

ssh -i ${EC2_SSH_KEY} -t -t ec2-user@${EC2_HOST} <<EOF
	#!/bin/bash -eu
{'fraction_non_alphanumeric': 0.17605893186003682, 'fraction_numerical': 0.016206261510128914, 'mean_word_length': 7.25531914893617, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2720423', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1283, 'n_words': 189}