@@ -437,112 +437,6 @@ def search_folders(
437437 ]
438438 return [folder .name for folder in data if not folder .is_root ]
439439
440- def copy_image (
441- self ,
442- source_project : Union [NotEmptyStr , dict ],
443- image_name : NotEmptyStr ,
444- destination_project : Union [NotEmptyStr , dict ],
445- include_annotations : Optional [StrictBool ] = False ,
446- copy_annotation_status : Optional [StrictBool ] = False ,
447- copy_pin : Optional [StrictBool ] = False ,
448- ):
449- """Copy image to a project. The image's project is the same as destination
450- project then the name will be changed to <image_name>_(<num>).<image_ext>,
451- where <num> is the next available number deducted from project image list.
452-
453- :param source_project: project name plus optional subfolder in the project (e.g., "project1/folder1") or
454- metadata of the project of source project
455- :type source_project: str or dict
456- :param image_name: image name
457- :type image_name: str
458- :param destination_project: project name or metadata of the project of destination project
459- :type destination_project: str or dict
460- :param include_annotations: enables annotations copy
461- :type include_annotations: bool
462- :param copy_annotation_status: enables annotations status copy
463- :type copy_annotation_status: bool
464- :param copy_pin: enables image pin status copy
465- :type copy_pin: bool
466- """
467- warning_msg = "The SAClient.copy_image method will be deprecated with the Superannotate Python SDK 4.4.6 release"
468- warnings .warn (warning_msg , DeprecationWarning )
469- logger .warning (warning_msg )
470- source_project_name , source_folder_name = extract_project_folder (source_project )
471- destination_project_name , destination_folder_name = extract_project_folder (
472- destination_project
473- )
474- source_project_metadata = self .controller .projects .get_by_name (
475- source_project_name
476- ).data
477- destination_project_metadata = self .controller .projects .get_by_name (
478- destination_project_name
479- ).data
480-
481- if destination_project_metadata .type .value in [
482- constants .ProjectType .VIDEO .value ,
483- constants .ProjectType .DOCUMENT .value ,
484- ] or source_project_metadata .type .value in [
485- constants .ProjectType .VIDEO .value ,
486- constants .ProjectType .DOCUMENT .value ,
487- ]:
488- raise AppException (LIMITED_FUNCTIONS [source_project_metadata .type ])
489-
490- response = self .controller .copy_image (
491- from_project_name = source_project_name ,
492- from_folder_name = source_folder_name ,
493- to_project_name = destination_project_name ,
494- to_folder_name = destination_folder_name ,
495- image_name = image_name ,
496- copy_annotation_status = copy_annotation_status ,
497- )
498- if response .errors :
499- raise AppException (response .errors )
500- if copy_pin :
501- destination_project = self .controller .get_project (
502- destination_project_metadata
503- )
504- _folder = self .controller .get_folder (
505- destination_project , destination_folder_name
506- )
507- item = self .controller .items .get_by_name (
508- destination_project_metadata , _folder , image_name
509- ).data
510- item .is_pinned = 1
511- self .controller .items .update (
512- project = destination_project_metadata ,
513- folder = _folder ,
514- image_name = image_name ,
515- is_pinned = 1 ,
516- )
517- if include_annotations :
518- source_project = self .controller .get_project (source_project_name )
519- source_folder = self .controller .get_folder (
520- source_project , source_folder_name
521- )
522- source_image = self .controller .items .get_by_name (
523- source_project , source_folder , image_name
524- ).data
525- destination_project = self .controller .get_project (destination_project )
526- destination_folder = self .controller .get_folder (
527- destination_project , destination_folder_name
528- )
529- destination_image = self .controller .items .get_by_name (
530- destination_project , destination_folder , image_name
531- ).data
532- self .controller .annotation_classes .copy_multiple (
533- source_project = source_project ,
534- source_folder = source_folder ,
535- source_item = source_image ,
536- destination_project = destination_project ,
537- destination_folder = destination_folder ,
538- destination_item = destination_image ,
539- )
540-
541- logger .info (
542- f"Copied image { source_project } /{ image_name } "
543- f" to { destination_project_name } /{ destination_folder_name } ."
544- )
545-
546440 def get_project_metadata (
547441 self ,
548442 project : Union [NotEmptyStr , dict ],
@@ -1616,79 +1510,6 @@ def upload_annotations_from_folder_to_project(
16161510 raise AppException (response .errors )
16171511 return response .data
16181512
1619- def upload_preannotations_from_folder_to_project (
1620- self ,
1621- project : Union [NotEmptyStr , dict ],
1622- folder_path : Union [str , Path ],
1623- from_s3_bucket = None ,
1624- recursive_subfolders : Optional [StrictBool ] = False ,
1625- ):
1626- """Finds and uploads all JSON files in the folder_path as pre-annotations to the project.
1627-
1628- The JSON files should follow specific naming convention. For Vector
1629- projects they should be named "<image_filename>___objects.json" (e.g., if
1630- image is cats.jpg the annotation filename should be cats.jpg___objects.json), for Pixel projects
1631- JSON file should be named "<image_filename>___pixel.json" and also second mask
1632- image file should be present with the name "<image_name>___save.png". In both cases
1633- image with <image_name> should be already present on the platform.
1634-
1635- Existing pre-annotations will be overwritten.
1636-
1637- :param project: project name or folder path (e.g., "project1/folder1")
1638- :type project: str
1639- :param folder_path: from which folder to upload the pre-annotations
1640- :type folder_path: Path-like (str or Path)
1641- :param from_s3_bucket: AWS S3 bucket to use. If None then folder_path is in local filesystem
1642- :type from_s3_bucket: str
1643- :param recursive_subfolders: enable recursive subfolder parsing
1644- :type recursive_subfolders: bool
1645-
1646- :return: paths to pre-annotations uploaded and could-not-upload
1647- :rtype: tuple of list of strs
1648- """
1649- warning_msg = (
1650- "The SAClient.upload_preannotations_from_folder_to_project"
1651- " method will be deprecated with the Superannotate Python SDK 4.4.6 release"
1652- )
1653- warnings .warn (warning_msg , DeprecationWarning )
1654- logger .warning (warning_msg )
1655- project_name , folder_name = extract_project_folder (project )
1656- project_folder_name = project_name + (f"/{ folder_name } " if folder_name else "" )
1657- project = self .controller .get_project (project_name )
1658- if project .type in [
1659- constants .ProjectType .VIDEO ,
1660- constants .ProjectType .DOCUMENT ,
1661- ]:
1662- raise AppException (LIMITED_FUNCTIONS [project .type ])
1663- if recursive_subfolders :
1664- logger .info (
1665- "When using recursive subfolder parsing same name annotations in different "
1666- "subfolders will overwrite each other." ,
1667- )
1668- logger .info (
1669- "The JSON files should follow a specific naming convention, matching file names already present "
1670- "on the platform. Existing annotations will be overwritten"
1671- )
1672- annotation_paths = get_annotation_paths (
1673- folder_path , from_s3_bucket , recursive_subfolders
1674- )
1675- logger .info (
1676- f"Uploading { len (annotation_paths )} annotations from { folder_path } to the project { project_folder_name } ."
1677- )
1678- project , folder = self .controller .get_project_folder (project_name , folder_name )
1679- response = self .controller .annotations .upload_from_folder (
1680- project = project ,
1681- folder = folder ,
1682- team = self .controller .team ,
1683- annotation_paths = annotation_paths , # noqa: E203
1684- client_s3_bucket = from_s3_bucket ,
1685- folder_path = folder_path ,
1686- is_pre_annotations = True ,
1687- )
1688- if response .errors :
1689- raise AppException (response .errors )
1690- return response .data
1691-
16921513 def upload_image_annotations (
16931514 self ,
16941515 project : Union [NotEmptyStr , dict ],
@@ -1971,6 +1792,12 @@ def add_annotation_bbox_to_image(
19711792 :param error: if not None, marks annotation as error (True) or no-error (False)
19721793 :type error: bool
19731794 """
1795+ warning_msg = (
1796+ "The SAClient.add_annotation_bbox_to_image method will "
1797+ "be deprecated with the Superannotate Python SDK 4.4.7 release"
1798+ )
1799+ warnings .warn (warning_msg , DeprecationWarning )
1800+ logger .warning (warning_msg )
19741801 project_name , folder_name = extract_project_folder (project )
19751802 project = self .controller .get_project (project_name )
19761803
@@ -2035,6 +1862,12 @@ def add_annotation_point_to_image(
20351862 :param error: if not None, marks annotation as error (True) or no-error (False)
20361863 :type error: bool
20371864 """
1865+ warning_msg = (
1866+ "The SAClient.add_annotation_point_to_image method will "
1867+ "be deprecated with the Superannotate Python SDK 4.4.7 release"
1868+ )
1869+ warnings .warn (warning_msg , DeprecationWarning )
1870+ logger .warning (warning_msg )
20381871 project , folder = self .controller .get_project_folder_by_path (project )
20391872 if project .type in [
20401873 constants .ProjectType .VIDEO ,
@@ -2091,6 +1924,12 @@ def add_annotation_comment_to_image(
20911924 :param resolved: comment resolve status
20921925 :type resolved: bool
20931926 """
1927+ warning_msg = (
1928+ "The SAClient.add_annotation_comment_to_image method will "
1929+ "be deprecated with the Superannotate Python SDK 4.4.7 release"
1930+ )
1931+ warnings .warn (warning_msg , DeprecationWarning )
1932+ logger .warning (warning_msg )
20941933 project_name , folder_name = extract_project_folder (project )
20951934 project = self .controller .projects .get_by_name (project_name ).data
20961935 if project .type in [
0 commit comments