<commit_before>#!/bin/bash
set -e

# include dependencies
dir="${BASH_SOURCE%/*}"
if [[ ! -d "$dir" ]]; then dir="$PWD"; fi
. "$dir/captain_functions"

# transforms ETCD_VALUE_NAME to /etcd/path/to/key
# $1: env_key
etcd_key_from_env () {
  env_key="$1"
  local key=${env_key/ETCD_VALUE_/}
  local key="$(echo $key | awk '{print tolower($0)}')"
  local key="$ETCD_BASE_PATH$key"

  echo "$key"
}

while true; do
  envs="$(env)"

  while read -r env; do
    # set every ETCD_VALUE_[NAME]
    if [[ $env == *"ETCD_VALUE_"* ]]; then
      env_key="$(echo $env | awk -F'=' '{print $1}')"
      value="$(echo $env | awk -F'=' '{print $2}')"

      key="$(etcd_key_from_env $env_key)"

      echo "publish $key = $value to $ETCD_ENDPOINT with a ttl of $ETCD_TTL"
      echo "$(set_value $key $value $ETCD_TTL)"
    fi
  done <<< "$envs"

  sleep "$REFRESH_TIME"
done<commit_msg>no publishing empty keys and values<commit_after>#!/bin/bash
set -e

# include dependencies
dir="${BASH_SOURCE%/*}"
if [[ ! -d "$dir" ]]; then dir="$PWD"; fi
. "$dir/captain_functions"

# transforms ETCD_VALUE_NAME to /etcd/path/to/key
# $1: env_key
etcd_key_from_env () {
  env_key="$1"
  local key=${env_key/ETCD_VALUE_/}
  local key="$(echo $key | awk '{print tolower($0)}')"
  local key="$ETCD_BASE_PATH$key"

  echo "$key"
}

while true; do
  envs="$(env)"

  while read -r env; do
    # set every ETCD_VALUE_[NAME]
    if [[ $env == "ETCD_VALUE_"* ]]; then
      env_key="$(echo $env | awk -F'=' '{print $1}')"
      value="$(echo $env | awk -F'=' '{print $2}')"

      key="$(etcd_key_from_env $env_key)"

      if [[ (! -z "$key") && (! -z "$value") ]]; then
        echo "publish $key = $value to $ETCD_ENDPOINT with a ttl of $ETCD_TTL"
        echo "$(set_value $key $value $ETCD_TTL)"
      fi
    fi
  done <<< "$envs"

  sleep "$REFRESH_TIME"
done
{'fraction_non_alphanumeric': 0.19868995633187772, 'fraction_numerical': 0.0054585152838427945, 'mean_word_length': 3.470731707317073, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2136498', 'n_tokens_mistral': 751, 'n_tokens_neox': 718, 'n_words': 181}