<commit_before>#!/bin/bash

ZUUL_LAYOUTDIR="$(dirname '<%= zuul_layout %>')"
JENKINS_JOB_URL="<%= jenkins_url %>/job/<%= jenkins_job %>/lastSuccessfulBuild/artifact/build/<%= @fqdn %>"
ZUUL_RELOAD="false"
ZUUL_TEMP="$(mktemp -d)"

diff_config() {
    diff -u "${ZUUL_LAYOUTDIR}/${1}" "${ZUUL_TEMP}/${1}"
}

# Get configs from Jenkins
curl -fLsS -o "${ZUUL_TEMP}/layout.yaml" "${JENKINS_JOB_URL}/layout.yaml"
curl -fLsS -o "${ZUUL_TEMP}/external_functions.py" "${JENKINS_JOB_URL}/external_functions.py"

# If files are not changed - just exit
if diff_config layout.yaml && diff_config external_functions.py; then
    rm -rf "${ZUUL_TEMP}"
    exit 0
fi

# Verify configs
if ! zuul-server -t -l "${ZUUL_TEMP}/layout.yaml"; then
    rm -rf "${ZUUL_TEMP}"
    exit 1
fi

# Diff and apply if needed
if ! diff_config layout.yaml; then
    cp "${ZUUL_TEMP}/layout.yaml" "${ZUUL_LAYOUTDIR}"
    ZUUL_RELOAD="true"
fi

if ! diff_config external_functions.py; then
    cp "${ZUUL_TEMP}/external_functions.py" "${ZUUL_LAYOUTDIR}"
    ZUUL_RELOAD="true"
fi

[ "${ZUUL_RELOAD}" ] && /etc/init.d/zuul reload

rm -rf "${ZUUL_TEMP}"
<commit_msg>Fix problem with zuul config reload<commit_after>#!/bin/bash

ZUUL_LAYOUTDIR="$(dirname '<%= zuul_layout %>')"
JENKINS_JOB_URL="<%= jenkins_url %>/job/<%= jenkins_job %>/lastSuccessfulBuild/artifact/build/<%= @fqdn %>"
ZUUL_RELOAD="false"
ZUUL_TEMP="$(mktemp -d)"

diff_config() {
    diff -u "${ZUUL_LAYOUTDIR}/${1}" "${ZUUL_TEMP}/${1}"
}

# Get configs from Jenkins
curl -fLsS -o "${ZUUL_TEMP}/layout.yaml" "${JENKINS_JOB_URL}/layout.yaml"
curl -fLsS -o "${ZUUL_TEMP}/external_functions.py" "${JENKINS_JOB_URL}/external_functions.py"

# If files are not changed - just exit
if diff_config layout.yaml && diff_config external_functions.py; then
    rm -rf "${ZUUL_TEMP}"
    exit 0
fi

# Verify configs
if ! zuul-server -t -l "${ZUUL_TEMP}/layout.yaml"; then
    rm -rf "${ZUUL_TEMP}"
    exit 1
fi

# Diff and apply if needed
if ! diff_config layout.yaml; then
    cp "${ZUUL_TEMP}/layout.yaml" "${ZUUL_LAYOUTDIR}"
    ZUUL_RELOAD="true"
fi

if ! diff_config external_functions.py; then
    cp "${ZUUL_TEMP}/external_functions.py" "${ZUUL_LAYOUTDIR}"
    ZUUL_RELOAD="true"
fi

[ "${ZUUL_RELOAD}" ] && service zuul reload

rm -rf "${ZUUL_TEMP}"

{'fraction_non_alphanumeric': 0.17311072056239016, 'fraction_numerical': 0.0035149384885764497, 'mean_word_length': 4.650124069478908, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3433988', 'n_tokens_mistral': 954, 'n_tokens_neox': 940, 'n_words': 192}