<commit_before>#!/bin/bash -xeE

# Setup paths
BASE_DIR=`pwd`
# Setup path to SLURM source from github. (shuld be passed through env or args).
SLURM_SOURCES=/home/artpol/WORK/Mellanox/src/SLURM/pmix/jenkins/slurm-git/slurm/
if [ ! -d $SLURM_SOURCES ]; then
    echo "No slurm sources found. Nothing to check"
    exit 0
fi
PREPARE_DIR=$BASE_DIR/dev_img
DEV_IMG_NAME="artpol/dev_img"
BUILD_DIR=$BASE_DIR/compile_img
BUILD_SRC=$BUILD_DIR/src
FINAL_DIR=$BASE_DIR/cluster_img
CLUSTER_IMG_NAME_FILE=`mktemp`
CLUSTER_IMG=`basename $tmp_file | tr '[:upper:]' '[:lower:]'`


fix_developer_image()
{
    # NOTE: we need to use <pipeline> || true to 
    # hide error exit code = 1 from grep
    tmp=`docker images | awk '{ print $1 }' | grep $DEV_IMG_NAME || true`
    if [ -z "$tmp" ]; then
        cd $PREPARE_DIR
        ./dev_img.sh
        cd $BASE_DIR
    fi
}

build_all()
{
    mkdir -p $BUILD_SRC
    cp -R $SLURM_SOURCES $BUILD_SRC
    cd $BUILD_DIR
    tmp_file=`mktemp`
    tmp_image=`basename $tmp_file | tr '[:upper:]' '[:lower:]'`
    ./prepare.sh $tmp_image
    rm $tmp_file
    cd $BASE_DIR
}

create_node_image()
{
    mv $BUILD_DIR/root.tar.bz2 $FINAL_DIR
    cd $FINAL_DIR
    docker build -t "$CLUSTER_IMG" .
    cd $BASE_DIR
}

#run_cluster()
#{
#    
#}


# Make sure that we have developer image ready for use.
# Developer image is the machine with full set of packages 
# nessesary to configure and build SLURM, PMIx, libevent and munge.
fix_developer_image

# Create temporal image based on dev_image and use 
# it to build everything
build_all

# Create final cluster/frontend node image
create_node_image

# run cluster
#run_cluster

# Cleanup temp filename
rm $CLUSTER_IMG_NAME_FILE<commit_msg>And one more small fix<commit_after>#!/bin/bash -xeE

# Setup paths
BASE_DIR=`pwd`
# Setup path to SLURM source from github. (shuld be passed through env or args).
SLURM_SOURCES=/home/artpol/WORK/Mellanox/src/SLURM/pmix/jenkins/slurm-git/slurm/
if [ ! -d $SLURM_SOURCES ]; then
    echo "No slurm sources found. Nothing to check"
    exit 0
fi
PREPARE_DIR=$BASE_DIR/dev_img
DEV_IMG_NAME="artpol/dev_img"
BUILD_DIR=$BASE_DIR/compile_img
BUILD_SRC=$BUILD_DIR/src
FINAL_DIR=$BASE_DIR/cluster_img
CLUSTER_IMG_NAME_FILE=`mktemp`
CLUSTER_IMG=`basename $CLUSTER_IMG_NAME_FILE | tr '[:upper:]' '[:lower:]'`


fix_developer_image()
{
    # NOTE: we need to use <pipeline> || true to 
    # hide error exit code = 1 from grep
    tmp=`docker images | awk '{ print $1 }' | grep $DEV_IMG_NAME || true`
    if [ -z "$tmp" ]; then
        cd $PREPARE_DIR
        ./dev_img.sh
        cd $BASE_DIR
    fi
}

build_all()
{
    mkdir -p $BUILD_SRC
    cp -R $SLURM_SOURCES $BUILD_SRC
    cd $BUILD_DIR
    tmp_file=`mktemp`
    tmp_image=`basename $tmp_file | tr '[:upper:]' '[:lower:]'`
    ./prepare.sh $tmp_image
    rm $tmp_file
    cd $BASE_DIR
}

create_node_image()
{
    mv $BUILD_DIR/root.tar.bz2 $FINAL_DIR
    cd $FINAL_DIR
    docker build -t "$CLUSTER_IMG" .
    cd $BASE_DIR
}

#run_cluster()
#{
#    
#}


# Make sure that we have developer image ready for use.
# Developer image is the machine with full set of packages 
# nessesary to configure and build SLURM, PMIx, libevent and munge.
fix_developer_image

# Create temporal image based on dev_image and use 
# it to build everything
build_all

# Create final cluster/frontend node image
create_node_image

# run cluster
#run_cluster

# Cleanup temp filename
rm $CLUSTER_IMG_NAME_FILE
{'fraction_non_alphanumeric': 0.10840579710144928, 'fraction_numerical': 0.002318840579710145, 'mean_word_length': 3.657219973009447, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6367854', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1295, 'n_words': 349}