
    ]jm                       d Z ddlZddlZddlZddlZddlZddlmZmZ ddlm	Z	 ddl
mZmZ ddlmZmZmZmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZmZmZ ddlmZ ddlmZm Z   ejB                  e"      Z# G d de$      Z% G d de%      Z& G d de      Z' G d de      Z( G d de      Z) G d d      Z* G d de      Z+y)z  .. include::../docs/project.md
    N)Enumauto)Path)sampleshuffle)OptionalUnionListDictCallable)parse_config)get_local_path)Response)	HTTPErrorInvalidSchemaMissingSchema   )Client)r   chunkc                       e Zd Zy)LabelStudioExceptionN__name__
__module____qualname__     J/root/env/lib/python3.12/site-packages/label_studio_sdk/_legacy/project.pyr   r          r   r   c                       e Zd Zy)LabelStudioAttributeErrorNr   r   r   r   r!   r!      r   r   r!   c                        e Zd ZdZdZ	 dZ	 dZy)ProjectSamplingz9Enumerate the available task sampling modes for labeling.zUniform samplingzSequential samplingzUncertainty samplingN)r   r   r   __doc__RANDOMSEQUENCEUNCERTAINTYr   r   r   r#   r#   !   s    CF,$H7(Kar   r#   c                   2    e Zd ZdZdZ	 dZ	 dZ	 dZ	 dZ	 dZ	y)	ProjectStoragezZEnumerate the available types of external source and target storage for labeling projects.gcss3
azure_blob
localfilesrediss3sN)
r   r   r   r$   GOOGLES3AZURELOCALREDIS
S3_SECUREDr   r   r   r)   r)   ,   s5    dF 	BE(E+EJDr   r)   c                       e Zd Z e       Zy)AssignmentSamplingMethodN)r   r   r   r   r%   r   r   r   r7   r7   =   s	    VFr   r7   c                   B    e Zd ZdZ	 dZ	 dZ	 dZ	 d Zd Zd Z	d Z
d	 Zy
)ExportSnapshotStatuscreatedin_progressfailed	completedc                     || _         y N)responseselfr@   s     r   __init__zExportSnapshotStatus.__init__K   s	     r   c                 d    d| j                   v sJ d       | j                   d   | j                  k(  S )zExport snapshot is createdstatusz;"status" field not found in export snapshot status response)r@   CREATEDrB   s    r   
is_createdzExportSnapshotStatus.is_createdN   s:     %	IH	I%}}X&$,,66r   c                 d    d| j                   v sJ d       | j                   d   | j                  k(  S )zExport snapshot is in progressrE   ;"status" field not found in export_snapshot_status response)r@   IN_PROGRESSrG   s    r   is_in_progressz#ExportSnapshotStatus.is_in_progressU   s<     %	IH	I%}}X&$*:*:::r   c                 d    d| j                   v sJ d       | j                   d   | j                  k(  S )z"Export snapshot failed with errorsrE   rJ   )r@   FAILEDrG   s    r   	is_failedzExportSnapshotStatus.is_failed\   s:     %	IH	I%}}X&$++55r   c                 d    d| j                   v sJ d       | j                   d   | j                  k(  S )z1Export snapshot was created and can be downloadedrE   rJ   )r@   	COMPLETEDrG   s    r   is_completedz!ExportSnapshotStatus.is_completedc   s:     %	IH	I%}}X&$..88r   N)r   r   r   rF   rK   rN   rQ   rC   rH   rL   rO   rR   r   r   r   r9   r9   A   s;    G&K+F.I=!7;69r   r9   c                       e Zd Z fdZd Zed        Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd Zedd       Zedd       ZddefdZ	 	 	 	 	 ddedededeee      dee   deeej<                  f   fdZd Z de!fdZ"defdZ#d efd!Z$	 	 	 	 	 dd"efd#Z%	 	 	 	 	 	 	 	 dd%ed&ed"ed'efd(Z&d) Z'd* Z(d+ Z)dd,Z*d- Z+ed.        Z,ed/        Z-dd0Z.d1 Z/dd2Z0d3 Z1d4 Z2d5 Z3	 	 	 dd6ed7eeee4   e4ef      d8ee5   d ee   fd9Z6d: Z7dd;Z8d6edefd<Z9d6ede4fd=Z:d>ede;fd?Z<d@ Z=d>edefdAZ>dB Z?dC Z@dD ZA	 	 	 	 	 	 	 	 ddEedFee   dGee   dHee   dIee   dJee   dKee   dLee   dMee   fdNZB	 	 	 	 	 ddEedFee   dIee   dLee   dMee   dOefdPZC	 	 	 	 	 	 	 	 	 	 	 	 	 ddEedFee   dGee   dHee   dJee   dKee   dLee   dMee   dQee   dRee   dSee   dTee   dUee   dVee   fdWZD	 	 	 	 	 	 	 	 	 	 	 	 	 ddXedYee   dEee   dFee   dGee   dHee   dJee   dKee   dLee   dMee   dTee   dUee   dVee   dZee   fd[ZE	 	 	 	 	 	 	 	 	 ddEedFee   dLee   dMee   dQee   dRee   dSee   dTee   dUee   dOefd\ZF	 	 	 	 	 	 	 	 	 dd]edFee   dGee   dHee   dJee   dKee   dLee   dMee   d^ee   d_ee   fd`ZG	 	 	 	 	 	 dd]edFee   dLee   dMee   d^ee   d_ee   dOefdaZH	 	 	 	 ddbegdGee   dHee   dLee   dMee   f
dcZIdd ZJde ZKdf ZLdg ZMdeNj                  dhd$fdiee   djePdkedleNdme5dnefdoZQdeNj                  dhd$fdiee   dkedleNdme5dnef
dpZRdeNj                  dhd$fdiee   dkedleNdme5dnef
dqZSdefdrZT	 	 	 	 	 	 	 	 ddLedse;dteduedvedwedxedyedzede;fd{ZU	 	 	 	 dd|ZVd}edeWfd~ZX	 dd}edededeeffdZYd}edefdZZdde4defdZ[d6ede\fdZ]dede\fdZ^ddede\fdZ_ xZ`S )Projectc                 :    t        t        | 
  |i | i | _        y)zJInitialize project class.

        Parameters
        ----------

        N)superrT   rC   params)rB   argskwargs	__class__s      r   rC   zProject.__init__l   s      	gt%t6v6r   c                 $    | j                  |      S r?   )
_get_param)rB   items     r   __getattr__zProject.__getattr__v   s    t$$r   c                 ,    t        | j                        S )ay  Get the parsed labeling configuration for the project. You can use this to more easily construct
        annotation or prediction results based on your labeling configuration.

        Returns
        -------
        dict
            Object and control tags from the project labeling configuration.
            Example with structured configuration of the form:
        ```
        {
            "<ControlTag>.name": {
                "type": "ControlTag",
                "to_name": ["<ObjectTag1>.name", "<ObjectTag2>.name"],
                "inputs: [
                    {"type": "ObjectTag1", "value": "<ObjectTag1>.value"},
                    {"type": "ObjectTag2", "value": "<ObjectTag2>.value"}
                ],
                "labels": ["Label1", "Label2", "Label3"]
        }
        ```
        `"labels"` are taken from "alias" attribute if it exists, else "value"
        )r   label_configrG   s    r   parsed_label_configzProject.parsed_label_configy   s    0 D--..r   c                     ddl m} | j                  sJ d       | j                  dd| j                   d      }g }|j                         D ]  }| |d<   |j                   |di |         |S )	zGet members from this project.

        Parameters
        ----------

        Returns
        -------
        list of `label_studio_sdk.users.User`

        r   )UserzfProject members are available in the Enterprise edition of Label Studio only. Use get_users() instead.GET/api/projects//membersclientr   )usersrc   is_enterprisemake_requestidjsonappend)rB   rc   r@   rh   	user_datas        r   get_memberszProject.get_members   s     	 !! 	
'	
!
 $$UnTWWIX,NO! 	,I"&IhLL*	*+	, r   c                     d|j                   i}| j                  dd| j                    d|      }|j                         S )zAdd a user to a project.

        Parameters
        ----------
        user: User

        Returns
        -------
        dict
            Dict with created member

        userPOSTre   rf   rl   rk   rj   rl   )rB   rq   payloadr@   s       r   
add_memberzProject.add_member   sI     477#$$nTWWIX6W % 
 }}r   c                 .   ddi}|D cg c]  }|j                    }}t        |d      D ]c  }t        j                  d|        |d|ddd}| j	                  d	d
| j                    d|      }|dxx   |j                         d   z  cc<   e |S c c}w )a  Assign annotators to tasks

        Parameters
        ----------
        users: list of user's objects
        tasks_ids: list of integer task IDs to assign users to

        Returns
        -------
        dict
            Dict with counter of created assignments

        assignmentsr   i  zStarting assignment for: FallincludedANrh   selectedItemstyperr   re   /tasks/assigneesrs   )rk   r   loggerdebugrj   rl   )	rB   rh   	tasks_idsfinal_responserq   	users_idscru   r@   s	            r   assign_annotatorszProject.assign_annotators   s     (+)./TWW/	/y$' 
	LALL4YK@A").A!>G
 ((.	1AB ) H =)X]]_]-KK)
	L  0s   Bc                 r    dd|di}| j                  dd| j                   |      }|j                         S )zRemove all assigned annotators for tasks

        Parameters
        ----------
        tasks_ids: list of int

        Returns
        -------
        dict
            Dict with counter of deleted annotator assignments

        r~   Fry   rr   z-/api/dm/actions?id=delete_annotators&project=rs   rj   rk   rl   rB   r   ru   r@   s       r   delete_annotators_assignmentz$Project.delete_annotators_assignment   sJ     #Ey$IJ$$;DGG9E % 

 }}r   c                 r    dd|di}| j                  dd| j                   |      }|j                         S )zClear all assigned reviewers for tasks

        Parameters
        ----------
        tasks_ids: list of int

        Returns
        -------
        dict
            Dict with counter of deleted reviewer assignments

        r~   Fry   rr   z,/api/dm/actions?id=delete_reviewers&project=rs   r   r   s       r   delete_reviewers_assignmentz#Project.delete_reviewers_assignment   sJ     #Ey$IJ$$:477)D % 

 }}r   c                     |D cg c]  }|j                    c}d|ddd}| j                  dd| j                    d|      }|j                         S c c}w )	a  Assign reviewers to tasks

        Parameters
        ----------
        users: list of user's objects
        tasks_ids: list of integer task IDs to assign reviewers to

        Returns
        -------
        dict
            Dict with counter of created assignments

        Fry   REr}   rr   re   r   rs   rt   )rB   rh   r   rq   ru   r@   s         r   assign_reviewerszProject.assign_reviewers  sg     +00$dgg0%*	B

 $$nTWWI-=>W % 
 }} 1s   Ac                     || j                   vr-| j                          || j                   vrt        d| d      | j                   |   S )Nz	Project "z" field is not set)rW   update_paramsr!   )rB   
param_names     r   r\   zProject._get_param  sQ    T[[( ,/
|+=>  {{:&&r   c                 `    | j                  dd| j                         }|j                         S )aQ  Get all available project parameters.

        Returns
        --------
        dict
            containing all following params:

        title: str
            Project name.
        description: str
            Project description
        label_config: str
            Label config in XML format.
        expert_instruction: str
            Labeling instructions in HTML format
        show_instruction: bool
            Whether to display instructions to annotators before they start
        show_skip_button: bool
            Whether to show a skip button in the Label Studio UI and let annotators skip the task
        enable_empty_annotation: bool
            Allow annotators to submit empty annotations
        show_annotation_history: bool
            Show annotation history to annotator
        organization: int
            Organization ID
        color: str
            Color to decorate the project card in the Label Studio UI
        maximum_annotations: int
            Maximum number of annotations for one task. If the number of annotations per task is equal or greater
            to this value, the task is finished and is_labeled=True is set. (Enterprise only)
        is_published: bool
            Whether or not the project is published to annotators (Enterprise only)
        model_version: str
            Machine learning model version for predictions or pre-annotations
        is_draft: bool
            Whether or not the project is in the middle of being created (Enterprise only)
        created_by: object
            Details about the user that created the project
        min_annotations_to_start_training: int
            Minimum number of completed tasks after which model training is started
        show_collab_predictions: bool
            Whether to show model predictions to the annotator, allowing them to collaborate with the ML model
        sampling: str
            Type of sampling to use for task labeling. Uncertainty sampling is Enterprise only.
            Enum: "Sequential sampling" "Uniform sampling" "Uncertainty sampling"
        show_ground_truth_first: bool
            Whether to show tasks with ground truth annotations first (Enterprise only)
        show_overlap_first: bool
            Whether to show tasks with overlap first (Enterprise only)
        overlap_cohort_percentage: int
            Percentage of tasks that must be annotated multiple times. (Enterprise only)
        task_data_login: str
            User credentials for accessing task data. (Enterprise only)
        task_data_password: str
            Password credentials for accessing task data. (Enterprise only)
        control_weights: object
            Weights for control tags used when calculating agreement metrics. (Enterprise only)
        evaluate_predictions_automatically: bool
            Retrieve and display predictions when loading a task

        rd   re   r   rA   s     r   
