<commit_before>import logging
from collections import MutableMapping
from .resourcetype import ResourceType, ItemsResourceType
from .utils import millitime, urlpathjoin
from .jobq import JobQ


class Job(object):

    def __init__(self, client, key, auth=None, jobauth=None, metadata=None):
        self.key = urlpathjoin(key)
        assert len(self.key.split('/')) == 3, 'Jobkey must be projectid/spiderid/jobid: %s' % self.key
        self._jobauth = jobauth
        # It can't use self.jobauth because metadata is not ready yet
        self.auth = jobauth or auth
        self.metadata = JobMeta(client, self.key, self.auth, metadata=metadata)
        self.items = Items(client, self.key, self.auth)
        self.logs = Logs(client, self.key, self.auth)
        self.samples = Samples(client, self.key, self.auth)
        self.jobq = JobQ(client, self.key.split('/')[0], auth)

    def close_writers(self):
        wl = [self.items, self.logs, self.samples]
        # close all resources that use backwround writers
        for w in wl:
            w.close(block=False)
        # now wait for all writers to close together
        for w in wl:
            w.close(block=True)

    @property
    def jobauth(self):
        if self._jobauth is None:
            token = self.metadata.authtoken()
            self._jobauth = (self.key, token)
        return self._jobauth

    def _update_metadata(self, *args, **kwargs):
        kwargs.setdefault('updated_time', millitime())<commit_msg>no need to update updated_time anymore<commit_after>import logging
from collections import MutableMapping
from .resourcetype import ResourceType, ItemsResourceType
from .utils import millitime, urlpathjoin
from .jobq import JobQ


class Job(object):

    def __init__(self, client, key, auth=None, jobauth=None, metadata=None):
        self.key = urlpathjoin(key)
        assert len(self.key.split('/')) == 3, 'Jobkey must be projectid/spiderid/jobid: %s' % self.key
        self._jobauth = jobauth
        # It can't use self.jobauth because metadata is not ready yet
        self.auth = jobauth or auth
        self.metadata = JobMeta(client, self.key, self.auth, metadata=metadata)
        self.items = Items(client, self.key, self.auth)
        self.logs = Logs(client, self.key, self.auth)
        self.samples = Samples(client, self.key, self.auth)
        self.jobq = JobQ(client, self.key.split('/')[0], auth)

    def close_writers(self):
        wl = [self.items, self.logs, self.samples]
        # close all resources that use backwround writers
        for w in wl:
            w.close(block=False)
        # now wait for all writers to close together
        for w in wl:
            w.close(block=True)

    @property
    def jobauth(self):
        if self._jobauth is None:
            token = self.metadata.authtoken()
            self._jobauth = (self.key, token)
        return self._jobauth

    def _update_metadata(self, *args, **kwargs):
{'fraction_non_alphanumeric': 0.10515603799185888, 'fraction_numerical': 0.0013568521031207597, 'mean_word_length': 2.690863579474343, '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': '3779793', 'n_tokens_mistral': 898, 'n_tokens_neox': 871, 'n_words': 258}