55from collections import namedtuple
66from datetime import datetime , timezone
77from pathlib import Path
8- from typing import TYPE_CHECKING , Any , Dict , Iterable , List , Optional , Union
8+ from typing import TYPE_CHECKING , Any , Dict , Iterable , List , Optional , TypeVar , Union , overload
99from urllib .parse import urlparse
1010
1111import requests
1212
1313from labelbox import parser
1414from labelbox import utils
15- from labelbox .exceptions import (InvalidQueryError , LabelboxError ,
16- ProcessingWaitTimeout , ResourceConflict ,
17- ResourceNotFoundError )
15+ from labelbox .exceptions import (
16+ InvalidQueryError ,
17+ LabelboxError ,
18+ ProcessingWaitTimeout ,
19+ ResourceConflict ,
20+ )
1821from labelbox .orm import query
1922from labelbox .orm .db_object import DbObject , Deletable , Updateable , experimental
2023from labelbox .orm .model import Entity , Field , Relationship
2528from labelbox .schema .export_filters import ProjectExportFilters , validate_datetime , build_filters
2629from labelbox .schema .export_params import ProjectExportParams
2730from labelbox .schema .export_task import ExportTask
31+ from labelbox .schema .identifiables import DataRowIdentifiers , UniqueIds
2832from labelbox .schema .media_type import MediaType
2933from labelbox .schema .queue_mode import QueueMode
3034from labelbox .schema .resource_tag import ResourceTag
3135from labelbox .schema .task import Task
3236from labelbox .schema .task_queue import TaskQueue
33- from labelbox .schema .user import User
3437
3538if TYPE_CHECKING :
3639 from labelbox import BulkImportRequest
3740
38- try :
39- datetime .fromisoformat # type: ignore[attr-defined]
40- except AttributeError :
41- from backports .datetime_fromisoformat import MonkeyPatch
42-
43- MonkeyPatch .patch_fromisoformat ()
44-
4541try :
4642 from labelbox .data .serialization import LBV1Converter
4743except ImportError :
@@ -643,7 +639,7 @@ def labeler_performance(self) -> PaginatedCollection:
643639 def create_labeler_performance (client , result ):
644640 result ["user" ] = Entity .User (client , result ["user" ])
645641 # python isoformat doesn't accept Z as utc timezone
646- result ["lastActivityTime" ] = datetime . fromisoformat (
642+ result ["lastActivityTime" ] = utils . format_iso_from_string (
647643 result ["lastActivityTime" ].replace ('Z' , '+00:00' ))
648644 return LabelerPerformance (** {
649645 utils .snake_case (key ): value for key , value in result .items ()
@@ -1382,29 +1378,44 @@ def task_queues(self) -> List[TaskQueue]:
13821378 for field_values in task_queue_values
13831379 ]
13841380
1381+ @overload
1382+ def move_data_rows_to_task_queue (self , data_row_ids : DataRowIdentifiers ,
1383+ task_queue_id : str ):
1384+ pass
1385+
1386+ @overload
13851387 def move_data_rows_to_task_queue (self , data_row_ids : List [str ],
13861388 task_queue_id : str ):
1389+ pass
1390+
1391+ def move_data_rows_to_task_queue (self , data_row_ids , task_queue_id : str ):
13871392 """
13881393
13891394 Moves data rows to the specified task queue.
13901395
13911396 Args:
1392- data_row_ids: a list of data row ids to be moved
1397+ data_row_ids: a list of data row ids to be moved. This can be a list of strings or a DataRowIdentifiers object
1398+ DataRowIdentifier objects are lists of ids or global keys. A DataIdentifier object can be a UniqueIds or GlobalKeys class.
13931399 task_queue_id: the task queue id to be moved to, or None to specify the "Done" queue
13941400
13951401 Returns:
13961402 None if successful, or a raised error on failure
13971403
13981404 """
1405+ if isinstance (data_row_ids , list ):
1406+ data_row_ids = UniqueIds (data_row_ids )
1407+ warnings .warn ("Using data row ids will be deprecated. Please use "
1408+ "UniqueIds or GlobalKeys instead." )
1409+
13991410 method = "createBulkAddRowsToQueueTask"
14001411 query_str = """mutation AddDataRowsToTaskQueueAsyncPyApi(
14011412 $projectId: ID!
14021413 $queueId: ID
1403- $dataRowIds: [ID!] !
1414+ $dataRowIdentifiers: AddRowsToTaskQueueViaDataRowIdentifiersInput !
14041415 ) {
14051416 project(where: { id: $projectId }) {
14061417 %s(
1407- data: { queueId: $queueId, dataRowIds : $dataRowIds }
1418+ data: { queueId: $queueId, dataRowIdentifiers : $dataRowIdentifiers }
14081419 ) {
14091420 taskId
14101421 }
@@ -1416,7 +1427,10 @@ def move_data_rows_to_task_queue(self, data_row_ids: List[str],
14161427 query_str , {
14171428 "projectId" : self .uid ,
14181429 "queueId" : task_queue_id ,
1419- "dataRowIds" : data_row_ids
1430+ "dataRowIdentifiers" : {
1431+ "ids" : [id for id in data_row_ids ],
1432+ "idType" : data_row_ids ._id_type ,
1433+ },
14201434 },
14211435 timeout = 180.0 ,
14221436 experimental = True )["project" ][method ]["taskId" ]
0 commit comments