<commit_before>#!/bin/sh

# Include shared
source /vagrant/dev-up/shared.sh

HOST_CACHE=/vagrant/dev-up/cache/tce/
GUEST_CACHE=/tmp/tce/optional/

if [ -z $1 ]; then
  error_exit "No packages specified for cached installation"
fi

# Load host cache
if [ -d $HOST_CACHE ] && [ `ls $HOST_CACHE | wc -l` -gt 0 ] ; then
  yes n | cp  $HOST_CACHE* $GUEST_CACHE
fi

# Install specified packages
for ext in $@
do
  su -c "tce-load -i $ext" docker &>/dev/null
  if [ ! $? -eq 0 ]; then
    echo "Downloading tce package $ext..."
    su -c "tce-load -wi $ext" docker &>/dev/null
  fi
done

# Save guest cache
if [ ! -d $GUEST_CACHE ]; then
  mkdir $GUEST_CACHE || error_exit "Could not create host directory $GUEST_CACHE for tce caching"
fi

if [ `ls $GUEST_CACHE | wc -l` -gt 0 ]; then
  yes n | cp $GUEST_CACHE* $HOST_CACHE
fi

echo "Installed and cached requested tce packages"<commit_msg>Cache: Fixed issue when cache dir is missing<commit_after>#!/bin/sh

# Include shared
source /vagrant/dev-up/shared.sh

HOST_CACHE_DIR=/vagrant/dev-up/cache
HOST_CACHE=$HOST_CACHE_DIR/tce/
GUEST_CACHE=/tmp/tce/optional/

if [ -z $1 ]; then
  error_exit "No packages specified for cached installation"
fi

# Load host cache
if [ -d $HOST_CACHE ] && [ `ls $HOST_CACHE | wc -l` -gt 0 ] ; then
  yes n | cp  $HOST_CACHE* $GUEST_CACHE
fi

# Install specified packages
for ext in $@
do
  su -c "tce-load -i $ext" docker &>/dev/null
  if [ ! $? -eq 0 ]; then
    echo "Downloading tce package $ext..."
    su -c "tce-load -wi $ext" docker &>/dev/null
  fi
done

# Save guest cache
if [ ! -d $HOST_CACHE_DIR ]; then
  mkdir -p $HOST_CACHE_DIR || error_exit "Could not create host directory $HOST_CACHE_DIR for tce caching"
fi
if [ ! -d $HOST_CACHE ]; then
  mkdir -p $HOST_CACHE || error_exit "Could not create host directory $HOST_CACHE for tce caching"
fi

if [ `ls $GUEST_CACHE | wc -l` -gt 0 ]; then
  yes n | cp $GUEST_CACHE* $HOST_CACHE
fi

echo "Installed and cached requested tce packages"
{'fraction_non_alphanumeric': 0.1262677484787018, 'fraction_numerical': 0.004056795131845842, 'mean_word_length': 3.3942093541202674, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '745183', 'n_tokens_mistral': 755, 'n_tokens_neox': 738, 'n_words': 248}