Skip to content

Commit 6d83cfe

Browse files
authored
Merge pull request #527 from superannotateai/1491_1494
Deprecation Tasks
2 parents 983dd9a + 72038bc commit 6d83cfe

File tree

5 files changed

+23
-383
lines changed

5 files changed

+23
-383
lines changed

docs/source/superannotate.sdk.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ ________
4242
.. automethod:: superannotate.SAClient.upload_videos_from_folder_to_project
4343
.. _ref_upload_annotations_from_folder_to_project:
4444
.. automethod:: superannotate.SAClient.upload_annotations_from_folder_to_project
45-
.. automethod:: superannotate.SAClient.upload_preannotations_from_folder_to_project
4645
.. automethod:: superannotate.SAClient.add_contributors_to_project
4746
.. automethod:: superannotate.SAClient.get_project_settings
4847
.. automethod:: superannotate.SAClient.set_project_default_image_quality_in_editor
@@ -107,7 +106,6 @@ ______
107106
.. automethod:: superannotate.SAClient.download_image
108107
.. automethod:: superannotate.SAClient.download_image_annotations
109108
.. automethod:: superannotate.SAClient.upload_image_annotations
110-
.. automethod:: superannotate.SAClient.copy_image
111109
.. automethod:: superannotate.SAClient.pin_image
112110
.. automethod:: superannotate.SAClient.add_annotation_bbox_to_image
113111
.. automethod:: superannotate.SAClient.add_annotation_point_to_image

src/superannotate/lib/app/interface/cli_interface.py

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -129,27 +129,6 @@ def export_project(
129129
)
130130
sys.exit(0)
131131

132-
def upload_preannotations(
133-
self, project, folder, dataset_name=None, task=None, format=None
134-
):
135-
"""
136-
To upload preannotations from folder to project use
137-
Optional argument format accepts input annotation format. It can have COCO or SuperAnnotate values.
138-
If the argument is not given then SuperAnnotate (the native annotation format) is assumed.
139-
Only when COCO format is specified dataset-name and task arguments are required.
140-
dataset-name specifies JSON filename (without extension) in <folder_path>.
141-
task specifies the COCO task for conversion. Please see import_annotation_format for more details.
142-
"""
143-
self._upload_annotations(
144-
project=project,
145-
folder=folder,
146-
format=format,
147-
dataset_name=dataset_name,
148-
task=task,
149-
pre=True,
150-
)
151-
sys.exit(0)
152-
153132
def upload_annotations(
154133
self, project, folder, dataset_name=None, task=None, format=None
155134
):
@@ -167,13 +146,10 @@ def upload_annotations(
167146
format=format,
168147
dataset_name=dataset_name,
169148
task=task,
170-
pre=False,
171149
)
172150
sys.exit(0)
173151

174-
def _upload_annotations(
175-
self, project, folder, format, dataset_name, task, pre=True
176-
):
152+
def _upload_annotations(self, project, folder, format, dataset_name, task):
177153
project_folder_name = project
178154
project_name, folder_name = split_project_path(project)
179155
project = SAClient().controller.get_project(project_name)
@@ -197,14 +173,10 @@ def _upload_annotations(
197173
task=task,
198174
)
199175
annotations_path = temp_dir
200-
if pre:
201-
SAClient().upload_preannotations_from_folder_to_project(
202-
project_folder_name, annotations_path
203-
)
204-
else:
205-
SAClient().upload_annotations_from_folder_to_project(
206-
project_folder_name, annotations_path
207-
)
176+
177+
SAClient().upload_annotations_from_folder_to_project(
178+
project_folder_name, annotations_path
179+
)
208180
sys.exit(0)
209181

210182
def attach_image_urls(

src/superannotate/lib/app/interface/sdk_interface.py

Lines changed: 18 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)