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

from ..core.unchecked_base_model import UncheckedBaseModel
import typing
from .assignment_settings import AssignmentSettings
import pydantic
import datetime as dt
from .user_simple import UserSimple
from .review_settings import ReviewSettings
from .lse_project_update_sampling import LseProjectUpdateSampling
from .lse_project_update_skip_queue import LseProjectUpdateSkipQueue
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class LseProjectUpdate(UncheckedBaseModel):
    """
    Serializer get numbers from project queryset annotation,
    make sure, that you use correct one(Project.objects.with_counts())
    """

    annotation_limit_count: typing.Optional[int] = None
    annotation_limit_percent: typing.Optional[str] = None
    annotator_evaluation_minimum_score: typing.Optional[str] = None
    annotator_evaluation_minimum_tasks: typing.Optional[int] = None
    assignment_settings: AssignmentSettings
    color: typing.Optional[str] = None
    comment_classification_config: typing.Optional[str] = None
    config_has_control_tags: bool = pydantic.Field()
    """
    Flag to detect is project ready for labeling
    """

    config_suitable_for_bulk_annotation: bool = pydantic.Field()
    """
    Flag to detect is project ready for bulk annotation
    """

    control_weights: typing.Optional[typing.Optional[typing.Any]] = None
    created_at: dt.datetime
    created_by: typing.Optional[UserSimple] = pydantic.Field(default=None)
    """
    Project owner
    """

    custom_script: typing.Optional[str] = None
    custom_task_lock_ttl: typing.Optional[int] = pydantic.Field(default=None)
    """
    TTL in seconds for task reservations, on new and existing tasks
    """

    description: typing.Optional[str] = pydantic.Field(default=None)
    """
    Project description
    """

    enable_empty_annotation: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Allow annotators to submit empty annotations
    """

    evaluate_predictions_automatically: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Retrieve and display predictions when loading a task
    """

    expert_instruction: typing.Optional[str] = pydantic.Field(default=None)
    """
    Labeling instructions in HTML format
    """

    finished_task_number: int = pydantic.Field()
    """
    Finished tasks
    """

    ground_truth_number: int = pydantic.Field()
    """
    Honeypot annotation number in project
    """

    id: int
    is_draft: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether or not the project is in the middle of being created
    """

    is_published: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether or not the project is published to annotators
    """

    label_config: typing.Optional[str] = pydantic.Field(default=None)
    """
    Label config in XML format. See more about it in documentation
    """

    maximum_annotations: typing.Optional[int] = pydantic.Field(default=None)
    """
    Maximum number of annotations for one task. If the number of annotations per task is equal or greater to this value, the task is completed (is_labeled=True)
    """

    min_annotations_to_start_training: typing.Optional[int] = pydantic.Field(default=None)
    """
    Minimum number of completed tasks after which model training is started
    """

    model_version: typing.Optional[str] = pydantic.Field(default=None)
    """
    Machine learning model version
    """

    num_tasks_with_annotations: int = pydantic.Field()
    """
    Tasks with annotations count
    """

    organization: typing.Optional[int] = None
    overlap_cohort_percentage: typing.Optional[int] = None
    parsed_label_config: typing.Optional[typing.Any] = None
    pause_on_failed_annotator_evaluation: typing.Optional[bool] = None
    pinned_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    Pinned date and time
    """

    prompts: str
    queue_done: int
    queue_total: int
    require_comment_on_skip: typing.Optional[bool] = None
    reveal_preannotations_interactively: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Reveal pre-annotations interactively
    """

    review_settings: ReviewSettings
    sampling: typing.Optional[LseProjectUpdateSampling] = None
    show_annotation_history: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Show annotation history to annotator
    """

    show_collab_predictions: typing.Optional[bool] = pydantic.Field(default=None)
    """
    If set, the annotator can view model predictions
    """

    show_ground_truth_first: typing.Optional[bool] = None
    show_instruction: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Show instructions to the annotator before they start
    """

    show_overlap_first: typing.Optional[bool] = None
    show_skip_button: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Show a skip button in interface and allow annotators to skip the task
    """

    skip_queue: typing.Optional[LseProjectUpdateSkipQueue] = None
    skipped_annotations_number: int = pydantic.Field()
    """
    Skipped by collaborators annotation number in project
    """

    start_training_on_annotation_update: bool = pydantic.Field()
    """
    Start model training after any annotations are submitted or updated
    """

    task_data_login: typing.Optional[str] = pydantic.Field(default=None)
    """
    Task data credentials: login
    """

    task_data_password: typing.Optional[str] = pydantic.Field(default=None)
    """
    Task data credentials: password
    """

    task_number: int = pydantic.Field()
    """
    Total task number in project
    """

    title: typing.Optional[str] = pydantic.Field(default=None)
    """
    Project name. Must be between 3 and 50 characters long.
    """

    total_annotations_number: int = pydantic.Field()
    """
    Total annotations number in project including skipped_annotations_number and ground_truth_number.
    """

    total_predictions_number: int = pydantic.Field()
    """
    Total predictions number in project including skipped_annotations_number, ground_truth_number, and useful_annotation_number.
    """

    useful_annotation_number: int = pydantic.Field()
    """
    Useful annotation number in project not including skipped_annotations_number and ground_truth_number. Total annotations = annotation_number + skipped_annotations_number + ground_truth_number
    """

    workspace: int
    workspace_title: str

    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
