|
34 | 34 | from lib.app.serializers import SettingsSerializer |
35 | 35 | from lib.app.serializers import TeamSerializer |
36 | 36 | from lib.core import LIMITED_FUNCTIONS |
| 37 | +from lib.core.entities.integrations import IntegrationEntity |
37 | 38 | from lib.core.entities.project_entities import AnnotationClassEntity |
38 | 39 | from lib.core.enums import ImageQuality |
39 | 40 | from lib.core.exceptions import AppException |
40 | 41 | from lib.core.types import AttributeGroup |
41 | 42 | from lib.core.types import MLModel |
| 43 | +from lib.core.types import PriorityScore |
42 | 44 | from lib.core.types import Project |
43 | 45 | from lib.infrastructure.controller import Controller |
44 | 46 | from pydantic import conlist |
@@ -189,7 +191,7 @@ def create_project_from_metadata(project_metadata: Project): |
189 | 191 | project_metadata = project_metadata.dict() |
190 | 192 | response = Controller.get_default().create_project( |
191 | 193 | name=project_metadata["name"], |
192 | | - description=project_metadata["description"], |
| 194 | + description=project_metadata.get("description"), |
193 | 195 | project_type=project_metadata["type"], |
194 | 196 | settings=project_metadata.get("settings", []), |
195 | 197 | annotation_classes=project_metadata.get("classes", []), |
@@ -1572,6 +1574,8 @@ def create_annotation_class( |
1572 | 1574 | attribute_groups=attribute_groups, |
1573 | 1575 | class_type=class_type, |
1574 | 1576 | ) |
| 1577 | + if response.errors: |
| 1578 | + raise AppException(response.errors) |
1575 | 1579 | return BaseSerializers(response.data).serialize() |
1576 | 1580 |
|
1577 | 1581 |
|
@@ -2900,3 +2904,71 @@ def get_annotations_per_frame(project: NotEmptyStr, video: NotEmptyStr, fps: int |
2900 | 2904 | if response.errors: |
2901 | 2905 | raise AppException(response.errors) |
2902 | 2906 | return response.data |
| 2907 | + |
| 2908 | + |
| 2909 | +@Trackable |
| 2910 | +@validate_arguments |
| 2911 | +def upload_priority_scores(project: NotEmptyStr, scores: List[PriorityScore]): |
| 2912 | + """Returns per frame annotations for the given video. |
| 2913 | +
|
| 2914 | + :param project: project name or folder path (e.g., “project1/folder1”) |
| 2915 | + :type project: str |
| 2916 | +
|
| 2917 | + :param scores: list of score objects |
| 2918 | + :type scores: list of dicts |
| 2919 | +
|
| 2920 | + :return: lists of uploaded, skipped items |
| 2921 | + :rtype: tuple (2 members) of lists of strs |
| 2922 | + """ |
| 2923 | + project_name, folder_name = extract_project_folder(project) |
| 2924 | + project_folder_name = project |
| 2925 | + response = Controller.get_default().upload_priority_scores(project_name, folder_name, scores, project_folder_name) |
| 2926 | + if response.errors: |
| 2927 | + raise AppException(response.errors) |
| 2928 | + return response.data |
| 2929 | + |
| 2930 | + |
| 2931 | +@Trackable |
| 2932 | +@validate_arguments |
| 2933 | +def get_integrations(): |
| 2934 | + """Get all integrations per team |
| 2935 | +
|
| 2936 | + :return: metadata objects of all integrations of the team. |
| 2937 | + :rtype: list of dicts |
| 2938 | + """ |
| 2939 | + response = Controller.get_default().get_integrations() |
| 2940 | + if response.errors: |
| 2941 | + raise AppException(response.errors) |
| 2942 | + integrations = response.data |
| 2943 | + return BaseSerializers.serialize_iterable(integrations, ("name", "type", "root")) |
| 2944 | + |
| 2945 | + |
| 2946 | +@Trackable |
| 2947 | +@validate_arguments |
| 2948 | +def attach_items_from_integrated_storage( |
| 2949 | + project: NotEmptyStr, |
| 2950 | + integration: Union[NotEmptyStr, IntegrationEntity], |
| 2951 | + folder_path: Optional[NotEmptyStr] = None |
| 2952 | +): |
| 2953 | + """Link images from integrated external storage to SuperAnnotate. |
| 2954 | +
|
| 2955 | + :param project: project name or folder path where items should be attached (e.g., “project1/folder1”). |
| 2956 | + :type project: str |
| 2957 | +
|
| 2958 | + :param project: project name or folder path where items should be attached (e.g., “project1/folder1”). |
| 2959 | + :type project: str |
| 2960 | +
|
| 2961 | + :param integration: existing integration name or metadata dict to pull items from. |
| 2962 | + Mandatory keys in integration metadata’s dict is “name”. |
| 2963 | + :type integration: str or dict |
| 2964 | +
|
| 2965 | + :param folder_path: Points to an exact folder/directory within given storage. |
| 2966 | + If None, items are fetched from the root directory. |
| 2967 | + :type folder_path: str |
| 2968 | + """ |
| 2969 | + project_name, folder_name = extract_project_folder(project) |
| 2970 | + if isinstance(integration, str): |
| 2971 | + integration = IntegrationEntity(name=integration) |
| 2972 | + response = Controller.get_default().attach_integrations(project_name, folder_name, integration, folder_path) |
| 2973 | + if response.errors: |
| 2974 | + raise AppException(response.errors) |
0 commit comments