<commit_before>
import sys

import skytools

from cc import json
from cc.job import CCJob
from cc.reqs import TaskReplyMessage

#
# Base class for tasks
#

class CCTask(CCJob):
    """Task base class.

    - loads config & task from stdin as single json blob
    - does not loop by default
    - log is sent into CC
    """
    looping = 0
    task_uid = None
    task_finished = False

    def __init__(self, service_name, args):
        info = sys.stdin.read()
        self.task_info = json.Struct.from_json(info)<commit_msg>cc.task.get_task_handlers: collect list of handler modules<commit_after>
import sys, os, os.path

import skytools

from cc import json
from cc.job import CCJob
from cc.reqs import TaskReplyMessage

def get_task_handlers():
    """Returns list of handler modules.
    
    Returns dict: (module_name -> docstr)
    """

    d = os.path.dirname(__file__)
    res = {}
    for fn in os.listdir(d):
        if fn[0] in ('.', '_'):
            continue
        name, ext = os.path.splitext(fn)
        if ext == '.py':
            mod = 'cc.task.' + name
            try:
                __import__(mod, level=0)
                m = sys.modules[mod]
                desc = m.__doc__
            except:
                desc = '<broken>'
            res[mod] = desc
    return res

#
# Base class for tasks
#

class CCTask(CCJob):
    """Task base class.

    - loads config & task from stdin as single json blob
    - does not loop by default
    - log is sent into CC
    """
    looping = 0
    task_uid = None
    task_finished = False

    def __init__(self, service_name, args):
        info = sys.stdin.read()
        self.task_info = json.Struct.from_json(info)
{'fraction_non_alphanumeric': 0.0970414201183432, 'fraction_numerical': 0.002366863905325444, 'mean_word_length': 2.0914076782449724, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, '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': '2837948', 'n_tokens_mistral': 535, 'n_tokens_neox': 519, 'n_words': 169}