<commit_before>import argparse
import sys
import time


def _get_argparser():
    parser = argparse.ArgumentParser()
    # add common argparser arguments here
    return parser


def run():
    sys.path.insert(0, '')
    parser = _get_argparser()
    parser.description = 'Run a tasa worker.'
    parser.add_argument('worker',
                        type=lambda w: w.partition(':')[::2],
                        help='Worker module. In the form: '
                        '"path.to.my.module:MyWorkerClass". Relative to '
                        'the current directory.')
    args = parser.parse_args()

    worker_module = __import__(args.worker[0])
    try:
        WorkerClass = getattr(worker_module, args.worker[1] or 'Worker')
    except AttributeError:
        raise Exception('Worker not found')
    worker = WorkerClass()

    try:
        for job in worker():
            if job:
                print "Doing job:", job
            # FIXME: do something better here
            time.sleep(.1)
    except KeyboardInterrupt:
        sys.exit()


def log():
    parser = _get_argparser()
    parser.description = 'Follow logs from a running tasa system.'
    args = parser.parse_args()


if __name__=='__main__':
    # deal with being run directly rather than as an installed script
    cmd = 'undefined' if len(sys.argv) < 2 else sys.argv.pop(1)
    if cmd == 'run':
        run()
    elif cmd == 'log':
        log()<commit_msg>Fix import bug. Add version arg to cli.<commit_after>import argparse
import sys
import time

import tasa

def _get_argparser():
    parser = argparse.ArgumentParser()
    parser.add_argument('-v', '--version', action='version',
                        version='Tasa %s on Python %s' % (tasa.__version__, sys.version)
                        )
    # add common argparser arguments here
    return parser


def run():
    sys.path.insert(0, '')
    parser = _get_argparser()
    parser.description = 'Run a tasa worker.'
    parser.add_argument('worker',
                        type=lambda w: w.partition(':')[::2],
                        help='Worker module. In the form: '
                        '"path.to.my.module:MyWorkerClass". Relative to '
                        'the current directory.')
    args = parser.parse_args()

    worker_class_name = args.worker[1] or 'Worker'
    worker_module = __import__(args.worker[0], globals(), locals(),
                               [worker_class_name])
    try:
        WorkerClass = getattr(worker_module, worker_class_name)
    except AttributeError:
        raise Exception('Worker not found')
    worker = WorkerClass()
    print 'Running worker: %s:%s' % (args.worker[0],
                                     worker.__class__.__name__)
    try:
        for job in worker():
            if job:
                print "Doing job:", job
            # FIXME: do something better here
            time.sleep(.1)
    except KeyboardInterrupt:
        print 'Exiting worker.'
        sys.exit()


def log():
    parser = _get_argparser()
    parser.description = 'Follow logs from a running tasa system.'
    args = parser.parse_args()


if __name__=='__main__':
    # deal with being run directly rather than as an installed script
    cmd = 'undefined' if len(sys.argv) < 2 else sys.argv.pop(1)
    if cmd == 'run':
        run()
    elif cmd == 'log':
        log()
{'fraction_non_alphanumeric': 0.11124366239188786, 'fraction_numerical': 0.0044736057262153295, 'mean_word_length': 2.05742935278031, 'pattern_counts': {'":': 0, '<': 5, '<?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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2425239', 'n_tokens_mistral': 957, 'n_tokens_neox': 925, 'n_words': 276}