<commit_before>"""Provides initialization functionality for the Scale system"""
from __future__ import unicode_literals

import logging

from django.conf import settings
from django.db import transaction
from django.utils.timezone import now

from job.configuration.data.job_data import JobData
from job.models import Job, JobType
from queue.models import Queue
from scheduler.models import Scheduler
from trigger.models import TriggerEvent


logger = logging.getLogger(__name__)


def initialize_system():
    """Performs any necessary functions needed for initializing Scale"""

    logger.info('Initializing system')

    if settings.DEBUG:
        from pudb.remote import set_trace
        set_trace(term_size=(80, 24), port=settings.DEBUG_PORT)

    Scheduler.objects.initialize_scheduler()

    # Make sure clock job has been created
    clock_job_type = JobType.objects.get_clock_job_type()
    count = Job.objects.filter(job_type_id=clock_job_type.id).count()
    if not count:
        logger.info('Queuing Scale Clock job')
        with transaction.atomic():
            init_event = TriggerEvent.objects.create_trigger_event('SCALE_INIT', None, {}, now())
            Queue.objects.queue_new_job(clock_job_type, JobData(), init_event)<commit_msg>Opened up listener to all interfaces<commit_after>"""Provides initialization functionality for the Scale system"""
from __future__ import unicode_literals

import logging

from django.conf import settings
from django.db import transaction
from django.utils.timezone import now

from job.configuration.data.job_data import JobData
from job.models import Job, JobType
from queue.models import Queue
from scheduler.models import Scheduler
from trigger.models import TriggerEvent


logger = logging.getLogger(__name__)


def initialize_system():
    """Performs any necessary functions needed for initializing Scale"""

    logger.info('Initializing system')

    if settings.DEBUG:
        from pudb.remote import set_trace
        set_trace(term_size=(80, 50), host='0.0.0.0', port=settings.DEBUG_PORT)

    Scheduler.objects.initialize_scheduler()

    # Make sure clock job has been created
    clock_job_type = JobType.objects.get_clock_job_type()
    count = Job.objects.filter(job_type_id=clock_job_type.id).count()
    if not count:
        logger.info('Queuing Scale Clock job')
        with transaction.atomic():
            init_event = TriggerEvent.objects.create_trigger_event('SCALE_INIT', None, {}, now())
            Queue.objects.queue_new_job(clock_job_type, JobData(), init_event)
{'fraction_non_alphanumeric': 0.08349666797334379, 'fraction_numerical': 0.004704037632301058, 'mean_word_length': 4.406779661016949, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '3601859', 'n_tokens_mistral': 724, 'n_tokens_neox': 689, 'n_words': 199}