<commit_before>#!/usr/bin/env python
# Copyright (c) 2016 Ansible, Inc.
# All Rights Reserved
import os
import sys

# Python
from collections import defaultdict
from optparse import make_option, OptionParser
from datetime import datetime
import logging


# Django
import django
from django.utils.timezone import now


base_dir = os.path.abspath(  # Convert into absolute path string
    os.path.join(  # Current file's grandparent directory
        os.path.join(  # Current file's parent directory
            os.path.dirname(  # Current file's directory
                os.path.abspath(__file__)  # Current file path
            ),
            os.pardir
        ),
        os.pardir
    )
)

if base_dir not in sys.path:
    sys.path.insert(1, base_dir)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "awx.settings.development") # noqa
django.setup() # noqa


from django.db import transaction # noqa

# awx
from awx.main.models import * # noqa
from awx.main.signals import ( # noqa
    disable_activity_stream,
    disable_computed_fields
)


option_list = [
    make_option('--organizations', action='store', type='int', default=3,
                help='Number of organizations to create'),
    make_option('--users', action='store', type='int', default=10,
                help='Number of users to create'),
    make_option('--teams', action='store', type='int', default=5,
                help='Number of teams to create'),
    make_option('--projects', action='store', type='int', default=10,
                help='Number of projects to create'),
    make_option('--job-templates', action='store', type='int', default=20,
                help='Number of job templates to create'),
    make_option('--credentials', action='store', type='int', default=5,
                help='Number of credentials to create'),
    make_option('--inventories', action='store', type='int', default=5,
                help='Number of credentials to create'),
    make_option('--inventory-groups', action='store', type='int', default=10,
                help='Number of credentials to create'),
    make_option('--inventory-hosts', action='store', type='int', default=40,
                help='number of credentials to create'),
    make_option('--wfjts', action='store', type='int', default=15,
                help='number of workflow job templates to create'),
    make_option('--nodes', action='store', type='int', default=200,
                help='number of workflow job template nodes to create'),
    make_option('--labels', action='store', type='int', default=100,
                help='labels to create, will associate 10x as many'),
    make_option('--jobs', action='store', type='int', default=200,
                help='number of job entries to create'),
    make_option('--job-events', action='store', type='int', default=500,
                help='number of job event entries to create'),
    make_option('--pretend', action='store_true',
                help="Don't commit the data to the database"),
    make_option('--preset', action='store', type='string', default='',
                help="Preset data set to use"),
    make_option('--prefix', action='store', type='string', default='',
                help="Prefix generated names with this string"),
    #make_option('--spread-bias', action='store', type='string', default='exponential',
    #            help='"exponential" to bias associations exponentially front loaded for - for ex'),
]
parser = OptionParser(option_list=option_list)
options, remainder = parser.parse_args()
options = vars(options)


if options['preset']:
    print ' Using preset data numbers set ' + str(options['preset'])
    # Read the numbers of resources from presets file, if provided
    presets_filename = os.path.abspath(os.path.join(
        os.path.dirname(os.path.abspath(__file__)), 'presets.tsv'))

    with open(presets_filename) as f:
        text = f.read()

    split_lines = [line.split('\t') for line in text.split('\n')]
    keys = split_lines[0][1:]

    try:
        col = keys.index(options['preset'])
    except ValueError:
        raise Exception('Preset "%s" dataset not found, options are %s' % (options['preset'], keys))

    options.update({cols[0]: cols[col + 1] for cols in split_lines})


n_organizations    = int(options['organizations'])
n_users            = int(options['users'])
n_teams            = int(options['teams'])
n_projects         = int(options['projects'])
n_job_templates    = int(options['job_templates'])<commit_msg>use dataset name as naming prefix<commit_after>#!/usr/bin/env python
# Copyright (c) 2016 Ansible, Inc.
# All Rights Reserved
import os
import sys

# Python
from collections import defaultdict
from optparse import make_option, OptionParser
from datetime import datetime
import logging


# Django
import django
from django.utils.timezone import now


base_dir = os.path.abspath(  # Convert into absolute path string
    os.path.join(  # Current file's grandparent directory
        os.path.join(  # Current file's parent directory
            os.path.dirname(  # Current file's directory
                os.path.abspath(__file__)  # Current file path
            ),
            os.pardir
        ),
        os.pardir
    )
)

if base_dir not in sys.path:
    sys.path.insert(1, base_dir)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "awx.settings.development") # noqa
django.setup() # noqa


from django.db import transaction # noqa

# awx
from awx.main.models import * # noqa
from awx.main.signals import ( # noqa
    disable_activity_stream,
    disable_computed_fields
)


option_list = [
    make_option('--organizations', action='store', type='int', default=3,
                help='Number of organizations to create'),
    make_option('--users', action='store', type='int', default=10,
                help='Number of users to create'),
    make_option('--teams', action='store', type='int', default=5,
                help='Number of teams to create'),
    make_option('--projects', action='store', type='int', default=10,
                help='Number of projects to create'),
    make_option('--job-templates', action='store', type='int', default=20,
                help='Number of job templates to create'),
    make_option('--credentials', action='store', type='int', default=5,
                help='Number of credentials to create'),
    make_option('--inventories', action='store', type='int', default=5,
                help='Number of credentials to create'),
    make_option('--inventory-groups', action='store', type='int', default=10,
                help='Number of credentials to create'),
    make_option('--inventory-hosts', action='store', type='int', default=40,
                help='number of credentials to create'),
    make_option('--wfjts', action='store', type='int', default=15,
                help='number of workflow job templates to create'),
    make_option('--nodes', action='store', type='int', default=200,
                help='number of workflow job template nodes to create'),
    make_option('--labels', action='store', type='int', default=100,
                help='labels to create, will associate 10x as many'),
    make_option('--jobs', action='store', type='int', default=200,
                help='number of job entries to create'),
    make_option('--job-events', action='store', type='int', default=500,
                help='number of job event entries to create'),
    make_option('--pretend', action='store_true',
                help="Don't commit the data to the database"),
    make_option('--preset', action='store', type='string', default='',
                help="Preset data set to use"),
    make_option('--prefix', action='store', type='string', default='',
                help="Prefix generated names with this string"),
    #make_option('--spread-bias', action='store', type='string', default='exponential',
    #            help='"exponential" to bias associations exponentially front loaded for - for ex'),
]
parser = OptionParser(option_list=option_list)
options, remainder = parser.parse_args()
options = vars(options)


if options['preset']:
    print ' Using preset data numbers set ' + str(options['preset'])
    # Read the numbers of resources from presets file, if provided
    presets_filename = os.path.abspath(os.path.join(
        os.path.dirname(os.path.abspath(__file__)), 'presets.tsv'))

    with open(presets_filename) as f:
        text = f.read()

    split_lines = [line.split('\t') for line in text.split('\n')]
    keys = split_lines[0][1:]

    try:
        col = keys.index(options['preset'])
    except ValueError:
        raise Exception('Preset "%s" dataset not found, options are %s' % (options['preset'], keys))

    options.update({cols[0]: cols[col + 1] for cols in split_lines})

    if not options['prefix']:
        options['prefix'] = options['preset']


n_organizations    = int(options['organizations'])
n_users            = int(options['users'])
n_teams            = int(options['teams'])
n_projects         = int(options['projects'])
n_job_templates    = int(options['job_templates'])
{'fraction_non_alphanumeric': 0.14032772462333662, 'fraction_numerical': 0.008578027053777632, 'mean_word_length': 3.2004618937644342, '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': '4223998', 'n_tokens_mistral': 2663, 'n_tokens_neox': 2534, 'n_words': 709}