@@ -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 ],
@@ -1621,79 +1515,6 @@ def upload_annotations_from_folder_to_project(
16211515 raise AppException (response .errors )
16221516 return response .data
16231517
1624- def upload_preannotations_from_folder_to_project (
1625- self ,
1626- project : Union [NotEmptyStr , dict ],
1627- folder_path : Union [str , Path ],
1628- from_s3_bucket = None ,
1629- recursive_subfolders : Optional [StrictBool ] = False ,
1630- ):
1631- """Finds and uploads all JSON files in the folder_path as pre-annotations to the project.
1632-
1633- The JSON files should follow specific naming convention. For Vector
1634- projects they should be named "<image_filename>___objects.json" (e.g., if
1635- image is cats.jpg the annotation filename should be cats.jpg___objects.json), for Pixel projects
1636- JSON file should be named "<image_filename>___pixel.json" and also second mask
1637- image file should be present with the name "<image_name>___save.png". In both cases
1638- image with <image_name> should be already present on the platform.
1639-
1640- Existing pre-annotations will be overwritten.
1641-
1642- :param project: project name or folder path (e.g., "project1/folder1")
1643- :type project: str
1644- :param folder_path: from which folder to upload the pre-annotations
1645- :type folder_path: Path-like (str or Path)
1646- :param from_s3_bucket: AWS S3 bucket to use. If None then folder_path is in local filesystem
1647- :type from_s3_bucket: str
1648- :param recursive_subfolders: enable recursive subfolder parsing
1649- :type recursive_subfolders: bool
1650-
1651- :return: paths to pre-annotations uploaded and could-not-upload
1652- :rtype: tuple of list of strs
1653- """
1654- warning_msg = (
1655- "The SAClient.upload_preannotations_from_folder_to_project"
1656- " method will be deprecated with the Superannotate Python SDK 4.4.6 release"
1657- )
1658- warnings .warn (warning_msg , DeprecationWarning )
1659- logger .warning (warning_msg )
1660- project_name , folder_name = extract_project_folder (project )
1661- project_folder_name = project_name + (f"/{ folder_name } " if folder_name else "" )
1662- project = self .controller .get_project (project_name )
1663- if project .type in [
1664- constants .ProjectType .VIDEO ,
1665- constants .ProjectType .DOCUMENT ,
1666- ]:
1667- raise AppException (LIMITED_FUNCTIONS [project .type ])
1668- if recursive_subfolders :
1669- logger .info (
1670- "When using recursive subfolder parsing same name annotations in different "
1671- "subfolders will overwrite each other." ,
1672- )
1673- logger .info (
1674- "The JSON files should follow a specific naming convention, matching file names already present "
1675- "on the platform. Existing annotations will be overwritten"
1676- )
1677- annotation_paths = get_annotation_paths (
1678- folder_path , from_s3_bucket , recursive_subfolders
1679- )
1680- logger .info (
1681- f"Uploading { len (annotation_paths )} annotations from { folder_path } to the project { project_folder_name } ."
1682- )
1683- project , folder = self .controller .get_project_folder (project_name , folder_name )
1684- response = self .controller .annotations .upload_from_folder (
1685- project = project ,
1686- folder = folder ,
1687- team = self .controller .team ,
1688- annotation_paths = annotation_paths , # noqa: E203
1689- client_s3_bucket = from_s3_bucket ,
1690- folder_path = folder_path ,
1691- is_pre_annotations = True ,
1692- )
1693- if response .errors :
1694- raise AppException (response .errors )
1695- return response .data
1696-
16971518 def upload_image_annotations (
16981519 self ,
16991520 project : Union [NotEmptyStr , dict ],
@@ -1976,6 +1797,12 @@ def add_annotation_bbox_to_image(
19761797 :param error: if not None, marks annotation as error (True) or no-error (False)
19771798 :type error: bool
19781799 """
1800+ warning_msg = (
1801+ "The SAClient.add_annotation_bbox_to_image method will "
1802+ "be deprecated with the Superannotate Python SDK 4.4.7 release"
1803+ )
1804+ warnings .warn (warning_msg , DeprecationWarning )
1805+ logger .warning (warning_msg )
19791806 project_name , folder_name = extract_project_folder (project )
19801807 project = self .controller .get_project (project_name )
19811808
@@ -2040,6 +1867,12 @@ def add_annotation_point_to_image(
20401867 :param error: if not None, marks annotation as error (True) or no-error (False)
20411868 :type error: bool
20421869 """
1870+ warning_msg = (
1871+ "The SAClient.add_annotation_point_to_image method will "
1872+ "be deprecated with the Superannotate Python SDK 4.4.7 release"
1873+ )
1874+ warnings .warn (warning_msg , DeprecationWarning )
1875+ logger .warning (warning_msg )
20431876 project , folder = self .controller .get_project_folder_by_path (project )
20441877 if project .type in [
20451878 constants .ProjectType .VIDEO ,
@@ -2096,6 +1929,12 @@ def add_annotation_comment_to_image(
20961929 :param resolved: comment resolve status
20971930 :type resolved: bool
20981931 """
1932+ warning_msg = (
1933+ "The SAClient.add_annotation_comment_to_image method will "
1934+ "be deprecated with the Superannotate Python SDK 4.4.7 release"
1935+ )
1936+ warnings .warn (warning_msg , DeprecationWarning )
1937+ logger .warning (warning_msg )
20991938 project_name , folder_name = extract_project_folder (project )
21001939 project = self .controller .projects .get_by_name (project_name ).data
21011940 if project .type in [
0 commit comments