get_paramszProject.get_params(  s.    | $$UnTWWI,FG}}r   c                 b    | j                  dd| j                   d      }|j                         S )zGet the list of available ML model versions from pre-annotations or connected ML backends.

        Returns
        -------
        list of strings
             Model versions

        rd   re   z/model-versionsr   rA   s     r   get_model_versionszProject.get_model_versionsi  s/     $$UnTWWI_,UV}}r   c                 .    | j                         | _        y)zdGet [all available project parameters](#label_studio_sdk.project.Project.get_params) and cache them.N)r   rW   rG   s    r   r   zProject.update_paramsu  s    oo'r   c                     | j                  dd|      }|j                  dk(  r|j                         | _        yt	        d      )a\  Create a new labeling project in Label Studio.

        Parameters
        ----------
        title: str
            Project name.
        description: str
            Project description
        label_config: str
            Label config in XML format.
        expert_instruction: str
            Labeling instructions in HTML format
        show_instruction: bool
            Whether to display instructions to annotators before they start
        show_skip_button: bool
            Whether to show a skip button in the Label Studio UI and let annotators skip the task
        enable_empty_annotation: bool
            Allow annotators to submit empty annotations
        show_annotation_history: bool
            Show annotation history to annotator
        organization: int
            Organization ID
        color: str
            Color to decorate the project card in the Label Studio UI
        maximum_annotations: int
            Maximum number of annotations for one task. If the number of annotations per task is equal or greater
            to this value, the task is finished and is_labeled=True is set. (Enterprise only)
        is_published: bool
            Whether or not the project is published to annotators (Enterprise only)
        model_version: str
            Machine learning model version for predictions or pre-annotations
        is_draft: bool
            Whether or not the project is in the middle of being created (Enterprise only)
        created_by: object
            Details about the user that created the project
        min_annotations_to_start_training: int
            Minimum number of completed tasks after which model training is started
        show_collab_predictions: bool
            Whether to show model predictions to the annotator, allowing them to collaborate with the ML model
        sampling: str
            Type of sampling to use for task labeling. Uncertainty sampling is Enterprise only.
            Enum: "Sequential sampling" "Uniform sampling" "Uncertainty sampling"
        show_ground_truth_first: bool
            Whether to show tasks with ground truth annotations first (Enterprise only)
        show_overlap_first: bool
            Whether to show tasks with overlap first (Enterprise only)
        overlap_cohort_percentage: int
            Percentage of tasks that must be annotated multiple times. (Enterprise only)
        task_data_login: str
            User credentials for accessing task data. (Enterprise only)
        task_data_password: str
            Password credentials for accessing task data. (Enterprise only)
        control_weights: object
            Weights for control tags used when calculating agreement metrics. (Enterprise only)
        evaluate_predictions_automatically: bool
            Retrieve and display predictions when loading a task

        Raises LabelStudioException in case of errors.

        rr   z/api/projectsrs      zProject not createdN)rj   status_coderl   rW   r   rB   rY   r@   s      r   start_projectzProject.start_projecty  sC    z $$V_6$J3&"--/DK&'<==r   Nc                      | |j                   |j                  |j                  |j                  |j                  |j
                        }|rt        |t              r||_        ||j                  d<   |S )N)urlapi_keysessionextra_headersversionsmake_request_raiserk   )	r   r   r   headersr   r   
