<commit_before>#!/bin/bash
#                          _       _
#__      _____  __ ___   ___  __ _| |_ ___
#\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
# \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
#  \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
#
# Copyright © 2016 Weaviate. All rights reserved.
# LICENSE: https://github.com/weaviate/weaviate/blob/master/LICENSE
# AUTHOR: <NAME> (<EMAIL>)
# See www.weaviate.com for details
# Contact: @weaviate_iot / <EMAIL>
#

# check if root
if [ "$EUID" -ne 0 ]
    then echo "Please run as root"
    exit
fi

# check OS
if [[ "$OSTYPE" == "win32" ]]; then
    echo "SORRY, NO WINDOWS SUPPORT"
    exit 1
fi

# check if jq is installed
jq --help >/dev/null 2>&1 || { echo >&2 "I require jq but it's not installed. Aborting."; exit 1; }

# check if docker is installed
docker ps >/dev/null 2>&1 || { echo >&2 "I require Docker to run but it's not running. Aborting."; exit 1; }

# get all running docker container names
containers=$(docker ps | awk '{if(NR>1) print $NF}')
host=$(hostname)

# loop through all containers and stop weaviate and dgraph ones
for container in $containers
do
    if [[ $container == *"dgraph"* ]] ||  [[ $container == *"weaviate"* ]]; then
        echo "STOPPING: $container"
        docker kill $container &>/dev/null
    fi
done

# remove dgraph and weaviate
docker rm dgraph &>/dev/null || true
docker rm weaviate &>/dev/null || true

# build and start dgraph docker
mkdir -p ~/dgraph
DGRAPHID=$(docker run -itd -p 8080:8080 -p 9080:9080 -v ~/dgraph:/dgraph --name dgraph dgraph/dgraph dgraph --bindall=true --memory_mb 2048)
DGRAPHIP=$(docker inspect $DGRAPHID | jq -r '.[0].NetworkSettings.IPAddress')

# build and start weaviate docker
ECHO "BUILDING WITH DGRAPH IP: $DGRAPHIP"
docker build --no-cache --build-arg DGRAPHIP=$DGRAPHIP -t weaviate "https://raw.githubusercontent.com/weaviate/weaviate/develop/docker/Dockerfile?i=$(echo $((1 + RANDOM % 999999)))"
WEAVIATEID=$(docker run -d weaviate)
WEAVIATEIP=$(docker inspect $WEAVIATEID | jq -r '.[0].NetworkSettings.IPAddress')

# Return end-point
echo "Next line contains Weaviate IP + Weaviate ID seperated by a vertical bar (|)"
echo "WEAVIATE|$WEAVIATEIP|$WEAVIATEID"<commit_msg>gh-216: specify sudo<commit_after>#!/bin/bash
#                          _       _
#__      _____  __ ___   ___  __ _| |_ ___
#\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
# \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
#  \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
#
# Copyright © 2016 Weaviate. All rights reserved.
# LICENSE: https://github.com/weaviate/weaviate/blob/master/LICENSE
# AUTHOR: <NAME> (<EMAIL>)
# See www.weaviate.com for details
# Contact: @weaviate_iot / <EMAIL>
#

# check OS
if [[ "$OSTYPE" == "win32" ]]; then
    echo "SORRY, NO WINDOWS SUPPORT"
    exit 1
fi

# check if jq is installed
jq --help >/dev/null 2>&1 || { echo >&2 "I require jq but it's not installed. Aborting."; exit 1; }

# check if docker is installed
sudo docker ps >/dev/null 2>&1 || { echo >&2 "I require Docker to run but it's not running. Aborting."; exit 1; }

# get all running docker container names
containers=$(sudo docker ps | awk '{if(NR>1) print $NF}')
host=$(hostname)

# loop through all containers and stop weaviate and dgraph ones
for container in $containers
do
    if [[ $container == *"dgraph"* ]] ||  [[ $container == *"weaviate"* ]]; then
        echo "STOPPING: $container"
        docker kill $container &>/dev/null
    fi
done

# remove dgraph and weaviate
docker rm dgraph &>/dev/null || true
docker rm weaviate &>/dev/null || true

# build and start dgraph docker
mkdir -p ~/dgraph
DGRAPHID=$(sudo docker run -itd -p 8080:8080 -p 9080:9080 -v ~/dgraph:/dgraph --name dgraph dgraph/dgraph dgraph --bindall=true --memory_mb 2048)
DGRAPHIP=$(sudo docker inspect $DGRAPHID | jq -r '.[0].NetworkSettings.IPAddress')

# build and start weaviate docker
ECHO "BUILDING WITH DGRAPH IP: $DGRAPHIP"
sudo docker build --no-cache --build-arg DGRAPHIP=$DGRAPHIP -t weaviate "https://raw.githubusercontent.com/weaviate/weaviate/develop/docker/Dockerfile?i=$(echo $((1 + RANDOM % 999999)))"
WEAVIATEID=$(sudo docker run -d weaviate)
WEAVIATEIP=$(sudo docker inspect $WEAVIATEID | jq -r '.[0].NetworkSettings.IPAddress')

# Return end-point
echo "Next line contains Weaviate IP + Weaviate ID seperated by a vertical bar (|)"
echo "WEAVIATE|$WEAVIATEIP|$WEAVIATEID"
{'fraction_non_alphanumeric': 0.15668731360403762, 'fraction_numerical': 0.021564579031888048, 'mean_word_length': 3.23712342079689, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 29, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, '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': '732740', 'n_tokens_mistral': 1724, 'n_tokens_neox': 1572, 'n_words': 457}