<commit_before>import time
from multiprocessing import Process
from uuid import uuid4

from cbagent.collectors import NSServer
from logger import logger

from perfrunner.settings import CbAgentSettings


class CbAgent(object):

    def __init__(self, cluster_spec, target_iterator):
        settings = CbAgentSettings()
        settings.cluster = '{0}_{1}'.format(cluster_spec.name, uuid4().hex[:6])
        settings.ssh_username, settings.ssh_password = \
            cluster_spec.get_ssh_credentials()
        settings.rest_username, settings.rest_password = \
            cluster_spec.get_rest_credentials()

        self.collectors = []
        for target in target_iterator:
            settings.master_node = target.node.split(':')[0]
            for collector in (NSServer, ):
                self.collectors.append(collector(settings))

    def update_metadata(self):
        for collector in self.collectors:
            collector.update_metadata()

    def start(self):
        self.processes = [Process(target=c.collect) for c in self.collectors]
        map(lambda p: p.start(), self.processes)

    def stop(self):
        map(lambda p: p.terminate(), self.processes)
<commit_msg>remove unused imports<commit_after>from multiprocessing import Process
from uuid import uuid4

from cbagent.collectors import NSServer

from perfrunner.settings import CbAgentSettings


class CbAgent(object):

    def __init__(self, cluster_spec, target_iterator):
        settings = CbAgentSettings()
        settings.cluster = '{0}_{1}'.format(cluster_spec.name, uuid4().hex[:6])
        settings.ssh_username, settings.ssh_password = \
            cluster_spec.get_ssh_credentials()
        settings.rest_username, settings.rest_password = \
            cluster_spec.get_rest_credentials()

        self.collectors = []
        for target in target_iterator:
            settings.master_node = target.node.split(':')[0]
            for collector in (NSServer, ):
                self.collectors.append(collector(settings))

    def update_metadata(self):
        for collector in self.collectors:
            collector.update_metadata()

    def start(self):
        self.processes = [Process(target=c.collect) for c in self.collectors]
        map(lambda p: p.start(), self.processes)

    def stop(self):
        map(lambda p: p.terminate(), self.processes)

{'fraction_non_alphanumeric': 0.09847198641765705, 'fraction_numerical': 0.0050933786078098476, 'mean_word_length': 2.988155668358714, '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': '6251619', 'n_tokens_mistral': 689, 'n_tokens_neox': 666, 'n_words': 148}