isinstancedictrW   )clsrg   
project_idrW   projects        r   _create_from_idzProject._create_from_id  s`    

NNNN ..__%88
 j.#GN)tr   returnc                 J    | j                  ||      }|j                          |S )zClass factory to create a project instance from an existing project ID.

        Parameters
        ----------
        client: class Client
        project_id: int
            Project ID

        Returns
        -------
        `Project`
        )r   r   )r   rg   r   r   s       r   get_from_idzProject.get_from_id  s'     %%fj9r   preannotated_from_fieldsc                    ddi}|rdj                  |      |d<   t        |t        t        f      r%| j	                  dd| j
                   d||d	      }nt        |t        t        f      rjt        j                  j                  |      st        d
|       t        |d      5 }| j	                  dd| j
                   dd|i|d      }ddd       nt        dt        |             j                         }d|v rd}ddg}t!        j                          }	 | j	                  dd| j
                   d|d          j                         }	|	d   dk(  r|	d   S |	d   dk(  rt        |	d         t!        j                          |z
  |k\  rt        d      t!        j"                  |d          |d   |d   |d   z   g}|d   S # 1 sw Y   xY w)a  Import JSON-formatted labeling tasks. Tasks can be unlabeled or contain predictions.

        Parameters
        ----------
        tasks: list of dicts | dict | path to file
            Tasks in <a href="https://labelstud.io/guide/tasks.html#Basic-Label-Studio-JSON-format">
            Label Studio JSON format</a>

        preannotated_from_fields: list of strings
            Turns flat task JSON formatted like: `{"column1": value, "column2": value}` into Label Studio prediction
            data format: `{"data": {"column1"..}, "predictions": [{..."column2"}]`
            Useful when all your data is stored in tabular format with one column dedicated to model predictions.

        Returns
        -------
        list of int
            Imported task IDs

        return_task_ids1,r   rr   re   z/import)
   iX  )methodr   rl   rW   timeoutzNot found import tasks file rb)modefile)r   r   filesrW   r   Nz1Not supported type provided as "tasks" argument: importi,  r   rd   z	/imports/)r   r   rE   r=   task_idsr<   errorzImport timeoutr   )joinr   listr   rj   rk   strr   ospathisfiler   open	TypeErrorr   rl   timesleep)
rB   tasksr   rW   r@   fr   fibonacci_backoff
start_timeimport_statuss
             r   import_taskszProject.import_tasks  s   ( $S)#14:R1SF-.edD\*(($TWWIW5! ) H T{+77>>%(*-I%+QRRe$' 1,,!(	9!1+!% -   CDK=Q  ==?xG!"AJ $ 1 1 (	8H;M:NO !2 ! $& 
 !*k9(44 *h6.}W/EFF99;+w6./?@@

,Q/0%a(%a(+<Q+??%!! * 
##U s   &'GGexport_typedownload_all_tasksdownload_resourcesidsexport_locationc                    |||d}|r||d<   | j                  dd| j                   d|      }|0d|j                         vrt        | d	      |j	                         S t        j                  |      }|j                  j                  d
d
       t        |d      5 }	|j                  d      D ]  }
|	j                  |
        	 ddd       |S # 1 sw Y   |S xY w)a  Export annotated tasks.

        Parameters
        ----------
        export_type: string
            Default export_type is JSON.
            Specify another format type as referenced in <a href="https://github.com/heartexlabs/label-studio-converter/blob/master/label_studio_converter/converter.py#L32">
            the Label Studio converter code</a>.

        download_all_tasks: bool
            Default download_all_tasks is False.
            If true, download all tasks regardless of status. If false, download only annotated tasks.

        download_resources: bool
            Default download_resources is False.
            If true, download all resource files such as images, audio, and others relevant to the tasks.

        ids: list of ints
            Optional, specify a list of task IDs to retrieve only the details for those tasks.
        export_location: str or path
            Optional, specify a location to save the export to, this is mandatory for the YOLO export.
            A pathlib.Path object will be returned instead of the deserialized json.
        Returns
        -------
        list of dicts if export_location is None
            Tasks with annotations
        pathlib.Path if export_location is not None
            Path to the export

        )
exportTyper   r   r   rd   re   z/export)r   r   rW   NJSONz8 export type requires an export location to be specifiedT)parentsexist_okwbi   )
chunk_size)rj   rk   upper
ValueErrorrl   pathlibr   parentmkdirr   iter_contentwrite)rB   r   r   r   r   r   rW   r@   export_pathout_filer   s              r   export_taskszProject.export_tasks-  s   N &"4"4

 F5M$$twwiw? % 
 "[..00 "m#[\  ==?"ll?3 	   =+t$ 	&!.. /  & u%&	& 	& s    )CCc                 h    | j                  dd| j                   |      }|j                  dk(  sJ y)z-Low level function to set project parameters.PATCHre   rs      Nrj   rk   r   r   s      r   
set_paramszProject.set_paramsq  s8    $$Wtwwi.Hv$V##s***r   samplingc                 <    | j                  |j                         y)z8Set the project sampling method for the labeling stream.)r   N)r   value)rB   r   s     r   set_samplingzProject.set_samplingv  s    0r   is_publishedc                 (    | j                  |       y)zSet the project publication state. (Enterprise only)

        Parameters
        ----------
        is_published: bool
            Project publication state for reviewers and annotators

        )r   Nr   )rB   r   s     r   set_publishedzProject.set_publishedz  s     	\2r   model_versionc                 (    | j                  |       y)a9  Set the current model version to use for displaying predictions to annotators, perform uncertainty sampling
        and annotation evaluations in Label Studio Enterprise, and other operations.

        Parameters
        ----------
        model_version: string
            It can be any string you want

        )r   Nr   )rB   r   s     r   set_model_versionzProject.set_model_version  s     	m4r   only_idsc           	         d}g }i }|j                  d      s8	 | j                  ||||||d      }||d   z  }|dz  }|j                  d      s8|S # t        $ r#}	t        j	                  d|	        Y d}	~	|S d}	~	ww xY w)a  Retrieve a subset of tasks from the Data Manager based on a filter, ordering mechanism, or a
        predefined view ID.

        Parameters
        ----------
        filters: label_studio_sdk.data_manager.Filters.create()
            JSON objects representing Data Manager filters. Use `label_studio_sdk.data_manager.Filters.create()`
            helper to create it.
            Example:
        ```json
        {
          "conjunction": "and",
          "items": [
            {
              "filter": "filter:tasks:id",
              "operator": "equal",
              "type": "Number",
              "value": 1
            }
          ]
        }
        ```
        ordering: list of label_studio_sdk.data_manager.Column
            List with <b>one</b> string representing Data Manager ordering.
            Use `label_studio_sdk.data_manager.Column` helper class.
            Example:
            ```[Column.total_annotations]```, ```['-' + Column.total_annotations]``` - inverted order
        view_id: int
            View ID, visible as a Data Manager tab, for which to retrieve filters, ordering, and selected items
        selected_ids: list of ints
            Task IDs
        only_ids: bool
            If true, return only task IDs

        Returns
        -------
        list
            Task list with task data, annotations, predictions and other fields from the Data Manager

        r   end_paginationd   )filtersorderingview_idselected_idsr   page	page_sizer   zError during pagination: N)getget_paginated_tasksr   r   r   )
rB   r   r   r   r   r   r   resultdataes
             r   	get_taskszProject.get_tasks  s    b ((+,//#%#!-%! 0  $w-'	 ((+,   ( 8<=s   %A 	A>A99A>r   r   r   resolve_uric	                    ||xs g |rd|dndg dd}	| j                   |||t        j                  |	      d|d}
|rd|
d	<   | j                  d
d|
d      }|j                  dk(  rg ddS |j                  dk7  r"| j                  |       	 |j                          |j                         }|d   }|r|D cg c]  }|d   	 c}|d<   |S # t        $ r}t        d|       d}~ww xY wc c}w )a  Retrieve a subset of tasks from the Data Manager based on a filter, ordering mechanism, or a
        predefined view ID. For non-existent pages it returns 404 error.

        Parameters
        ----------
        filters: label_studio_sdk.data_manager.Filters.create()
            JSON objects representing Data Manager filters. Use `label_studio_sdk.data_manager.Filters.create()`
            helper to create it.
            Example:

                {
                  "conjunction": "and",
                  "items": [
                    {
                      "filter": "filter:tasks:id",
                      "operator": "equal",
                      "type": "Number",
                      "value": 1
                    }
                  ]
                }

        ordering: list of label_studio_sdk.data_manager.Column
            List with <b>one</b> string representing Data Manager ordering.
            Use `label_studio_sdk.data_manager.Column` helper class.
            Example:
            ```[Column.total_annotations]```, ```['-' + Column.total_annotations]``` - inverted order
        view_id: int
            View ID, visible as a Data Manager tab, for which to retrieve filters, ordering, and selected items
        selected_ids: list of ints
            Task IDs
        page: int
            Page. Default is 1.
        page_size: int
            Page size. Default is 100, to retrieve all tasks in the project you can use get_tasks().
        only_ids: bool
            If true, return only task IDs
        resolve_uri: bool
            Resolve pre-sign urls to https links

        Returns
        -------

        dict
            Example:

                {
                    "tasks": [{...}],
                    "total_annotations": 50,
                    "total_predictions": 100,
                    "total": 100
                }

        tasks: list of dicts
            Tasks with task data, annotations, predictions and other fields from the Data Manager
        total: int
            Total number of tasks in filtered result
        total_annotations: int
            Total number of annotations in filtered tasks
        total_predictions: int
            Total number of predictions in filtered tasks

        Fry   Trz   excluded)r   r   r~   rz   )r   r   r   viewqueryfieldsr  rk   includerd   z
/api/tasks)raise_exceptionsi  )r   r   r   zError loading tasks: Nr   )	rk   rl   dumpsrj   r   log_response_errorraise_for_statusr   r   )rB   r   r   r   r   r   r   r   r  r	  rW   r@   r  r  r   tasks                   r   r   zProject.get_paginated_tasks  s/   V  B   <8!r2
 ww"ZZ&&
  $F9$$<% % 
 3&488!!S(##H-H))+ }}W49:DT$Z:DM  H*-B1#+FGGH ;s   C 8C+	C(C##C(c                 0    d|d<    | j                   |i |S )zQSame as `label_studio_sdk.project.Project.get_tasks()` but returns only task IDs.Tr   r  rB   rX   rY   s      r   get_tasks_idszProject.get_tasks_idsJ  s"    !zt~~t.v..r   c                 0    d|d<    | j                   |i |S )zlSame as `label_studio_sdk.project.Project.get_paginated_tasks()` but returns
        only task IDs.
        Tr   )r   r  s      r   get_paginated_tasks_idszProject.get_paginated_tasks_idsO  s&     "z't''888r   c                 `    | j                  dd| j                         }|j                         S )a  Get all views related to the project

        Returns
        -------
        list
            List of view dicts

        The each dict contains the following fields:
        id: int
            View ID
        project: int
            Project ID
        user: int
            User ID who created this tab
        data: dict
            Filters, orderings and other visual settings
        rd   z/api/dm/views?project=r   rA   s     r   	get_viewszProject.get_viewsV  s.    $ $$U.DTWWI,NO}}r   c                 p    | j                   |||dd}| j                  dd|      }|j                         S )ak  Create view

        Parameters
        ----------
        filters: dict
            Specify the filters(`label_studio_sdk.data_manager.Filters`) of the view
        ordering: list of label_studio_sdk.data_manager.Column
            List with <b>one</b> string representing Data Manager ordering.
            Use `label_studio_sdk.data_manager.Column` helper class.
            Example:
            ```[Column.total_annotations]```, ```['-' + Column.total_annotations]``` - inverted order
        title: str
            Tab name
        Returns
        -------
        dict:
            dict with created view

        )titler   r   )r   r  rr   z/api/dm/viewsrs   rt   )rB   r   r   r  r  r@   s         r   create_viewzProject.create_viewk  sA    * ww#gN
 $$V_4$H}}r   c                 .    | j                  dd|       }y)zDelete view

        Parameters
        ----------
        view_id: int
            View ID

        Returns
        -------
        dict:
            dict with deleted view

        DELETEz/api/dm/views/N)rj   )rB   r   r@   s      r   delete_viewzProject.delete_view  s      $$Xy/IJr   c                 "    | j                         S )zbRetrieve all tasks from the project. This call can be very slow if the project has a lot of tasks.r  rG   s    r   r   zProject.tasks  s     ~~r   c                 "    | j                         S )z]IDs for all tasks for a project. This call can be very slow if the project has lots of tasks.)r  rG   s    r   r   zProject.tasks_ids  s     !!##r   c                 :    | j                  ddddddgd|      S )	a=  Retrieve all tasks that have been completed, i.e. where requested number of annotations have been created

        Parameters
        ----------
        only_ids: bool
            Return only task IDs.

        Returns
        -------
        list
            List of task dicts, the same as in `get_tasks`.

        andfilter:tasks:completed_atemptyFDatetimefilteroperatorr   r   conjunctionitemsr   r   r  rB   r   s     r   get_labeled_taskszProject.get_labeled_tasks  s?     ~~$ #>$+!& *	
   
 	
