<commit_before>#!/usr/bin/env python
'''
@author <NAME> <<EMAIL>>
@file ion/processes/bootstrap/plugins/bootstrap_qc_post_processor.py
@description Bootstraps the QC Post Processor
'''

from interface.services.cei.ischeduler_service import SchedulerServiceProcessClient
from interface.services.cei.iprocess_dispatcher_service import ProcessDispatcherServiceProcessClient

from ion.core.bootstrap_process import BootstrapPlugin
from pyon.util.containers import DotDict
from interface.objects import ProcessDefinition
from uuid import uuid4
import time

class BootstrapQCPostProcessor(BootstrapPlugin):
    '''
    Sets up one QC Post Processing worker and initiates
    the Scheduler Service's interval every 24 hours.
    '''

    def on_initial_bootstrap(self, process, config, **kwargs):
        self.scheduler_service = SchedulerServiceProcessClient(process=process)
        self.process_dispatcher = ProcessDispatcherServiceProcessClient(process=process)

        interval_key = uuid4().hex # Unique identifier for this process

        config = DotDict()
        config.process.interval_key = interval_key

        process_definition = ProcessDefinition(name='qc_post_processor',
            executable={'module':'ion.processes.data.transforms.qc_post_processing', 'class':'QCPostProcessing'})
        process_definition_id = self.process_dispatcher.create_process_definition(process_definition)


        process_id = self.process_dispatcher.create_process(process_definition_id)
        self.process_dispatcher.schedule_process(process_definition_id, process_id=process_id, configuration=config)


        timer_id = self.scheduler_service.create_interval_timer(start_time=time.time(),
                end_time=-1, #Run FOREVER
                interval=3600*24,
                event_origin=interval_key)<commit_msg>Adds singleton longic to qpp bootstrap<commit_after>#!/usr/bin/env python
'''
@author <NAME> <<EMAIL>>
@file ion/processes/bootstrap/plugins/bootstrap_qc_post_processor.py
@description Bootstraps the QC Post Processor
'''

from interface.services.cei.ischeduler_service import SchedulerServiceProcessClient
from interface.services.cei.iprocess_dispatcher_service import ProcessDispatcherServiceProcessClient
from pyon.public import RT
from ion.core.bootstrap_process import BootstrapPlugin
from pyon.util.containers import DotDict
from interface.objects import ProcessDefinition
from uuid import uuid4
import time

class BootstrapQCPostProcessor(BootstrapPlugin):
    '''
    Sets up one QC Post Processing worker and initiates
    the Scheduler Service's interval every 24 hours.
    '''

    def on_initial_bootstrap(self, process, config, **kwargs):
        if self.process_exists(process, 'qc_post_processor'):
            # Short circuit the bootstrap to make sure not more than one is ever started
            return

        self.scheduler_service = SchedulerServiceProcessClient(process=process)
        self.process_dispatcher = ProcessDispatcherServiceProcessClient(process=process)

        interval_key = uuid4().hex # Unique identifier for this process

        config = DotDict()
        config.process.interval_key = interval_key

        process_definition = ProcessDefinition(name='qc_post_processor',
            executable={'module':'ion.processes.data.transforms.qc_post_processing', 'class':'QCPostProcessing'})
        process_definition_id = self.process_dispatcher.create_process_definition(process_definition)

        process_id = self.process_dispatcher.create_process(process_definition_id)
        self.process_dispatcher.schedule_process(process_definition_id, process_id=process_id, configuration=config)


        timer_id = self.scheduler_service.create_interval_timer(start_time=time.time(),
                end_time=-1, #Run FOREVER
                interval=3600*24,
                event_origin=interval_key)

    def process_exists(self, process, name):
        proc_ids, meta = process.container.resource_registry.find_resources(restype=RT.Process, id_only=True)
        return any([name in p['name'] for p in meta])

{'fraction_non_alphanumeric': 0.0767533104462972, 'fraction_numerical': 0.005394801373222168, 'mean_word_length': 4.50472334682861, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1086817', 'n_tokens_mistral': 1126, 'n_tokens_neox': 1059, 'n_words': 232}