<commit_before>#!/usr/bin/env bash

set -o pipefail -o errtrace -o errexit -o nounset
# ubuntu in ci might not have bash 4.4
if [[ -n "$(shopt | grep inherit_errexit)" ]] ; then
  shopt -s inherit_errexit
fi

[[ -n "${TRACE:-}" ]] && set -o xtrace

declare errmsg="ERROR (${0##*/})":
trap 'echo >&2 $errmsg trap on error \(rc=${PIPESTATUS[@]}\) near line $LINENO' ERR

EXEC=(docker exec --interactive "${NETWORK_CONTAINER:?Network container name unset}")
CURL=(curl --silent --write-out '%{http_code}' --output /dev/null --connect-timeout 10)

docker_cleanup() {
  local cid="$1"
  # Place logs in similarly named file
  mkdir -p tmp/out
  local l_logfile="tmp/out/${cid}.log"

  docker logs "${cid}" > "${l_logfile}" || echo "failed to write log"
  docker rm --force "${cid}" > /dev/null 2>&1 || true
  docker network disconnect "${COMPOSE_NETWORK}" "${NETWORK_CONTAINER}" > /dev/null 2>&1 || true
  docker rm --force "${NETWORK_CONTAINER}" > /dev/null 2>&1 || true
}

docker_ensure_network_container() {
  if ! output=$(docker inspect "${NETWORK_CONTAINER:?Network container name unset}" 2> /dev/null); then
    network_container_image_id=$(cat tmp/.image-id-network-container)
    docker run --rm --detach --interactive --name="${NETWORK_CONTAINER:?Network container name unset}" > /dev/null \
    "${network_container_image_id}"
  fi
  docker network connect "${COMPOSE_NETWORK}" "${NETWORK_CONTAINER}" > /dev/null 2>&1 || true
}

docker_restart() {
  local l_cname="$1"
  docker restart "${l_cname}" >/dev/null
}<commit_msg>Send stderr from docker logs to logfile as well in tests<commit_after>#!/usr/bin/env bash

set -o pipefail -o errtrace -o errexit -o nounset
# ubuntu in ci might not have bash 4.4
if [[ -n "$(shopt | grep inherit_errexit)" ]] ; then
  shopt -s inherit_errexit
fi

[[ -n "${TRACE:-}" ]] && set -o xtrace

declare errmsg="ERROR (${0##*/})":
trap 'echo >&2 $errmsg trap on error \(rc=${PIPESTATUS[@]}\) near line $LINENO' ERR

EXEC=(docker exec --interactive "${NETWORK_CONTAINER:?Network container name unset}")
CURL=(curl --silent --write-out '%{http_code}' --output /dev/null --connect-timeout 10)

docker_cleanup() {
  local cid="$1"
  # Place logs in similarly named file
  mkdir -p tmp/out
  local l_logfile="tmp/out/${cid}.log"

  docker logs "${cid}" >> "${l_logfile}" 2>&1 || echo "failed to write log"
  docker rm --force "${cid}" > /dev/null 2>&1 || true
  docker network disconnect "${COMPOSE_NETWORK}" "${NETWORK_CONTAINER}" > /dev/null 2>&1 || true
  docker rm --force "${NETWORK_CONTAINER}" > /dev/null 2>&1 || true
}

docker_ensure_network_container() {
  if ! output=$(docker inspect "${NETWORK_CONTAINER:?Network container name unset}" 2> /dev/null); then
    network_container_image_id=$(cat tmp/.image-id-network-container)
    docker run --rm --detach --interactive --name="${NETWORK_CONTAINER:?Network container name unset}" > /dev/null \
    "${network_container_image_id}"
  fi
  docker network connect "${COMPOSE_NETWORK}" "${NETWORK_CONTAINER}" > /dev/null 2>&1 || true
}

docker_restart() {
  local l_cname="$1"
  docker restart "${l_cname}" >/dev/null
}
{'fraction_non_alphanumeric': 0.17541036369488253, 'fraction_numerical': 0.011586739620212423, 'mean_word_length': 4.232323232323233, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 31, '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': '2526347', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1068, 'n_words': 309}