r   c                 &    | j                  d      S )zRetrieve all task IDs for completed tasks, i.e. where requested number of annotations have been created

        Returns
        -------
        list
            List of task IDs
        Tr   )r.  rG   s    r   get_labeled_tasks_idszProject.get_labeled_tasks_ids  s     %%t%44r   c                 :    | j                  ddddddgd|      S )	a  Retrieve all tasks that are <b>not</b> completed.
         If using Label Studio Enterprise, this can include tasks that have been labeled one or more times, but not the full number of times defined in the
        project labeling settings.

        Parameters
        ----------
        only_ids: bool
            Return only task IDs

        Returns
        -------
        list
            List of task dicts, the same as in `get_tasks`.

        r"  r#  r$  Tr%  r&  r)  r,  r  r-  s     r   get_unlabeled_taskszProject.get_unlabeled_tasks  s?      ~~$ #>$+!% *	
   
 	
r   c                 &    | j                  d      S )aP  Retrieve all task IDs for tasks that are <b>not</b> completed. If using
        Label Studio Enterprise, this can include tasks that have been labeled one or more times, but not the full
        number of times defined in the project labeling settings.

        Returns
        -------
        list
            List of task IDs
        Tr0  )r3  rG   s    r   get_unlabeled_tasks_idszProject.get_unlabeled_tasks_ids  s     '''66r   c                 L    | j                  dd|       }|j                         S )a  Get specific task by ID.

        Parameters
        ----------
        task_id: int
            Task ID you want to retrieve

        Returns
        -------
        dict:
            dict of task data containing all initial data and annotation results in [Label Studio JSON format](https://labelstud.io/guide/tasks.html#Basic-Label-Studio-JSON-format)

        ```
        id: int
            Task ID
        predictions: dict
            Predictions object
        annotations: dict
            Annotations object
        drafts: dict
            Drafts object
        data: object
            User imported or uploaded data for a task. Data is formatted according to the project label config.
        meta: object
            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.
            (Deprecated)
        created_at: str
            Date time string representing the time a task was created.
        updated_at: str
            Date time string representing the last time a task was updated.
        is_labeled: bool
            True if the number of annotations for this task is greater than or equal to the number of maximum_completions for the project.
        overlap: int
            Number of distinct annotators that processed the current task.
        project: int
            Project ID for this task
        file_upload: str
            Uploaded file used as data source for this task
        ```
        rd   /api/tasks/)rj   rl   rB   task_idr@   s      r   get_taskzProject.get_task  s*    R $$Uk',CD}}r   c                 p    | j                  dd| |      }|j                          |j                         S )a  Update specific task by ID.

        Parameters
        ----------
        task_id: int
            Task ID you want to update
        kwargs: kwargs parameters
            List of parameters to update. Check all available parameters [here](https://labelstud.io/api#operation/api_tasks_partial_update)

        Returns
        -------
        dict:
            Dict with updated task

        r   r7  rs   rj   r  rl   rB   r9  rY   r@   s       r   update_taskzProject.update_task  s:      $$WG9.EF$S!!#}}r   r9  r   scorec                     |||d}|||d<   | j                  dd|      }|j                         }t        j                  d|        |S )a  Create a prediction for a specific task.

        Parameters
        ----------
        task_id: int
            Task ID
        result: list or dict or str
            Result in the <a href="https://labelstud.io/guide/export.html#Label-Studio-JSON-format-of-annotated-tasks">
            Label Studio JSON format as for annotations</a>.
            For the labeling config:

                <View>
                <Image name="image" value="$value"/>
                <Choices name="class_name" toName="image">
                    <Choice value="Class A"/>
                    <Choice value="Class B"/>
                </Choices>
                </View>

            The following inputs are equivalent, result could be either full `"predictions"`:

                [{
                    "from_name": "class_name",
                    "to_name": "image",
                    "type": "choices",
                    "value": {
                        "choices": ["Class A"]
                    }
                }]

            or just `"value"` payload

                {"choices": ["Class A"]}

            or just the class name:

                "Class A"

        score: float
            Model prediction score
        model_version: str
            Any string identifying your model
        )r  r   r?  r   rr   z/api/predictionsrs   z
Response: )rj   rl   r   r   )rB   r9  r   r?  r   r  r@   rl   s           r   create_predictionzProject.create_prediction3  s\    d  6EB$$1D!$$V-?d$K}}z$()r   c                 f    | j                  dd| j                   d|      }|j                         S )a  Bulk create predictions for tasks. See <a href="https://labelstud.io/guide/predictions.html">more
        details about pre-annotated tasks</a>.

        Parameters
        ----------
        predictions: list of dicts
            List of dicts with predictions in the <a href="https://labelstud.io/guide/export.html#Label-Studio-JSON-format-of-annotated-tasks">
            Label Studio JSON format as for annotations</a>.
        rr   re   z/import/predictionsrs   r   )rB   predictionsr@   s      r   create_predictionszProject.create_predictionsm  s<     $$nTWWI-@A % 
 }}r   c                     dg d|g | j                   dg dd}| j                  ddd| j                   d	|
      }|j                         S )a  Create annotations from all predictions that exist for project tasks from specific ML model versions.

        Parameters
        ----------
        model_versions: list or None
            Convert predictions with these model versions to annotations. If `None`, all existing model versions are used

        Returns
        -------
        dict
            Dict with counter of created predictions

        r"  r)  Tr  )r   r   r   r   r~   rr   z/api/dm/actionspredictions_to_annotations)rk   r   )rW   rl   rt   )rB   model_versionsru   r@   s       r   #create_annotations_from_predictionsz+Project.create_annotations_from_predictions|  sb     (-r:+ww%)r:
 $$6477K	 % 
 }}r   c                 n    | j                  dd| d      }|j                          |j                         S )zList all annotations for a task.

        Parameters
        ----------
        task_id: int
            Task ID

        Returns
        -------
        list of dict:
            List of annotations objects
        rd   r7  z/annotationsr<  r8  s      r   list_annotationszProject.list_annotations  s7     $$Uk',,OP!!#}}r   c                 r    | j                  dd| d|      }|j                          |j                         S )a  Add annotations to a task like an annotator does.

        Parameters
        ----------
        task_id: int
            Task ID you want to update
        kwargs: kwargs parameters
            List of parameters to create. Check all available parameters [here](https://labelstud.io/api#operation/api_tasks_annotations_create).
            Labeling is stored in the `result` field as a list of dicionaries, [{...}, {...}, ...]

        Returns
        -------
        dict:
            Dict with created annotation

        rr   r7  z/annotations/rs   r<  r=  s       r   create_annotationzProject.create_annotation  sC    " $$k'-8v % 
 	!!#}}r   annotation_idc                 l    | j                  dd|       }|j                          |j                         S )a&  Retrieve a specific annotation for a task using the annotation ID.

        Parameters
        ----------
        annotation_id: int
            A unique integer value identifying this annotation.

        Returns
        ----------
        dict
            Retreived annotation object
        rd   /api/annotations/r<  rB   rM  r@   s      r   get_annotationzProject.get_annotation  s6     $$U.?,OP!!#}}r   c                 p    | j                  dd| |      }|j                          |j                         S )a  Update specific annotation with new annotation parameters, e.g.
            ```
            project.update_annotation(annotation_id=123, ground_truth=True)
            ```

        Parameters
        ----------
        annotation_id: int
            Existing annotation ID from current project. Could be retrieved from `project.get_tasks()` response
        kwargs: kwargs parameters
            List of annotation parameters. Check all available parameters [here](https://labelstud.io/guide/export.html#Label-Studio-JSON-format-of-annotated-tasks)

        Returns
        -------
        dict
            Dict with updated annotation

        r   rO  rs   r<  )rB   rM  rY   r@   s       r   update_annotationzProject.update_annotation  sB    & $$(8v % 
 	!!#}}r   c                 d    | j                  dd|       }|j                          |j                  S )a,  Delete an annotation using the annotation ID. This action can't be undone!

        Parameters
        ----------
        annotation_id: int
            A unique integer value identifying this annotation.

        Returns
        ----------
        int
            Status code for operation

        r  rO  )rj   r  r   rP  s      r   delete_annotationzProject.delete_annotation  s6     $$X1B=//RS!!####r   c                     | j                         }| j                         }|d   }|j                         D ci c]  \  }}|||z   }}}|S c c}}w )ap  Prediction coverage stats for all model versions for the project.

        Returns
        -------
        dict
            Example:

                {
                    "2021-01-01": 0.9,
                     "2021-02-01": 0.7
                }

            `0.9` means that 90% of project tasks is covered by predictions with model_version `"2021-01-01"`

        task_number)r   r   r+  )rB   rG  rW   tasks_numberr   countcoverages          r   get_predictions_coveragez Project.get_predictions_coverage  sj      002"m, )7(<(<(>
$u 5<//
 
 	
s   Ac                     t         r?   NotImplementedErrorrG   s    r   get_predictions_conflictz Project.get_predictions_conflict      !!r   c                     t         r?   r]  rG   s    r   get_predictions_precisionz!Project.get_predictions_precision  r`  r   bucketprefixregex_filteruse_blob_urlsgoogle_application_credentialspresignpresign_ttlr  descriptionc
                    |rCt         j                  j                  |      r$t        |      5 }
|
j	                         }ddd       || j
                  ||||||||	d
}| j                  dd|      }|j                         S # 1 sw Y   DxY w)a  Connect a Google Cloud Storage (GCS) bucket to Label Studio to use as source storage and import tasks.

        Parameters
        ----------
        bucket: string
            Specify the name of the GCS bucket
        prefix: string
            Optional, specify the prefix or folder within the GCS bucket with your data
        regex_filter: string
            Optional, specify a regex filter to use to match the file types of your data
        use_blob_urls: bool
            Optional, true by default. Specify whether your data is raw image or video data, or JSON tasks.
        google_application_credentials: string
            Optional, provide a file with your Google application credentials. If not specified, it will use path stored in `GOOGLE_APPLICATION_CREDENTIALS` environmental variable. Read more about [Google Cloud authentication](https://cloud.google.com/docs/authentication/getting-started)
        presign: bool
            Optional, true by default. Specify whether or not to create presigned URLs.
        presign_ttl: int
            Optional, 1 by default. Specify how long to keep presigned URLs active.
        title: string
            Optional, specify a title for your GCS import storage that appears in Label Studio.
        description: string
            Optional, specify a description for your GCS import storage.

        Returns
        -------
        dict:
            containing the same fields as in the request and:

        id: int
            Storage ID
        type: str
            Type of storage
        created_at: str
            Creation time
        last_sync: str
            Time last sync finished, can be empty.
        last_sync_count: int
            Number of tasks synced in the last sync

        N)
rc  r   rd  re  rf  rg  rh  ri  r  rj  rr   z/api/storages/gcsrs   r   r   r   r   readrk   rj   rl   )rB   rc  rd  re  rf  rg  rh  ri  r  rj  r   ru   r@   s                r   connect_google_import_storagez%Project.connect_google_import_storage  s    h *bggnn*/
 45 :12.: ww(*.L&&
 $$V-@w$O}}!: :s   BB
can_delete_objectsc                    t         j                  j                  |      r$t        |      5 }|j	                         }ddd       ||||||| j
                  d}| j                  dd|      }	|	j                         S # 1 sw Y   AxY w)a  Connect a Google Cloud Storage (GCS) bucket to Label Studio to use as target storage and export tasks.

        Parameters
        ----------
        bucket: string
            Specify the name of the GCS bucket
        prefix: string
            Optional, specify the prefix or folder within the GCS bucket to export your data to
        google_application_credentials: string
            Optional, provide a file with your Google application credentials. If not specified, it will use path stored in `GOOGLE_APPLICATION_CREDENTIALS` environmental variable. Read more about [Google Cloud authentication](https://cloud.google.com/docs/authentication/getting-started)
        title: string
            Optional, specify a title for your GCS export storage that appears in Label Studio.
        description: string
            Optional, specify a description for your GCS export storage.
        can_delete_objects: bool
            False by default. Specify whether to delete tasks in the GCS bucket if they are deleted in Label Studio.

        Returns
        -------
        dict:
            containing the same fields as in the request and:

        id: int
            Storage ID
        type: str
            Type of storage
        created_at: str
            Creation time
        last_sync: str
            Time last sync finished, can be empty.
        last_sync_count: int
            Number of tasks synced in the last sync

        N)rc  rd  rg  r  rj  ro  r   rr   z/api/storages/export/gcsrs   rl  )
rB   rc  rd  rg  r  rj  ro  r   ru   r@   s
             r   connect_google_export_storagez%Project.connect_google_export_storagee  s    V 77>>8945 :12.: .L&"4ww
 $$V-Gg$V}}: :s   A<<Baws_access_key_idaws_secret_access_keyaws_session_tokenregion_names3_endpointrecursive_scanc                     |||||	|
|||||||| j                   |d}| j                  dd|      }|j                         S )a  Connect an Amazon S3 bucket to Label Studio to use as source storage and import tasks.

        Parameters
        ----------
        bucket: string
            Specify the name of the S3 bucket.
        prefix: string
            Optional, specify the prefix within the S3 bucket to import your data from.
        regex_filter: string
            Optional, specify a regex filter to use to match the file types of your data.
        use_blob_urls: bool
            Optional, true by default. Specify whether your data is raw image or video data, or JSON tasks.
        presign: bool
            Optional, true by default. Specify whether or not to create presigned URLs.
        presign_ttl: int
            Optional, 1 by default. Specify how long to keep presigned URLs active.
        title: string
            Optional, specify a title for your S3 import storage that appears in Label Studio.
        description: string
            Optional, specify a description for your S3 import storage.
        aws_access_key_id: string
            Optional, specify the access key ID for your bucket.
        aws_secret_access_key: string
            Optional, specify the secret access key for your bucket.
        aws_session_token: string
            Optional, specify a session token to use to access your bucket.
        region_name: string
            Optional, specify the AWS region of your S3 bucket.
        s3_endpoint: string
            Optional, specify an S3 endpoint URL to use to access your bucket instead of the standard access method.
        recursive_scan: bool
            Optional, specify whether to perform recursive scan over the bucket content.

        Returns
        -------
        dict:
            containing the same fields as in the request and:

        id: int
            Storage ID
        type: str
            Type of storage
        created_at: str
            Creation time
        last_sync: str
            Time last sync finished, can be empty.
        last_sync_count: int
            Number of tasks synced in the last sync
        )rc  rd  re  rf  rr  rs  rt  ru  rv  rh  ri  r  rj  r   rw  rr   z/api/storages/s3rs   rt   )rB   rc  rd  re  rf  rh  ri  r  rj  rr  rs  rt  ru  rv  rw  ru   r@   s                    r   connect_s3_import_storagez!Project.connect_s3_import_storage  sc    F (*!2%:!2&&&&ww,
" $$V-?g$N}}r   role_arnexternal_idaws_sse_kms_key_idc                     || j                         }|d   }|||||||	|
|||||| j                  |d}| j                  dd|      }|j                         S )aS  Create S3 secured import storage with IAM role access. Enterprise only.

        Parameters
        ----------
        role_arn: string
            Required, specify the AWS Role ARN to assume.
        external_id: string or None
            Optional, specify the external ID to use to assume the role. If None, SDK will call api/organizations/<id>
            and use external_id from the response. You can find this ID on the organization page in the Label Studio UI.
        bucket: string
            Specify the name of the S3 bucket.
        prefix: string
            Optional, specify the prefix within the S3 bucket to import your data from.
        regex_filter: string
            Optional, specify a regex filter to use to match the file types of your data.
        use_blob_urls: bool
            Optional, true by default. Specify whether your data is raw image or video data, or JSON tasks.
        presign: bool
            Optional, true by default. Specify whether or not to create presigned URLs.
        presign_ttl: int
            Optional, 1 by default. Specify how long to keep presigned URLs active.
        title: string
            Optional, specify a title for your S3 import storage that appears in Label Studio.
        description: string
            Optional, specify a description for your S3 import storage.
        region_name: string
            Optional, specify the AWS region of your S3 bucket.
        s3_endpoint: string
            Optional, specify an S3 endpoint URL to use to access your bucket instead of the standard access method.
        recursive_scan: bool
            Optional, specify whether to perform recursive scan over the bucket content.
        aws_sse_kms_key_id: string
            Optional, specify an AWS SSE KMS Key ID for server-side encryption.
        synchronizable, last_sync, last_sync_count, last_sync_job, status, traceback, meta:
            Parameters for synchronization details and storage status.

        Returns
        -------
        dict:
            containing the response from the API including storage ID and type, among other details.
        r{  )rc  rd  re  rf  rh  ri  r  rj  rw  rz  ru  rv  r|  r   r{  rr   z/api/storages/s3s/rs   )get_organizationrk   rj   rl   )rB   rz  r{  rc  rd  re  rf  rh  ri  r  rj  ru  rv  rw  r|  organizationru   r@   s                     r   connect_s3s_iam_import_storagez&Project.connect_s3s_iam_import_storage  s    t 002L&}5K (*&&, &&"4ww&
" $$V-A$P}}r   c                 z    |||||||	|||
| j                   d}| j                  dd|      }|j                         S )aj  Connect an Amazon S3 bucket to Label Studio to use as target storage and export tasks.

        Parameters
        ----------
        bucket: string
            Specify the name of the S3 bucket.
        prefix: string
            Optional, specify the prefix or folder within the S3 bucket to export your data to.
        title: string
            Optional, specify a title for your S3 export storage that appears in Label Studio.
        description: string
            Optional, specify a description for your S3 export storage.
        aws_access_key_id: string
            Optional, specify the access key ID for your bucket.
        aws_secret_access_key: string
            Optional, specify the secret access key for your bucket.
        aws_session_token: string
            Optional, specify a session token to use to access your bucket.
        region_name: string
            Optional, specify the AWS region of your S3 bucket.
        s3_endpoint: string
            Optional, specify an S3 endpoint URL to use to access your bucket instead of the standard access method.
        can_delete_objects: bool
            False by default. Specify whether to delete tasks in the S3 bucket if they are deleted in Label Studio.

        Returns
        -------
        dict:
            containing the same fields as in the request and:

        id: int
            Storage ID
        type: str
            Type of storage
        created_at: str
            Creation time
        last_sync: str
            Time last sync finished, can be empty.
        last_sync_count: int
            Number of tasks synced in the last sync
        )rc  rd  rr  rs  rt  ru  rv  r  rj  ro  r   rr   z/api/storages/export/s3rs   rt   )rB   rc  rd  r  rj  rr  rs  rt  ru  rv  ro  ru   r@   s                r   connect_s3_export_storagez!Project.connect_s3_export_storageH  sW    p !2%:!2&&&"4ww
 $$V-FW$U}}r   	containeraccount_nameaccount_keyc                 z    |||||	|
||||| j                   d}| j                  dd|      }|j                         S )a  Connect a Microsoft Azure BLOB storage container to Label Studio to use as source storage and import tasks.

        Parameters
        ----------
        container: string
            Specify the name of the Azure container.
        prefix: string
            Optional, specify the prefix or folder within the Azure container with your data.
        regex_filter: string
            Optional, specify a regex filter to use to match the file types of your data.
        use_blob_urls: bool
            Optional, true by default. Specify whether your data is raw image or video data, or JSON tasks.
        presign: bool
            Optional, true by default. Specify whether or not to create presigned URLs.
        presign_ttl: int
            Optional, 1 by default. Specify how long to keep presigned URLs active.
        title: string
            Optional, specify a title for your Azure import storage that appears in Label Studio.
        description: string
            Optional, specify a description for your Azure import storage.
        account_name: string
            Optional, specify the name of the account with access to the container.
        account_key: string
            Optional, specify the key for the account with access to the container.

        Returns
        -------
        dict:
            containing the same fields as in the request and:

        id: int
            Storage ID
        type: str
            Type of storage
        created_at: str
            Creation time
        last_sync: str
            Time last sync finished, can be empty.
        last_sync_count: int
            Number of tasks synced in the last sync
        )r  rd  re  rf  r  r  rh  ri  r  rj  r   rr   z/api/storages/azurers   rt   )rB   r  rd  re  rf  rh  ri  r  rj  r  r  ru   r@   s                r   connect_azure_import_storagez$Project.connect_azure_import_storage  sW    n #(*(&&&ww
 $$V-B$Q}}r   c           	      t    |||||||| j                   d}| j                  dd|      }	|	j                         S )aN  Connect Microsoft Azure BLOB storage to Label Studio to use as target storage and export tasks.

        Parameters
        ----------
        container: string
            Specify the name of the Azure storage container.
        prefix: string
            Optional, specify the prefix or folder within the Azure container to export your data to.
        title: string
            Optional, specify a title for your Azure export storage that appears in Label Studio.
        description: string
            Optional, specify a description for your Azure export storage.
        can_delete_objects: bool
            False by default. Specify whether to delete tasks in the Azure container if they are deleted in Label Studio.
        account_name: string
            Optional, specify the name of the account with access to the container.
        account_key: string
            Optional, specify the key for the account with access to the container.

        Returns
        -------
        dict:
            containing the same fields as in the request and:

        id: int
            Storage ID
        type: str
            Type of storage
        created_at: str
            Creation time
        last_sync: str
            Time last sync finished, can be empty.
        last_sync_count: int
            Number of tasks synced in the last sync
        )r  rd  r  r  r  rj  ro  r   rr   z/api/storages/export/azurers   rt   )
rB   r  rd  r  rj  r  r  ro  ru   r@   s
             r   connect_azure_export_storagez$Project.connect_azure_export_storage  sO    \ #(&&"4ww	
 $$V-IPW$X}}r   local_store_pathc           	         dt         j                  vrt        d      t         j                  d   }t         j                  j	                  |      st        | d      t        |      t        |      j                  v du r>t        t        t        |             dt        t        |      j                               |||dd||| j                  d}| j                  dd	| j                   |
      }|j                         S )a7  Connect a Local storage to Label Studio to use as source storage and import tasks.
        Parameters
        ----------
        local_store_path: string
            Path to declare as local storage.
        regex_filter: string
            Optional, specify a regex filter to use to match the file types of your data
        use_blob_urls: bool
            Optional, true by default. Specify whether your data is raw image or video data, or JSON tasks.
        title: string
            Optional, specify a title for your GCS import storage that appears in Label Studio.
        description: string
            Optional, specify a description for your GCS import storage.
        Returns
        -------
        dict:
            containing the same fields as in the request and:
        id: int
            Storage ID
        type: str
            Type of storage
        created_at: str
            Creation time
        last_sync: str
            Time last sync finished, can be empty.
        last_sync_count: int
            Number of tasks synced in the last sync
        &LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOTzTo use connect_local_import_storage() you should set LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT environment variable, read more: https://labelstud.io/guide/storage.html#Prerequisites-2z is not a directoryFz/ is not presented in local_store_path parents: r   )re  rf  r   rh  ri  r  rj  r   rr   z!/api/storages/localfiles?project=rs   )r   environr   r   isdirr   r   r   rk   rj   rl   )	rB   r  re  rf  r  rj  rootru   r@   s	            r   connect_local_import_storagez$Project.connect_local_import_storage  s   H 42::EU 
 zzBCww}}-. 011DEFFJ$/0888UBtDz?##Rt,-55679  )*$&ww	
 $$7yA % 
 }}r   c           	      f    | j                  dd| dt        |       d      }|j                         S )a  Synchronize Import (Source) Cloud Storage.

        Parameters
        ----------
        storage_type: string
            Specify the type of the storage container. See ProjectStorage for available types.
        storage_id: int
            Specify the storage ID of the storage container. See get_import_storages() to get ids.

        Returns
        -------
        dict:
            containing the same fields as in the original storage request and:

        id: int
            Storage ID
        type: str
            Type of storage
        created_at: str
            Creation time
        last_sync: str
            Time last sync finished, can be empty.
        last_sync_count: int
            Number of tasks synced in the last sync
        rr   z/api/storages///syncrj   r   rl   rB   storage_type
storage_idr@   s       r   sync_import_storagezProject.sync_import_storageR  s;    6 $$n\N!C
O3DEJ
 }}r   c           	      f    | j                  dd| dt        |       d      }|j                         S )a  Synchronize Export (Target) Cloud Storage.

        Parameters
        ----------
        storage_type: string
            Specify the type of the storage container. See ProjectStorage for available types.
        storage_id: int
            Specify the storage ID of the storage container. See get_export_storages() to get ids.

        Returns
        -------
        dict:
            containing the same fields as in the original storage request and:

        id: int
            Storage ID
        type: str
            Type of storage
        created_at: str
            Creation time
        other fields:
            See more https://api.labelstud.io/#tag/Storage:S3/operation/api_storages_export_s3_sync_create
        rr   z/api/storages/export/r  r  r  r  s       r   sync_export_storagezProject.sync_export_storages  s<    0 $$+L>3z?:K5Q
 }}r   c                 `    | j                  dd| j                         }|j                         S )a
  Get Import (Source) Cloud Storage.

        Returns
        -------
        list of dicts:
            List of dicts with source storages, each dict consists of these fields:

        -------
        Each dict consists of these fields:

        id : int
            A unique integer value identifying this storage.
        type : str
            The type of the storage. Default is "s3".
        synchronizable : bool
            Indicates if the storage is synchronizable. Default is True.
        presign : bool
            Indicates if the storage is presign. Default is True.
        last_sync : str or None
            The last sync finished time. Can be None.
        last_sync_count : int or None
            The count of tasks synced last time. Can be None.
        last_sync_job : str or None
            The last sync job ID. Can be None.
        status : str
            The status of the storage. Can be one of "initialized", "queued", "in_progress", "failed", "completed".
        traceback : str or None
            The traceback report for the last failed sync. Can be None.
        meta : dict or None
            Meta and debug information about storage processes. Can be None.
        title : str or None
            The title of the cloud storage. Can be None.
        description : str or None
            The description of the cloud storage. Can be None.
        created_at : str
            The creation time of the storage.
        bucket : str or None
            The S3 bucket name. Can be None.
        prefix : str or None
            The S3 bucket prefix. Can be None.
        regex_filter : str or None
            The cloud storage regex for filtering objects. Can be None.
        use_blob_urls : bool
            Indicates if objects are interpreted as BLOBs and generate URLs.
        aws_access_key_id : str or None
            The AWS_ACCESS_KEY_ID. Can be None.
        aws_secret_access_key : str or None
            The AWS_SECRET_ACCESS_KEY. Can be None.
        aws_session_token : str or None
            The AWS_SESSION_TOKEN. Can be None.
        aws_sse_kms_key_id : str or None
            The AWS SSE KMS Key ID. Can be None.
        region_name : str or None
            The AWS Region. Can be None.
        s3_endpoint : str or None
            The S3 Endpoint. Can be None.
        presign_ttl : int
            The presigned URLs TTL (in minutes).
        recursive_scan : bool
            Indicates if a recursive scan over the bucket content is performed.
        glob_pattern : str or None
            The glob pattern for syncing from bucket. Can be None.
        synced : bool
            Flag indicating if the dataset has been previously synced or not.

        rd   z/api/storages/?project=r   rA   s     r   get_import_storageszProject.get_import_storages  s/    F $$U.EdggY,OP}}r   c                 `    | j                  dd| j                         }|j                         S )aS	  Get Export (Target) Cloud Storage.

        Returns
        -------
        list of dicts:
            List of dicts with target storages

        -------
        Each dict consists of these fields:

        id : int
            A unique integer value identifying this storage.
        type : str
            The type of the storage. Default is "s3".
        synchronizable : bool
            Indicates if the storage is synchronizable. Default is True.
        last_sync : str or None
            The last sync finished time. Can be None.
        last_sync_count : int or None
            The count of tasks synced last time. Can be None.
        last_sync_job : str or None
            The last sync job ID. Can be None.
        status : str
            The status of the storage. Can be one of "initialized", "queued", "in_progress", "failed", "completed".
        traceback : str or None
            The traceback report for the last failed sync. Can be None.
        meta : dict or None
            Meta and debug information about storage processes. Can be None.
        title : str or None
            The title of the cloud storage. Can be None.
        description : str or None
            The description of the cloud storage. Can be None.
        created_at : str
            The creation time of the storage.
        can_delete_objects : bool or None
            Deletion from storage enabled. Can be None.
        bucket : str or None
            The S3 bucket name. Can be None.
        prefix : str or None
            The S3 bucket prefix. Can be None.
        regex_filter : str or None
            The cloud storage regex for filtering objects. Can be None.
        use_blob_urls : bool
            Indicates if objects are interpreted as BLOBs and generate URLs.
        aws_access_key_id : str or None
            The AWS_ACCESS_KEY_ID. Can be None.
        aws_secret_access_key : str or None
            The AWS_SECRET_ACCESS_KEY. Can be None.
        aws_session_token : str or None
            The AWS_SESSION_TOKEN. Can be None.
        aws_sse_kms_key_id : str or None
            The AWS SSE KMS Key ID. Can be None.
        region_name : str or None
            The AWS Region. Can be None.
        s3_endpoint : str or None
            The S3 Endpoint. Can be None.
        project : int
            A unique integer value identifying this project.
        rd   z/api/storages/export?project=r   rA   s     r   get_export_storageszProject.get_export_storages  s/    x $$U.KDGG9,UV}}r         ?rh   assign_functionr   r   fractionoverlapc                 T   t        |      dkD  sJ d       t        |      |k\  sJ d       t        |d   t              r.| j                         }|D cg c]  }|j                  |v s| }}g }	| j                  |d      }
t        |
      dkD  sJ d       |dk7  r#t        t        |
      |z        }t        |
|      }
|dkD  rt        |
       |
|z  }
t        t        t        |
      t        |      z        d      }|D ]  }|t        |
      kD  rt        |
      }n|dz   t        |
      k(  r
|dk7  r|dz   }|t        j                  k(  r|dk(  rt        |
|      }n-|t        j                  k(  r|dkD  r|
d	| }nt        d
| d      |	j                   ||g|             |dkD  r|
|d	 }
n t        t        |
      t        |      z
        }
t        |
      dk(  s n t        |
      dkD  r6|D ]1  }|
s |	S |
j                         }|	j                   ||g|g             3 |	S c c}w )a  
        Assigning tasks to Reviewers or Annotators by assign_function with method by fraction from view_id
        Parameters
        ----------
        users: List[int]
            users' IDs list
        assign_function: Callable
            Function to assign tasks by list of user IDs
        view_id: int
            Optional, view ID to filter tasks to assign
        method: AssignmentSamplingMethod
            Optional, Assignment method
        fraction: float
            Optional, expresses the size of dataset to be assigned
        overlap: int
            Optional, expresses the count of assignments for each task
        Returns
        -------
        list[dict]
            List of dicts with counter of created assignments
        r   zUsers list is empty.z%Overlap is more than number of users.T)r   r   zTasks list is empty.r  r   NzSampling method z is not allowed)lenr   intro   rk   r  r   r   maxr7   r%   r   rm   r   setpop)rB   rh   r  r   r   r  r  project_usersrq   final_resultsr   kn_taskssample_tasksr  s                  r   _assign_by_samplingzProject._assign_by_sampling  s?   < 5zA~555~5zW$M&MM$eAh$ ,,.M&3Hdtww%7GTHEHw>5zA~555~s?CJ)*A5!$EQ;ENGOEc#e*E
23Q7 	DU#e* 1E
*w!|!A+1888W\%eW53:::w{$Xg #3F8?!KLL  $!FG{ghSZ#l*;;<5zQ)	, u:> F  yy{$$_dVdV%DE	F
 Y Is   H%&H%c                 D    | j                  || j                  ||||      S )a/  
        Behaves similarly like `assign_reviewers()` but instead of specify tasks_ids explicitely,
        it gets users' IDs list and optional view ID and uniformly splits all tasks across reviewers
        Fraction expresses the size of dataset to be assigned
        Parameters
        ----------
        users: List[int]
            users' IDs list
        view_id: int
            Optional, view ID to filter tasks to assign
        method: AssignmentSamplingMethod
            Optional, Assignment method
        fraction: float
            Optional, expresses the size of dataset to be assigned
        overlap: int
            Optional, expresses the count of assignments for each task
        Returns
        -------
        list[dict]
            List of dicts with counter of created assignments
        rh   r  r   r   r  r  )r  r   rB   rh   r   r   r  r  s         r   assign_reviewers_by_samplingz$Project.assign_reviewers_by_samplingi  s4    : '' 11 ( 
 	
r   c                 D    | j                  || j                  ||||      S )a(  
        Behaves similarly like `assign_annotators()` but instead of specify tasks_ids explicitly,
        it gets users' IDs list and optional view ID and splits all tasks across annotators.
        Fraction expresses the size of dataset to be assigned.
        Parameters
        ----------
        users: List[int]
            users' IDs list
        view_id: int
            Optional, view ID to filter tasks to assign
        method: AssignmentSamplingMethod
            Optional, Assignment method
        fraction: float
            Optional, expresses the size of dataset to be assigned
        overlap: int
            Optional, expresses the count of assignments for each task
        Returns
        -------
        list[dict]
            List of dicts with counter of created assignments
        r  )r  r   r  s         r   assign_annotators_by_samplingz%Project.assign_annotators_by_sampling  s4    : '' 22 ( 
 	
r   c                 b    | j                  dd| j                   d      }|j                         S )a  
        Get list of export snapshots for the current project
        -------
        Returns
        -------
        list[dict]
            List of dict with export snapshots with status:

        id: int
            Export ID
        created_at: str
            Creation time
        status: str
            Export status
        created_by: dict
            User data
        finished_at: str
            Finished time
        rd   re   z/exportsr   rA   s     r   export_snapshot_listzProject.export_snapshot_list  s/    ( $$UnTWWIX,NO}}r   task_filter_optionsserialization_options_drafts!serialization_options_predictions/serialization_options_annotations__completed_byannotation_filter_options_usual&annotation_filter_options_ground_truth!annotation_filter_options_skippedinterpolate_key_framesc
                     |i }|d|id|id|i|	d||||dd}
| j                  dd| j                   d|	 |
      }|j                         S )	a  
        Create new export snapshot
        ----------
        Parameters
        ----------
        title: str
            Export title
        task_filter_options: dict
            Task filter options, use {"view": tab_id} to apply filter from this tab,
            <a href="https://api.labelstud.io/#operation/api_projects_exports_create">check the API parameters for more details</a>
        serialization_options_drafts: bool
            Expand drafts (False) or include only ID (True)
        serialization_options_predictions: bool
            Expand predictions (False) or include only ID (True)
        serialization_options_annotations__completed_by: bool
            Expand user that completed_by (False) or include only ID (True)
        annotation_filter_options_usual: bool
            Include not cancelled and not ground truth annotations
        annotation_filter_options_ground_truth: bool
            Filter ground truth annotations
        annotation_filter_options_skipped: bool
            Filter skipped annotations
        interpolate_key_frames: bool
            Interpolate key frames into sequence

        Returns
        -------
        dict:
            containing the same fields as in the request and the created export fields:
        id: int
            Export ID
        created_at: str
            Creation time
        status: str
            Export status
        created_by: dict
            User data
        finished_at: str
            Finished time

        only_id)draftsrC  annotations__completed_byr  )usualground_truthskipped)r  serialization_optionsr  annotation_filter_optionsrr   re   z /exports?interpolate_key_frames=rs   r   )rB   r  r  r  r  r  r  r  r  r  ru   r@   s               r   export_snapshot_createzProject.export_snapshot_create  s    j &"$ $&BC )+LMN. +A& $78 F<*
" $$TWWI%EF\E]^ % 

 }}r   c                    |r| j                  d|      }d|d   i}nd}d} | j                  d||d|}|d   }	| j                  |	      j                         r5t	        j
                  d       | j                  |	      j                         r5t        j                  |d	       | j                  |	||
      \  }
}|r| j                  |d          |
||	dS )a  
        Export tasks from the project with optional filters,
        and save the exported data to a specified directory.

        This method:
        (1) creates a temporary view with the specified filters if they are not None,
        (2) creates a new export snapshot using the view ID,
        (3) checks the status of the snapshot creation while it's in progress,
        (4) and downloads the snapshot file in the specified export format.
        (5) After the export, it cleans up and remove the temporary view.

        Parameters
        ----------
        filters : data_manager.Filters, dict, optional
            Filters to apply when exporting tasks.
            If provided, a temporary view is created with these filters.
            The format of the filters should match the Label Studio filter options.
            Default is None, which means all tasks are exported.
            Use label_studio_sdk.data_manager.Filters.create() to create filters,
            Example of the filters JSON format:
        ```json
        {
          "conjunction": "and",
          "items": [
            {
              "filter": "filter:tasks:id",
              "operator": "equal",
              "type": "Number",
              "value": 1
            }
          ]
        }
        ```
        titile : str, optional
            The title of the export snapshot. Default is 'SDK Export'.
        export_type : str, optional
            The format of the exported data. It should be one of the formats supported by Label Studio ('JSON', 'CSV', etc.). Default is 'JSON'.
        output_dir : str, optional
            The directory where the exported file will be saved. Default is the current directory.
        kwargs : kwargs, optional
            The same parameters as in the export_snapshot_create method.

        Returns
        -------
        dict
            containing the status of the export, the filename of the exported file, and the export ID.

        filename : str
            Path to the downloaded export file
        status : int
            200 is ok
        export_id : int
            Export ID, you can retrieve more details about this export using this ID
        zTemp SDK export)r  r   r  rk   N)r  r  r  T)r   )r   r   )rE   filename	export_idr   )
r  r  export_snapshot_statusrL   r   r   r   makedirsexport_snapshot_downloadr  )rB   r   r  r   
output_dirrY   r  r  export_resultr  rE   r  s               r   exportzProject.export	  s    @ ##*;W#MD#)4:"6"&D 433 
 3
 
 "$'	)))4CCEJJsO )))4CCE 	J.  88;Z 9 

 T$Z( hYOOr   r  c                 x    | j                  dd| j                   d|       }t        |j                               S )a  
        Get export snapshot status by Export ID
        ----------
        Parameters
        ----------
        export_id: int
            Existing Export ID from current project. Can be referred as id from self.exports()

        Returns
        -------
        `label_studio_sdk.project.ExportSnapshotStatus`

        ExportSnapshotStatus.response is dict and contains the following fields:
        id: int
            Export ID
        created_at: str
            Creation time
        status: str
            created, completed, in_progress, failed
        created_by: dict
            User data
        finished_at: str
            Finished time
        rd   re   	/exports/)rj   rk   r9   rl   rB   r  r@   s      r   r  zProject.export_snapshot_status{	  s=    2 $$^DGG9Ii[A
 $HMMO44r   r   c           	         | j                  dd| j                   d| d|       }d}|j                  dk(  r|j                  j	                  d      }|rC|j                  d      d	   j                  d
      }t        j                  j                  |      }nt        d      t        t        j                  j                  ||      d      5 }|D ]  }|j                  |        	 ddd       |j                  |fS # 1 sw Y   xY w)a  
        Download file with export snapshot in provided format
        ----------
        Parameters
        ----------
        export_id: int
            Existing Export ID from current project. Can be referred as id from self.exports()
        export_type: str
            Default export_type is JSON.
            Specify another format type as referenced in <a href="https://github.com/heartexlabs/label-studio-converter/blob/master/label_studio_converter/converter.py#L32">
            the Label Studio converter code</a>.
        path: str
            Default path to store downloaded files
        Returns
        -------
        Status code for operation and downloaded filename
        rd   re   r  z/download?exportType=Nr   zContent-Dispositionz	filename=z"'zNo filename in responser   )rj   rk   r   r   r   splitstripr   r   basenamer   r   r   r   )	rB   r  r   r   r@   r  content_dispositionr   chks	            r   r  z Project.export_snapshot_download	  s    ( $$TWWIYyk9N{m\
 3&"*"2"2"6"67L"M".44[A"EKKER77++H5*+DEEbggll42D9 !Q# !CGGCL!! ##X--! !s   C<<Dc                 ^    | j                  dd| j                   d|       }|j                  S )zDelete an export file by specified export ID

        Parameters
        ----------
        export_id: int
            Existing Export ID from current project

        Returns
        ----------
        Status code for operation
        r  re   r  r   r  s      r   export_snapshot_deletezProject.export_snapshot_delete	  s8     $$twwiyD
 ###r   r   r  c                 D   |r| j                         }g }|rK|D ]F  }|d   D ]<  }	 t        |d   |   | j                  | j                        }|j	                  |       > H |S # t
        t        t        t        f$ r" t        j                  d|d   |    d       Y }w xY w)a#  Copy files from tasks to cache folder

        Parameters
        ----------
        tasks: Dict
        Tasks to download to local storage
        get_tasks: bool
        Get all tasks from current project

        Returns
        -------
        list
            List of filenames
        r  )access_tokenhostnamezCouldn't copy file .)r  r   r   r   rm   FileNotFoundErrorr   r   IOErrorr   r   )rB   r   r  	filenamesr  keyr  s          r   get_files_from_taskszProject.get_files_from_tasks	  s     NN$E	 
Q< 	QCQ#1 L-)-%)XX$
 "((2	Q
Q  .}mWU Q':4<;L:MQ%OPQs   9A$$8BBc                 Z    t        |t              sJ d       | j                  dd|       S )zDelete a task. To remove multiple tasks `use delete_tasks()`.

        Parameters
        ----------
        task_id: int
            Task id.
        ztask_id should be intr  r7  )r   r  rj   )rB   r9  s     r   delete_taskzProject.delete_task	  s4     '3'@)@@'  [	+BCCr   r   c                     t        |t              sJ d       |s
t               S d|d| j                  d}| j	                  dd| j                   d|      S )	zDelete multiple tasks by IDs.

        Parameters
        ----------
        task_ids: list of int
            Task ids.
        ztask_ids should be list of intFry   r~   r   rr   /api/dm/actions?project=&id=delete_tasksrs   )r   r   r   rk   rj   )rB   r   ru   s      r   delete_taskszProject.delete_tasks	  sk     (D)K+KK):%*Aww
   .twwi7GHw ! 
 	
r   excluded_idsc                     t        |t              s	|J d       |g }d|d| j                  d}| j                  dd| j                   d|      S )	zDelete all tasks from the project.

        Parameters
        ----------
        excluded_ids: list of int
            Task ids that should be excluded from the deletion.
        z*excluded_ids should be list of int or NoneTr  r  rr   r  r  rs   )r   r   rk   rj   )rB   r  ru   s      r   delete_all_taskszProject.delete_all_tasks
  st     |T*l.B	87	8BL%)|Dww
   .twwi7GHw ! 
 	
r   r?   )r   rT   )r   FFNN)NNNNF)NNNNr   r   FT)NTasks)F)Nr   N)NNTNTr    r  )NNr  r  F)NNTTr   r  r  NNNNNF)NNNNTTr   r  r  NNFN)	Nr  r  NNNNNF)	NNTTr   r  r  NN)Nr  r  NNF)NTr  r  )NTTTTTTF)Nz
SDK Exportr   r  )r   r  )ar   r   r   rC   r^   propertyra   ro   rv   r   r   r   r   r\   r   r   r   r   classmethodr   r   r
   r   r   boolr   r  r	   r   r   r   r   r   r#   r   r   r   r  r   r  r  r  r  r  r   r   r.  r1  r3  r5  r:  r>  r   floatrA  rD  rH  rJ  rL  r   rQ  rS  rU  r[  r_  rb  rn  rq  ry  r  r  r  r  r  r  r  r  r  r7   r%   r   r  r  r  r  r  r  r9   r  r  r  r  r   r  r  r  __classcell__)rZ   s   @r   rT   rT   k   sS
   % / /22&<**0'?B
(A>F    "M$D M$b "#(#(#')-BB !B !	B
 d3i B "#B 
tW\\!	"BH+
1_ 1	3$ 	3
5s 
5 D DP  q q q q qf/
9*6"     $ $
:5
>
7*X. :>!"'+88 tDz44568 	8
  }8t:  " 4 .C D "2$s $s $$2"" !%&*(,8<"&%&!%'GG G sm	G
  ~G )1G $G c]G }G c]GX !%8<!%'#(99 9 )1	9
 }9 c]9 !9| !%&*(,"&%&!%'+//3+/%)%)).TT T sm	T
  ~T $T c]T }T c]T $C=T  (}T $C=T c]T c]T !Tr &* $ $&*(,"&%&!%'%)%)).,0PP c]P 	P
 P smP  ~P $P c]P }P c]P c]P c]P !P %SMPj !%!%'+//3+/%)%)#(EE E }	E
 c]E $C=E  (}E $C=E c]E c]E !ET !%&*(,"&%&!%'&*%)DD D sm	D
  ~D $D c]D }D c]D smD c]DR !%!%'&*%)#(88 8 }	8
 c]8 sm8 c]8 !8z '+(,!%'A%A smA  ~	A
 }A c]AFB<DL=F +C+J+JQCyQ "Q 	Q
 )Q Q Ql +C+J+J$
Cy$
 $
 )	$

 $
 $
R +C+J+J$
Cy$
 $
 )	$

 $
 $
Ld 4 %)-126@D047;26',NN "N '+	N
 ,0N :>N *.N 15N ,0N !%N 
Nd ]P~5 58L 5> FI#.#.+.#.?B#.
s#.J$ $ $"$ 4 @	D3 	D8 	D
T 
h 
&
T 
X 
r   rT   ),r$   rl   loggingr   r   r   enumr   r   r   randomr   r   typingr   r	   r
   r   r   Alabel_studio_sdk._extensions.label_studio_tools.core.label_configr   =label_studio_sdk._extensions.label_studio_tools.core.utils.ior   requestsr   requests.exceptionsr   r   r   rg   r   utilsr   	getLoggerr   r   	Exceptionr   r!   r#   r)   r7   r9   rT   r   r   r   <module>r     s      	     " 8 8 Z X  G G  &			8	$	9 		 4 	bd bET E"t '9 '9Tu&
f u&
r   