<commit_before>from django.db import models
from picklefield import fields
from django.contrib.auth.models import User


class OcrBatch(models.Model):
    """
    OCR Batch object.
    """
    TYPE_CHOICES = (
        ("ONESHOT", "One-Shot"),
        ("BATCH", "Batch"),
        ("TEST", "Test"),
    )

    user = models.ForeignKey(User)
    type = models.CharField(max_length=20, choices=TYPE_CHOICES)
    created_on = models.DateTimeField(auto_now_add=True, editable=False)


class OcrTask(models.Model):
    """
    OCR Task object.
    """
    STATUS_CHOICES = (
        ("INIT", "Initialising"),
        ("PENDING", "Pending"),
        ("RUNNING", "Running"),
        ("RETRY", "Retry"),
        ("SUCCESS", "Success"),
        ("ERROR", "Error"),
        ("DONE", "Done"),
    )

    batch = models.ForeignKey(OcrBatch)
    task_id = models.CharField(max_length=100)
    page = models.CharField(max_length=255)
    status = models.CharField(max_length=20, choices=STATUS_CHOICES)
    args = fields.PickledObjectField(blank=True, null=True)
    kwargs = fields.PickledObjectField(blank=True, null=True)
    created_on = models.DateTimeField(auto_now_add=True, editable=False)
    updated_on = models.DateTimeField(auto_now_add=True, auto_now=True, editable=False)

<commit_msg>Added a proxy function for getting the batch user<commit_after>from django.db import models
from picklefield import fields
from django.contrib.auth.models import User


class OcrBatch(models.Model):
    """
    OCR Batch object.
    """
    TYPE_CHOICES = (
        ("ONESHOT", "One-Shot"),
        ("BATCH", "Batch"),
        ("TEST", "Test"),
    )

    user = models.ForeignKey(User)
    type = models.CharField(max_length=20, choices=TYPE_CHOICES)
    created_on = models.DateTimeField(auto_now_add=True, editable=False)


class OcrTask(models.Model):
    """
    OCR Task object.
    """
    STATUS_CHOICES = (
        ("INIT", "Initialising"),
        ("PENDING", "Pending"),
        ("RUNNING", "Running"),
        ("RETRY", "Retry"),
        ("SUCCESS", "Success"),
        ("ERROR", "Error"),
        ("DONE", "Done"),
    )

    batch = models.ForeignKey(OcrBatch)
    task_id = models.CharField(max_length=100)
    page = models.CharField(max_length=255)
    status = models.CharField(max_length=20, choices=STATUS_CHOICES)
    args = fields.PickledObjectField(blank=True, null=True)
    kwargs = fields.PickledObjectField(blank=True, null=True)
    created_on = models.DateTimeField(auto_now_add=True, editable=False)
    updated_on = models.DateTimeField(auto_now_add=True, auto_now=True, editable=False)

    @property
    def user(self):
        return self.batch.user
{'fraction_non_alphanumeric': 0.14103525881470366, 'fraction_numerical': 0.007501875468867217, 'mean_word_length': 3.4228855721393034, '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': '3555231', 'n_tokens_mistral': 887, 'n_tokens_neox': 857, 'n_words': 161}