6161logger = get_default_logger ()
6262
6363
64+
6465class SAClient (BaseInterfaceFacade , metaclass = TrackableMeta ):
6566 def get_team_metadata (self ):
6667 """Returns team metadata
@@ -312,6 +313,7 @@ def rename_project(self, project: NotEmptyStr, new_name: NotEmptyStr):
312313 )
313314 return ProjectSerializer (response .data ).serialize ()
314315
316+
315317 def get_folder_metadata (self , project : NotEmptyStr , folder_name : NotEmptyStr ):
316318 """Returns folder metadata
317319
@@ -667,6 +669,53 @@ def delete_images(
667669 f"Images deleted in project { project_name } { '/' + folder_name if folder_name else '' } "
668670 )
669671
672+ def assign_items (
673+ self , project : Union [NotEmptyStr , dict ], item_names : List [str ], user : str
674+ ):
675+ """Assigns items to a user. The assignment role, QA or Annotator, will
676+ be deduced from the user's role in the project. The type of the objects` image, video or text
677+ will be deduced from the project type. With SDK, the user can be
678+ assigned to a role in the project with the share_project function.
679+
680+ :param project: project name or folder path (e.g., "project1/folder1")
681+ :type project: str
682+ :param item_names: list of item names to assign
683+ :type item_names: list of str
684+ :param user: user email
685+ :type user: str
686+ """
687+
688+ project_name , folder_name = extract_project_folder (project )
689+
690+ response = self .controller .assign_items (
691+ project , folder_name , item_names , user
692+ )
693+
694+ if not response .errors :
695+ logger .info (f"Assign items to user { user } " )
696+ else :
697+ raise AppException (response .errors )
698+
699+ def unassign_items (
700+ self , project : Union [NotEmptyStr , dict ], item_names : List [NotEmptyStr ]
701+ ):
702+ """Removes assignment of given items for all assignees. With SDK,
703+ the user can be assigned to a role in the project with the share_project
704+ function.
705+
706+ :param project: project name or folder path (e.g., "project1/folder1")
707+ :type project: str
708+ :param item_names: list of items to unassign
709+ :type item_names: list of str
710+ """
711+ project_name , folder_name = extract_project_folder (project )
712+
713+ response = self .controller .un_assign_items (
714+ project_name = project_name , folder_name = folder_name , item_names = item_names
715+ )
716+ if response .errors :
717+ raise AppException (response .errors )
718+
670719 def assign_images (
671720 self , project : Union [NotEmptyStr , dict ], image_names : List [str ], user : str
672721 ):
@@ -681,6 +730,14 @@ def assign_images(
681730 :param user: user email
682731 :type user: str
683732 """
733+
734+ warning_msg = (
735+ "We're deprecating the assign_images function. Please use assign_items instead."
736+ "Learn more. \n "
737+ "https://superannotate.readthedocs.io/en/stable/superannotate.sdk.html#superannotate.assign_items"
738+ )
739+ logger .warning (warning_msg )
740+ warnings .warn (warning_msg , DeprecationWarning )
684741 project_name , folder_name = extract_project_folder (project )
685742 project = self .controller .get_project_metadata (project_name ).data
686743
@@ -719,18 +776,26 @@ def assign_images(
719776 def unassign_images (
720777 self , project : Union [NotEmptyStr , dict ], image_names : List [NotEmptyStr ]
721778 ):
722- """Removes assignment of given images for all assignees.With SDK,
779+ """Removes assignment of given images for all assignees. With SDK,
723780 the user can be assigned to a role in the project with the share_project
724781 function.
725782
726783 :param project: project name or folder path (e.g., "project1/folder1")
727784 :type project: str
728- :param image_names: list of image unassign
785+ :param image_names: list of images to unassign
729786 :type image_names: list of str
730787 """
788+
789+ warning_msg = (
790+ "We're deprecating the unassign_images function. Please use unassign_items instead."
791+ "Learn more. \n "
792+ "https://superannotate.readthedocs.io/en/stable/superannotate.sdk.html#superannotate.unassign_items"
793+ )
794+ logger .warning (warning_msg )
795+ warnings .warn (warning_msg , DeprecationWarning )
731796 project_name , folder_name = extract_project_folder (project )
732797
733- response = self .controller .un_assign_images (
798+ response = self .controller .un_assign_items (
734799 project_name = project_name , folder_name = folder_name , image_names = image_names
735800 )
736801 if response .errors :
0 commit comments