<commit_before>#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
Run a Docker image used by a Make task.

This script does _not_ run inside a container, so it has to work on any
system.  This means:
 1. No third-party Python libraries!
 2. Python 2 and Python 3 compatible.

Arguments after the two flags are passed directly to ``docker run``.

"""

import argparse
import os
import subprocess

from tooling import ROOT


def _aws_credentials_args():
    """
    Returns the arguments to add to ``docker run`` for sharing AWS credentials
    with the running container.
    """
    if 'AWS_ACCESS_KEY_ID' in os.environ:
        print('*** Trying environment variables for AWS config...')
        return [
            '--env', 'AWS_ACCESS_KEY_ID=%s' % os.environ.get('AWS_SECRET_KEY_ID', ''),
            '--env', 'AWS_SECRET_ACCESS_KEY=%s' % os.environ.get('AWS_SECRET_ACCESS_KEY', ''),
            '--env', 'AWS_REGION=%s' % os.environ.get('AWS_REGION', ''),
            '--env', 'AWS_DEFAULT_REGION=%s' % os.environ.get('AWS_DEFAULT_REGION', ''),
        ]
    else:
        print('*** Missing environment variable, using ~/.aws')
        aws_path = os.path.join(os.environ['HOME'], '.aws')
        return ['--volume', '%s:/root/.aws' % aws_path]


def parse_args():
    parser = argparse.ArgumentParser(
        description='Run a Docker image used by a Make task.'
    )
    parser.add_argument(
        '--aws', dest='share_aws_creds', action='store_const', const=True,
        help='Whether to share AWS credentials with the running container'
    )
    parser.add_argument(
        '--dind', dest='docker_in_docker', action='store_const', const=True,
        help='Whether to allow this container to run Docker'
    )
    return parser.parse_known_args()<commit_msg>Fix the env variable lookup<commit_after>#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
Run a Docker image used by a Make task.

This script does _not_ run inside a container, so it has to work on any
system.  This means:
 1. No third-party Python libraries!
 2. Python 2 and Python 3 compatible.

Arguments after the two flags are passed directly to ``docker run``.

"""

import argparse
import os
import subprocess

from tooling import ROOT


def _aws_credentials_args():
    """
    Returns the arguments to add to ``docker run`` for sharing AWS credentials
    with the running container.
    """
    if 'AWS_ACCESS_KEY_ID' in os.environ:
        print('*** Trying environment variables for AWS config...')
        return [
            '--env', 'AWS_ACCESS_KEY_ID=%s' % os.environ.get('AWS_ACCESS_KEY_ID', ''),
            '--env', 'AWS_SECRET_ACCESS_KEY=%s' % os.environ.get('AWS_SECRET_ACCESS_KEY', ''),
            '--env', 'AWS_REGION=%s' % os.environ.get('AWS_REGION', ''),
            '--env', 'AWS_DEFAULT_REGION=%s' % os.environ.get('AWS_DEFAULT_REGION', ''),
        ]
    else:
        print('*** Missing environment variable, using ~/.aws')
        aws_path = os.path.join(os.environ['HOME'], '.aws')
        return ['--volume', '%s:/root/.aws' % aws_path]


def parse_args():
    parser = argparse.ArgumentParser(
        description='Run a Docker image used by a Make task.'
    )
    parser.add_argument(
        '--aws', dest='share_aws_creds', action='store_const', const=True,
        help='Whether to share AWS credentials with the running container'
    )
    parser.add_argument(
        '--dind', dest='docker_in_docker', action='store_const', const=True,
        help='Whether to allow this container to run Docker'
    )
    return parser.parse_known_args()
{'fraction_non_alphanumeric': 0.13692480359147025, 'fraction_numerical': 0.0028058361391694723, 'mean_word_length': 3.0282485875706215, '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': '2055799', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1108, 'n_words': 327}