<commit_before>import logging

from twisted.internet.threads import deferToThread

from zope.interface import implements

from lava_scheduler_app.models import Device
from lava_scheduler_daemon.jobsource import IJobSource


logger = logging.getLogger(__name__)


def defer_to_thread(func):
    def wrapper(*args, **kw):
        return deferToThread(func, *args, **kw)
    return wrapper


class DatabaseJobSource(object):

    implements(IJobSource)

    logger = logger.getChild('DirectoryJobSource')

    @defer_to_thread
    def getBoardList(self):
        return [d.hostname for d in Device.objects.all()]


    @defer_to_thread
    def getJobForBoard(self, board_name):
        pass

    @defer_to_thread
    def jobCompleted(self, board_name, log_stream):
        pass<commit_msg>(maybe) implement getJobForBoard<commit_after>import logging

from twisted.internet.threads import deferToThread

from zope.interface import implements

from lava_scheduler_app.models import Device, TestJob
from lava_scheduler_daemon.jobsource import IJobSource


logger = logging.getLogger(__name__)


def defer_to_thread(func):
    def wrapper(*args, **kw):
        return deferToThread(func, *args, **kw)
    return wrapper


class DatabaseJobSource(object):

    implements(IJobSource)

    logger = logger.getChild('DirectoryJobSource')

    @defer_to_thread
    def getBoardList(self):
        return [d.hostname for d in Device.objects.all()]

    @defer_to_thread
    def getJobForBoard(self, board_name):
        device = Device.objects.get(hostname=board_name)
        jobs_for_device = TestJob.objects(target=device)
        jobs_for_device.order_by('submit_time')
        jobs = jobs_for_device[:1]
        if jobs:
            return jobs[0]
        else:
            return None

    @defer_to_thread
    def jobCompleted(self, board_name, log_stream):
        pass
{'fraction_non_alphanumeric': 0.08096514745308311, 'fraction_numerical': 0.0010723860589812334, 'mean_word_length': 3.7240506329113923, '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': '6702295', 'n_tokens_mistral': 569, 'n_tokens_neox': 548, 'n_words': 127}