<commit_before>#! /bin/bash

#Script that gives you a test Datacats environment, to check the workflow works

NAME=${1:-master}
BRANCH=${2:-master}
WORKDIR="$(readlink -f "${3:-.}")"

TARGET="$WORKDIR/$NAME"
mkdir -p "$TARGET"
mkdir -p "$TARGET/ini"
mkdir -p "$TARGET/venv"

#Setup the virtualenv
id=$(cat setup_ckan.sh | docker run -i -a stdin \
    -e "BRANCH=$BRANCH" \
    -v $TARGET/venv:/usr/lib/ckan \
    -v $TARGET/ini:/etc/ckan/default \
    datacats_web /bin/bash)
test $(docker wait $id) -eq 0

#Run postgres
docker run -d --name="datacats_db_${NAME}" datacats_db

#Run Solr
docker run -d --name="datacats_solr_${NAME}" \
    -v $TARGET/venv/src/ckan/ckan/config/solr/schema.xml:/etc/solr/conf/schema.xml \
    datacats_solr

#Initialize the ckan .ini files
id=$(cat init_ini.sh | docker run -i -a stdin \
    -v $TARGET/venv:/usr/lib/ckan \
    -v $TARGET/ini:/etc/ckan/default \
    datacats_web /bin/bash)
test $(docker wait $id) -eq 0

# create a writable version of the ckan INI file
cp "$TARGET/ini/default.production.ini" "$TARGET/ini/production.ini"

#Initialize the database
id=$(docker run -i -a stdin \
    -v $TARGET/venv:/usr/lib/ckan \
    -v $TARGET/ini:/etc/ckan/default \
    --link "datacats_solr_${NAME}":solr \
    --link "datacats_db_${NAME}":db \
    datacats_web /usr/lib/ckan/bin/paster --plugin=ckan db init -c /etc/ckan/default/production.ini)
test $(docker wait $id) -eq 0

# copy the wsgi file into the mounted host volume so that our user owns it
cp web/apache.wsgi "$TARGET/ini/apache.wsgi"
<commit_msg>noisier setup_ckan<commit_after>#! /bin/bash

#Script that gives you a test Datacats environment, to check the workflow works
set -e

NAME="${1:-master}"
BRANCH="${2:-master}"
WORKDIR="$(readlink -f "${3:-.}")"
DATADIR="${HOME}/.datacats/${NAME}"

TARGET="$WORKDIR/$NAME"
mkdir -p "$DATADIR"
mkdir "$DATADIR/venv"
mkdir "$DATADIR/solr"
mkdir "$DATADIR/db"
mkdir "$DATADIR/storage"
mkdir "$TARGET"
mkdir "$TARGET/ini"
mkdir "$TARGET/src"

#Setup the virtualenv
docker run -i \
    -e "BRANCH=$BRANCH" \
    -v "$DATADIR/venv:/usr/lib/ckan" \
    -v "$TARGET/src:/project/src" \
    -v "$TARGET/ini:/etc/ckan/default" \
    datacats_web /bin/bash < setup_ckan.sh

echo Starting DB
#Run postgres
docker run -d --name="datacats_db_${NAME}" datacats_db

echo Starting Solr
#Run Solr
docker run -d --name="datacats_solr_${NAME}" \
    -v $TARGET/venv/src/ckan/ckan/config/solr/schema.xml:/etc/solr/conf/schema.xml \
    datacats_solr

#Initialize the ckan .ini files
id=$(cat init_ini.sh | docker run -i -a stdin \
    -v $TARGET/venv:/usr/lib/ckan \
    -v $TARGET/ini:/etc/ckan/default \
    datacats_web /bin/bash)
test $(docker wait $id) -eq 0

# create a writable version of the ckan INI file
cp "$TARGET/ini/default.production.ini" "$TARGET/ini/production.ini"

#Initialize the database
id=$(docker run -i -a stdin \
    -v $TARGET/venv:/usr/lib/ckan \
    -v $TARGET/ini:/etc/ckan/default \
    --link "datacats_solr_${NAME}":solr \
    --link "datacats_db_${NAME}":db \
    datacats_web /usr/lib/ckan/bin/paster --plugin=ckan db init -c /etc/ckan/default/production.ini)
test $(docker wait $id) -eq 0

# copy the wsgi file into the mounted host volume so that our user owns it
cp web/apache.wsgi "$TARGET/ini/apache.wsgi"

{'fraction_non_alphanumeric': 0.16488222698072805, 'fraction_numerical': 0.00336494340776996, 'mean_word_length': 3.383378016085791, 'pattern_counts': {'":': 4, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '6294064', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1265, 'n_words': 317}