<commit_before>#!/bin/bash

if [ "$#" -ne 1 ]; then
  echo: "USAGE: $0 environment_name" >& 2
  echo "environment_name should correspond to directory environments/environment_name"
  exit 1
fi

if [ ! -d "environments/$1/" ]; then
  echo "ERR: environments/$1 does not exist" >& 2
  exit 2
fi

if [ ! -f "environments/$1/Dockerfile" ]; then
  echo "ERR: environments/$1/Dockerfile does not exist" >& 2
  exit 3
fi

cd environments/$1/
docker build . -t prairielearn/$1:latest

if [ $? -ne 0 ]; then
  echo "ERR: building image failed. skipping upload." >& 2
  exit 4
fi

docker push prairielearn/$1<commit_msg>Enable releasing images to a tag other than latest<commit_after>#!/bin/bash

while getopts ":t:" o; do
    case "${o}" in
    t)
        t=${OPTARG}
        echo "found!"
        ;;
    *)
        echo "not found!"
        usage
        ;;
    esac
done

shift $(($OPTIND - 1))

if [ "$#" -ne 1 ]; then
  echo "USAGE: $0 environment_name [-t tag]" >& 2
  echo "environment_name should correspond to directory environments/environment_name"
  exit 1
fi

if [ ! -d "environments/$1/" ]; then
  echo "ERR: environments/$1 does not exist" >& 2
  exit 2
fi

if [ ! -f "environments/$1/Dockerfile" ]; then
  echo "ERR: environments/$1/Dockerfile does not exist" >& 2
  exit 3
fi

if [ -z "${t}" ]; then
    while true; do
        read -p "No tag specified; using \"latest\" by default. Continue? (y/n): " yn
        case $yn in
            [Yy]* ) break;;
            [Nn]* ) exit;;
            * ) echo "Please answer yes or no. ";;
        esac
    done
    t="latest"
fi

cd environments/$1/
docker build . -t prairielearn/$1

if [ $? -ne 0 ]; then
  echo "ERR: building image failed. skipping upload." >& 2
  exit 4
fi

docker push prairielearn/$1:${t}
{'fraction_non_alphanumeric': 0.1431818181818182, 'fraction_numerical': 0.021022727272727273, 'mean_word_length': 2.5504032258064515, 'pattern_counts': {'":': 1, '<': 3, '<?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': '6237763', 'n_tokens_mistral': 637, 'n_tokens_neox': 597, 'n_words': 210}