<commit_before>import json
import argparse
import logging
import sys

from dock import build_image_here, build_image_in_privileged_container, \
    build_image_using_hosts_docker, set_logging
from dock.constants import CONTAINER_BUILD_JSON_PATH, CONTAINER_RESULTS_JSON_PATH
from dock.buildimage import BuildImageBuilder
from dock.inner import BuildResultsEncoder, build_inside, BuildResults


logger = logging.getLogger('dock')


def cli_create_build_image(args):
    b = BuildImageBuilder(dock_tarball_path=args.dock_tarball_path,
                          dock_local_path=args.dock_local_path,
                          dock_remote_path=args.dock_remote_git,
                          use_official_dock_git=args.dock_latest)
    try:
        b.create_image(args.dockerfile_dir_path, args.image, use_cache=args.use_cache)
    except RuntimeError:
        logger.error("Build failed.")
        sys.exit(1)


def cli_build_image(args):
    if args.json:<commit_msg>build image: exit with 0 when successful<commit_after>import json
import argparse
import logging
import sys

from dock import build_image_here, build_image_in_privileged_container, \
    build_image_using_hosts_docker, set_logging
from dock.constants import CONTAINER_BUILD_JSON_PATH, CONTAINER_RESULTS_JSON_PATH
from dock.buildimage import BuildImageBuilder
from dock.inner import BuildResultsEncoder, build_inside, BuildResults


logger = logging.getLogger('dock')


def cli_create_build_image(args):
    b = BuildImageBuilder(dock_tarball_path=args.dock_tarball_path,
                          dock_local_path=args.dock_local_path,
                          dock_remote_path=args.dock_remote_git,
                          use_official_dock_git=args.dock_latest)
    try:
        b.create_image(args.dockerfile_dir_path, args.image, use_cache=args.use_cache)
    except RuntimeError:
        logger.error("Build failed.")
        sys.exit(1)
    sys.exit(0)


def cli_build_image(args):
    if args.json:
{'fraction_non_alphanumeric': 0.0639269406392694, 'fraction_numerical': 0.0020294266869609334, 'mean_word_length': 3.774818401937046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3463975', 'n_tokens_mistral': 627, 'n_tokens_neox': 591, 'n_words': 110}