<commit_before>#!/usr/bin/env python
# <NAME> <<EMAIL>>
from alphatwirl.progressbar import ProgressReport, BProgressMonitor
from alphatwirl.progressbar import ProgressBar
from alphatwirl.progressbar import ProgressPrint
from alphatwirl.concurrently import CommunicationChannel
import sys
import time, random
import uuid

##__________________________________________________________________||
class Task(object):
    def __init__(self, name):
        self.name = name
    def __call__(self, progressReporter = None):
        n = random.randint(5, 1000000)
        taskid = uuid.uuid4()
        time.sleep(random.randint(0, 3))
        for i in xrange(n):
            time.sleep(0.0001)
            report = ProgressReport(name = self.name, done = i + 1, total = n, taskid = taskid)
            progressReporter.report(report)
        return None

##__________________________________________________________________||
progressBar = ProgressBar() if sys.stdout.isatty() else ProgressPrint()

##__________________________________________________________________||
progressMonitor = BProgressMonitor(presentation = progressBar)
channel = CommunicationChannel(nprocesses = 10, progressMonitor = progressMonitor)
progressMonitor.begin()
channel.begin()
channel.put(Task("loop"))
channel.put(Task("another loop"))
channel.put(Task("more loop"))
channel.put(Task("loop loop loop"))
channel.put(Task("l"))
channel.put(Task("loop6"))
channel.put(Task("loop7"))
channel.put(Task("loop8"))
channel.put(Task("loop6"))
channel.receive()
channel.end()
progressMonitor.end()

##__________________________________________________________________||<commit_msg>update tests/misc/progressbar.py<commit_after>#!/usr/bin/env python
# <NAME> <<EMAIL>>
from alphatwirl.progressbar import ProgressReport, BProgressMonitor
from alphatwirl.progressbar import ProgressBar
from alphatwirl.progressbar import ProgressPrint
from alphatwirl.concurrently import CommunicationChannel, MultiprocessingDropbox
import sys
import time, random
import uuid

##__________________________________________________________________||
class Task(object):
    def __init__(self, name):
        self.name = name
    def __call__(self, progressReporter = None):
        n = random.randint(5, 1000000)
        taskid = uuid.uuid4()
        time.sleep(random.randint(0, 3))
        for i in range(n):
            time.sleep(0.0001)
            report = ProgressReport(name = self.name, done = i + 1, total = n, taskid = taskid)
            progressReporter.report(report)
        return None

##__________________________________________________________________||
progressBar = ProgressBar() if sys.stdout.isatty() else ProgressPrint()

##__________________________________________________________________||
progressMonitor = BProgressMonitor(presentation = progressBar)
dropbox = MultiprocessingDropbox(nprocesses = 10, progressMonitor = progressMonitor)
channel = CommunicationChannel(dropbox)
progressMonitor.begin()
channel.begin()
channel.put(Task("loop"))
channel.put(Task("another loop"))
channel.put(Task("more loop"))
channel.put(Task("loop loop loop"))
channel.put(Task("l"))
channel.put(Task("loop6"))
channel.put(Task("loop7"))
channel.put(Task("loop8"))
channel.put(Task("loop6"))
channel.receive()
channel.end()
progressMonitor.end()

##__________________________________________________________________||
{'fraction_non_alphanumeric': 0.11252969121140143, 'fraction_numerical': 0.013657957244655582, 'mean_word_length': 5.778672032193159, '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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '209068', 'n_tokens_mistral': 906, 'n_tokens_neox': 866, 'n_words': 196}