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

import datetime as dt
import typing

from ..core.datetime_utils import serialize_datetime
from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
from .project_sampling import ProjectSampling
from .project_skip_queue import ProjectSkipQueue
from .user_simple import UserSimple


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

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

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

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

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

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

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

    show_annotation_history: typing.Optional[bool] = pydantic_v1.Field(default=None)
    """
    Show annotation history to annotator
    """

    organization: typing.Optional[int] = None
    color: typing.Optional[str] = None
    maximum_annotations: typing.Optional[int] = pydantic_v1.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)
    """

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

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

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

    created_by: typing.Optional[UserSimple] = None
    created_at: typing.Optional[dt.datetime] = None
    min_annotations_to_start_training: typing.Optional[int] = pydantic_v1.Field(default=None)
    """
    Minimum number of completed tasks after which model training is started
    """

    start_training_on_annotation_update: typing.Optional[str] = pydantic_v1.Field(default=None)
    """
    Start model training after any annotations are submitted or updated
    """

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

    num_tasks_with_annotations: typing.Optional[int] = pydantic_v1.Field(default=None)
    """
    Tasks with annotations count
    """

    task_number: typing.Optional[int] = pydantic_v1.Field(default=None)
    """
    Total task number in project
    """

    useful_annotation_number: typing.Optional[int] = pydantic_v1.Field(default=None)
    """
    Useful annotation number in project not including skipped_annotations_number and ground_truth_number. Total annotations = annotation_number + skipped_annotations_number + ground_truth_number
    """

    ground_truth_number: typing.Optional[int] = pydantic_v1.Field(default=None)
    """
    Honeypot annotation number in project
    """

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

    total_annotations_number: typing.Optional[int] = pydantic_v1.Field(default=None)
    """
    Total annotations number in project including skipped_annotations_number and ground_truth_number.
    """

    total_predictions_number: typing.Optional[int] = pydantic_v1.Field(default=None)
    """
    Total predictions number in project including skipped_annotations_number, ground_truth_number, and useful_annotation_number.
    """

    sampling: typing.Optional[ProjectSampling] = None
    show_ground_truth_first: typing.Optional[bool] = None
    show_overlap_first: typing.Optional[bool] = None
    overlap_cohort_percentage: typing.Optional[int] = None
    task_data_login: typing.Optional[str] = pydantic_v1.Field(default=None)
    """
    Task data credentials: login
    """

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

    control_weights: typing.Optional[typing.Dict[str, typing.Any]] = pydantic_v1.Field(default=None)
    """
    Dict of weights for each control tag in metric calculation. Each control tag (e.g. label or choice) will have it's own key in control weight dict with weight for each label and overall weight.For example, if bounding box annotation with control tag named my_bbox should be included with 0.33 weight in agreement calculation, and the first label Car should be twice more important than Airplaine, then you have to need the specify: {'my_bbox': {'type': 'RectangleLabels', 'labels': {'Car': 1.0, 'Airplaine': 0.5}, 'overall': 0.33}
    """

    parsed_label_config: typing.Optional[typing.Dict[str, typing.Any]] = pydantic_v1.Field(default=None)
    """
    JSON-formatted labeling configuration
    """

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

    config_has_control_tags: typing.Optional[str] = pydantic_v1.Field(default=None)
    """
    Flag to detect is project ready for labeling
    """

    skip_queue: typing.Optional[ProjectSkipQueue] = None
    reveal_preannotations_interactively: typing.Optional[bool] = pydantic_v1.Field(default=None)
    """
    Reveal pre-annotations interactively
    """

    pinned_at: typing.Optional[dt.datetime] = pydantic_v1.Field(default=None)
    """
    Pinned date and time
    """

    finished_task_number: typing.Optional[int] = pydantic_v1.Field(default=None)
    """
    Finished tasks
    """

    queue_total: typing.Optional[str] = None
    queue_done: typing.Optional[str] = None

    def json(self, **kwargs: typing.Any) -> str:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().json(**kwargs_with_defaults)

    def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
        kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}

        return deep_union_pydantic_dicts(
            super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
        )

    class Config:
        frozen = True
        smart_union = True
        extra = pydantic_v1.Extra.allow
        json_encoders = {dt.datetime: serialize_datetime}
