|
28 | 28 | from lib.app.interface.types import ProjectTypes |
29 | 29 | from lib.app.interface.types import validate_arguments |
30 | 30 | from lib.app.mixp.decorators import Trackable |
31 | | -from lib.app.serializers import BaseSerializers |
| 31 | +from lib.app.serializers import BaseSerializer |
32 | 32 | from lib.app.serializers import ImageSerializer |
33 | 33 | from lib.app.serializers import ProjectSerializer |
34 | 34 | from lib.app.serializers import SettingsSerializer |
@@ -435,7 +435,7 @@ def search_folders( |
435 | 435 | raise AppException(response.errors) |
436 | 436 | data = response.data |
437 | 437 | if return_metadata: |
438 | | - return [BaseSerializers(folder).serialize() for folder in data] |
| 438 | + return [BaseSerializer(folder).serialize() for folder in data] |
439 | 439 | return [folder.name for folder in data] |
440 | 440 |
|
441 | 441 |
|
@@ -763,7 +763,7 @@ def get_project_metadata( |
763 | 763 | for elem in "classes", "workflows", "contributors": |
764 | 764 | if response.get(elem): |
765 | 765 | metadata[elem] = [ |
766 | | - BaseSerializers(attribute).serialize() for attribute in response[elem] |
| 766 | + BaseSerializer(attribute).serialize() for attribute in response[elem] |
767 | 767 | ] |
768 | 768 | else: |
769 | 769 | metadata[elem] = [] |
@@ -829,7 +829,7 @@ def search_annotation_classes( |
829 | 829 | """ |
830 | 830 | project_name, folder_name = extract_project_folder(project) |
831 | 831 | classes = Controller.get_default().search_annotation_classes(project_name, name_prefix) |
832 | | - classes = [BaseSerializers(attribute).serialize() for attribute in classes.data] |
| 832 | + classes = [BaseSerializer(attribute).serialize() for attribute in classes.data] |
833 | 833 | return classes |
834 | 834 |
|
835 | 835 |
|
@@ -895,6 +895,11 @@ def get_image_metadata( |
895 | 895 | :return: metadata of image |
896 | 896 | :rtype: dict |
897 | 897 | """ |
| 898 | + warning_msg = ( |
| 899 | + # TODO add link |
| 900 | + "We're deprecating the get_image_metadata function. Please use get_item_metadata instead. Learn more. <link>." |
| 901 | + ) |
| 902 | + logger.warning(warning_msg) |
898 | 903 | project_name, folder_name = extract_project_folder(project) |
899 | 904 | project = Controller.get_default()._get_project(project_name) |
900 | 905 | response = Controller.get_default().get_image_metadata(project_name, folder_name, image_name) |
@@ -1576,7 +1581,7 @@ def create_annotation_class( |
1576 | 1581 | ) |
1577 | 1582 | if response.errors: |
1578 | 1583 | raise AppException(response.errors) |
1579 | | - return BaseSerializers(response.data).serialize() |
| 1584 | + return BaseSerializer(response.data).serialize() |
1580 | 1585 |
|
1581 | 1586 |
|
1582 | 1587 | @Trackable |
@@ -1659,7 +1664,7 @@ def create_annotation_classes_from_classes_json( |
1659 | 1664 | ) |
1660 | 1665 | if response.errors: |
1661 | 1666 | raise AppException(response.errors) |
1662 | | - return [BaseSerializers(i).serialize() for i in response.data] |
| 1667 | + return [BaseSerializer(i).serialize() for i in response.data] |
1663 | 1668 |
|
1664 | 1669 |
|
1665 | 1670 | @Trackable |
@@ -2157,7 +2162,7 @@ def download_model(model: MLModel, output_dir: Union[str, Path]): |
2157 | 2162 | if res.errors: |
2158 | 2163 | logger.error("\n".join([str(error) for error in res.errors])) |
2159 | 2164 | else: |
2160 | | - return BaseSerializers(res.data).serialize() |
| 2165 | + return BaseSerializer(res.data).serialize() |
2161 | 2166 |
|
2162 | 2167 |
|
2163 | 2168 | @Trackable |
@@ -2940,7 +2945,7 @@ def get_integrations(): |
2940 | 2945 | if response.errors: |
2941 | 2946 | raise AppException(response.errors) |
2942 | 2947 | integrations = response.data |
2943 | | - return BaseSerializers.serialize_iterable(integrations, ("name", "type", "root")) |
| 2948 | + return BaseSerializer.serialize_iterable(integrations, ("name", "type", "root")) |
2944 | 2949 |
|
2945 | 2950 |
|
2946 | 2951 | @Trackable |
@@ -2989,4 +2994,90 @@ def query(project: NotEmptyStr, query: Optional[NotEmptyStr]): |
2989 | 2994 | response = Controller.get_default().query_entities(project_name, folder_name, query) |
2990 | 2995 | if response.errors: |
2991 | 2996 | raise AppException(response.errors) |
2992 | | - return BaseSerializers.serialize_iterable(response.data) |
| 2997 | + return BaseSerializer.serialize_iterable(response.data) |
| 2998 | + |
| 2999 | + |
| 3000 | +@Trackable |
| 3001 | +@validate_arguments |
| 3002 | +def get_item_metadata( |
| 3003 | + project: NotEmptyStr, |
| 3004 | + item_name: NotEmptyStr, |
| 3005 | +): |
| 3006 | + """Returns item metadata |
| 3007 | +
|
| 3008 | + :param project: project name or folder path (e.g., “project1/folder1”) |
| 3009 | + :type project: str |
| 3010 | +
|
| 3011 | + :param item_name: item name |
| 3012 | + :type item_name: str |
| 3013 | +
|
| 3014 | + :return: metadata of item |
| 3015 | + :rtype: dict |
| 3016 | + """ |
| 3017 | + project_name, folder_name = extract_project_folder(project) |
| 3018 | + response = Controller.get_default().get_item(project_name, folder_name, item_name) |
| 3019 | + if response.errors: |
| 3020 | + raise AppException(response.errors) |
| 3021 | + return BaseSerializer(response.data).serialize() |
| 3022 | + |
| 3023 | + |
| 3024 | +@Trackable |
| 3025 | +@validate_arguments |
| 3026 | +def search_items( |
| 3027 | + project: NotEmptyStr, |
| 3028 | + name_contains: NotEmptyStr = None, |
| 3029 | + annotation_status: Optional[AnnotationStatuses] = None, |
| 3030 | + annotator_email: Optional[NotEmptyStr] = None, |
| 3031 | + qa_email: Optional[NotEmptyStr] = None, |
| 3032 | + recursive: bool = False |
| 3033 | + |
| 3034 | +): |
| 3035 | + """Search items by filtering criteria. |
| 3036 | +
|
| 3037 | +
|
| 3038 | + :param project: project name or folder path (e.g., “project1/folder1”). |
| 3039 | + If recursive=False=True, then only the project name is required. |
| 3040 | + :type project: str |
| 3041 | +
|
| 3042 | + :param name_contains: Returns those items, where the given string is found anywhere within an item’s name. |
| 3043 | + If None, all items returned, in accordance with the recursive=False parameter. |
| 3044 | + :type name_contains: str |
| 3045 | +
|
| 3046 | + :param annotation_status: if not None, filters items by annotation status. |
| 3047 | + Values are: |
| 3048 | + “NotStarted” |
| 3049 | + “InProgress” |
| 3050 | + “QualityCheck” |
| 3051 | + “Returned” |
| 3052 | + “Completed” |
| 3053 | + “Skipped” |
| 3054 | + :type annotation_status: str |
| 3055 | +
|
| 3056 | +
|
| 3057 | + :param annotator_email: returns those items’ names that are assigned to the specified annotator. |
| 3058 | + If None, all items are returned. Strict equal. |
| 3059 | + :type annotator_email: str |
| 3060 | +
|
| 3061 | + :param qa_email: returns those items’ names that are assigned to the specified QA. |
| 3062 | + If None, all items are returned. Strict equal. |
| 3063 | + :type qa_email: str |
| 3064 | +
|
| 3065 | + :param recursive: search in the project’s root and all of its folders. |
| 3066 | + If False search only in the project’s root or given directory. |
| 3067 | + :type recursive: bool |
| 3068 | +
|
| 3069 | + :return: items metadata |
| 3070 | + :rtype: list of dicts |
| 3071 | + """ |
| 3072 | + project_name, folder_name = extract_project_folder(project) |
| 3073 | + response = Controller.get_default().list_items( |
| 3074 | + project_name, folder_name, |
| 3075 | + name_contains=name_contains, |
| 3076 | + annotation_status=annotation_status, |
| 3077 | + annotator_email=annotator_email, |
| 3078 | + qa_email=qa_email, |
| 3079 | + recursive=recursive |
| 3080 | + ) |
| 3081 | + if response.errors: |
| 3082 | + raise AppException(response.errors) |
| 3083 | + return BaseSerializer.serialize_iterable(response.data) |
0 commit comments