<commit_before>from __future__ import unicode_literals
from fabric.api import local


def ssh(service):
    """
    ssh into running service container
    :param service: ['backend', 'frontend', 'proxy', 'db']
    """
    assert service in ['backend', 'frontend', 'proxy', 'db'], "%s is unrecognized service"
    if service == 'frontend':
        local('docker-compose exec frontend ash')
    else:
        local('docker-compose exec %s bash' % service)


def up_recreate():
    """
    Recreate containers even if their configuration and image haven't changed.
    """
    local('docker-compose down && docker-compose up')


def up():
    """
    Create and start containers.
    """
    local('docker-compose up')


def down():
    """
    Stop all containers.
    """
    local('docker-compose down')


def rebuild():
    """
    Re-build docker images for containers.
    """
    local('docker-compose build')


def ps():
    """
    Display all containers.
    """
    local('docker-compose ps')


def stop():
    """
    Stop services.
    """
    local('docker-compose stop')


def fakedata(quantity=50, clean_before=True):
    """
    Load example data from fakedata management command.
    """
    cmd = 'docker-compose exec backend python manage.py fakedata %d' % (int(quantity))
    if clean_before:
        cmd += ' --clean_before'
    local(cmd)


def reset_db():
    """
    Reset db, migrate and generate fixtures.
    Useful when changing branch with different migration.
    """
    local('docker-compose exec backend python manage.py reset_db')
    local('docker-compose exec backend python manage.py migrate')
    local('docker-compose exec backend python manage.py loaddata --app common initial.json')
    local('docker-compose exec backend python manage.py loaddata --app agency initial.json')
    fakedata(clean_before=False)


def tests():
    """
    Run unit tests.
    """
    local('docker-compose exec backend python manage.py test --parallel --noinput')


def remove_untagged_images():
    """
    Delete all untagged (<none>) images
    """
    local('docker rmi $(docker images | grep "^<none>" | awk "{print $3}")')


def pep8():
    """
    Run python code linter
    """
    local('docker-compose exec backend flake8 ./ --count')<commit_msg>added option te specify tests to be run<commit_after>from __future__ import unicode_literals
from fabric.api import local


def ssh(service):
    """
    ssh into running service container
    :param service: ['backend', 'frontend', 'proxy', 'db']
    """
    assert service in ['backend', 'frontend', 'proxy', 'db'], "%s is unrecognized service"
    if service == 'frontend':
        local('docker-compose exec frontend ash')
    else:
        local('docker-compose exec %s bash' % service)


def up_recreate():
    """
    Recreate containers even if their configuration and image haven't changed.
    """
    local('docker-compose down && docker-compose up')


def up():
    """
    Create and start containers.
    """
    local('docker-compose up')


def down():
    """
    Stop all containers.
    """
    local('docker-compose down')


def rebuild():
    """
    Re-build docker images for containers.
    """
    local('docker-compose build')


def ps():
    """
    Display all containers.
    """
    local('docker-compose ps')


def stop():
    """
    Stop services.
    """
    local('docker-compose stop')


def fakedata(quantity=50, clean_before=True):
    """
    Load example data from fakedata management command.
    """
    cmd = 'docker-compose exec backend python manage.py fakedata %d' % (int(quantity))
    if clean_before:
        cmd += ' --clean_before'
    local(cmd)


def reset_db():
    """
    Reset db, migrate and generate fixtures.
    Useful when changing branch with different migration.
    """
    local('docker-compose exec backend python manage.py reset_db')
    local('docker-compose exec backend python manage.py migrate')
    local('docker-compose exec backend python manage.py loaddata --app common initial.json')
    local('docker-compose exec backend python manage.py loaddata --app agency initial.json')
    fakedata(clean_before=False)


def tests(test_path=''):
    """
    Run unit tests.
    """
    local('docker-compose exec backend python manage.py test {} --parallel --noinput'.format(test_path))


def remove_untagged_images():
    """
    Delete all untagged (<none>) images
    """
    local('docker rmi $(docker images | grep "^<none>" | awk "{print $3}")')


def pep8():
    """
    Run python code linter
    """
    local('docker-compose exec backend flake8 ./ --count')
{'fraction_non_alphanumeric': 0.13451941852896507, 'fraction_numerical': 0.002169668040789759, 'mean_word_length': 3.001736111111111, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6286035', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1321, 'n_words': 422}