# This file was auto-generated by Fern from our API Definition.

import datetime as dt
import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.unchecked_base_model import UncheckedBaseModel
from .lse_task_drafts_item import LseTaskDraftsItem
from .lse_task_predictions_item import LseTaskPredictionsItem


class LseTask(UncheckedBaseModel):
    """
    Data Manager Task Serializer with FSM state support.
    """

    agreement: typing.Optional[str] = None
    agreement_selected: typing.Optional[str] = None
    allow_skip: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether this task can be skipped. Set to False to make task unskippable.
    """

    annotation_time: typing.Optional[int] = pydantic.Field(default=None)
    """
    Calculate total annotation time for this task from MetricInTimeBucket records.
    Returns time in seconds.
    """

    annotations: typing.Optional[str] = None
    annotations_ids: typing.Optional[str] = None
    annotations_results: typing.Optional[str] = None
    annotators: typing.Optional[typing.List[int]] = pydantic.Field(default=None)
    """
    Annotators IDs who annotated this task
    """

    annotators_count: typing.Optional[int] = pydantic.Field(default=None)
    """
    The annotators_count is calculated as the number of users with annotations (can be repeated, so same as the number of annotations) + the number of assignees without annotations.
    """

    avg_lead_time: typing.Optional[float] = None
    cancelled_annotations: typing.Optional[int] = None
    comment_authors: typing.Optional[typing.List[typing.Dict[str, typing.Any]]] = None
    comment_authors_count: typing.Optional[int] = None
    comment_count: typing.Optional[int] = pydantic.Field(default=None)
    """
    Number of comments in the task including all annotations
    """

    comments: typing.Optional[str] = None
    completed_at: typing.Optional[dt.datetime] = None
    created_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    Time a task was created
    """

    data: typing.Any
    draft_exists: typing.Optional[bool] = None
    drafts: typing.Optional[typing.List[LseTaskDraftsItem]] = pydantic.Field(default=None)
    """
    Drafts for this task
    """

    file_upload: typing.Optional[str] = None
    ground_truth: typing.Optional[bool] = None
    id: typing.Optional[int] = None
    inner_id: typing.Optional[int] = None
    is_labeled: typing.Optional[bool] = pydantic.Field(default=None)
    """
    True if the number of annotations for this task is greater than or equal to the number of maximum_completions for the project
    """

    last_comment_updated_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    When the last comment was updated
    """

    meta: typing.Optional[typing.Any] = pydantic.Field(default=None)
    """
    Meta is user imported (uploaded) data and can be useful as input for an ML Backend for embeddings, advanced vectors, and other info. It is passed to ML during training/predicting steps.
    """

    overlap: typing.Optional[int] = pydantic.Field(default=None)
    """
    Number of distinct annotators that processed the current task
    """

    precomputed_agreement: typing.Optional[float] = pydantic.Field(default=None)
    """
    Average agreement score for the task
    """

    predictions: typing.Optional[typing.List[LseTaskPredictionsItem]] = pydantic.Field(default=None)
    """
    Predictions for this task
    """

    predictions_model_versions: typing.Optional[str] = None
    predictions_results: typing.Optional[str] = None
    predictions_score: typing.Optional[float] = None
    project: typing.Optional[int] = pydantic.Field(default=None)
    """
    Project ID for this task
    """

    review_time: typing.Optional[int] = pydantic.Field(default=None)
    """
    Calculate total review time for this task from MetricInTimeBucket records.
    Returns time in seconds.
    """

    reviewed: typing.Optional[bool] = None
    reviewers: typing.Optional[typing.List[typing.Dict[str, typing.Any]]] = None
    reviewers_count: typing.Optional[int] = None
    reviews_accepted: typing.Optional[int] = None
    reviews_rejected: typing.Optional[int] = None
    state: typing.Optional[str] = None
    storage_filename: typing.Optional[str] = None
    total_annotations: typing.Optional[int] = None
    total_predictions: typing.Optional[int] = None
    unresolved_comment_count: typing.Optional[int] = pydantic.Field(default=None)
    """
    Number of unresolved comments in the task including all annotations
    """

    updated_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    Last time a task was updated
    """

    updated_by: typing.Optional[typing.List[typing.Dict[str, typing.Any]]] = pydantic.Field(default=None)
    """
    User IDs who updated this task
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
