|
2 | 2 | import copy |
3 | 3 | import io |
4 | 4 | import json |
| 5 | +import logging |
5 | 6 | import os |
6 | 7 | import sys |
7 | 8 | import warnings |
|
63 | 64 | from lib.core.types import Project |
64 | 65 | from lib.infrastructure.utils import extract_project_folder |
65 | 66 | from lib.infrastructure.validators import wrap_error |
66 | | -import logging |
| 67 | + |
67 | 68 |
|
68 | 69 | logger = logging.getLogger("sa") |
69 | 70 |
|
70 | 71 |
|
71 | 72 | NotEmptyStr = TypeVar("NotEmptyStr", bound=constr(strict=True, min_length=1)) |
72 | 73 |
|
73 | 74 |
|
74 | | -PROJECT_STATUS = Literal["Undefined", "NotStarted", "InProgress", "Completed", "OnHold"] |
| 75 | +PROJECT_STATUS = Literal["NotStarted", "InProgress", "Completed", "OnHold"] |
75 | 76 |
|
76 | 77 | PROJECT_TYPE = Literal[ |
77 | 78 | "Vector", "Pixel", "Video", "Document", "Tiled", "Other", "PointCloud" |
|
91 | 92 |
|
92 | 93 | ANNOTATOR_ROLE = Literal["Admin", "Annotator", "QA"] |
93 | 94 |
|
94 | | -FOLDER_STATUS = Literal[ |
95 | | - "Undefined", |
96 | | - "NotStarted", |
97 | | - "InProgress", |
98 | | - "Completed", |
99 | | - "OnHold", |
100 | | -] |
| 95 | +FOLDER_STATUS = Literal["NotStarted", "InProgress", "Completed", "OnHold"] |
101 | 96 |
|
102 | 97 |
|
103 | 98 | class Setting(TypedDict): |
@@ -782,6 +777,52 @@ def search_annotation_classes( |
782 | 777 | for i in response.data |
783 | 778 | ] |
784 | 779 |
|
| 780 | + def set_project_status(self, project: NotEmptyStr, status: PROJECT_STATUS): |
| 781 | + """Set project status |
| 782 | +
|
| 783 | + :param project: project name |
| 784 | + :type project: str |
| 785 | + :param status: status to set, should be one of. \n |
| 786 | + ♦ “NotStarted” \n |
| 787 | + ♦ “InProgress” \n |
| 788 | + ♦ “Completed” \n |
| 789 | + ♦ “OnHold” \n |
| 790 | + :type status: str |
| 791 | + """ |
| 792 | + project = self.controller.get_project(name=project) |
| 793 | + project.status = constants.ProjectStatus.get_value(status) |
| 794 | + response = self.controller.projects.update(project) |
| 795 | + if response.errors: |
| 796 | + raise AppException(f"Failed to change {project.name} status.") |
| 797 | + logger.info(f"Successfully updated {project.name} status to {status}") |
| 798 | + |
| 799 | + def set_folder_status( |
| 800 | + self, project: NotEmptyStr, folder: NotEmptyStr, status: FOLDER_STATUS |
| 801 | + ): |
| 802 | + """Set folder status |
| 803 | +
|
| 804 | + :param project: project name |
| 805 | + :type project: str |
| 806 | + :param folder: folder name |
| 807 | + :type folder: str |
| 808 | + :param status: status to set, should be one of. \n |
| 809 | + ♦ “NotStarted” \n |
| 810 | + ♦ “InProgress” \n |
| 811 | + ♦ “Completed” \n |
| 812 | + ♦ “OnHold” \n |
| 813 | + :type status: str |
| 814 | + """ |
| 815 | + project, folder = self.controller.get_project_folder( |
| 816 | + project_name=project, folder_name=folder |
| 817 | + ) |
| 818 | + folder.status = constants.FolderStatus.get_value(status) |
| 819 | + response = self.controller.update(project, folder) |
| 820 | + if response.errors: |
| 821 | + raise AppException(f"Failed to change {project.name}/{folder.name} status.") |
| 822 | + logger.info( |
| 823 | + f"Successfully updated {project.name}/{folder.name} status to {status}" |
| 824 | + ) |
| 825 | + |
785 | 826 | def set_project_default_image_quality_in_editor( |
786 | 827 | self, |
787 | 828 | project: Union[NotEmptyStr, dict], |
@@ -1360,7 +1401,8 @@ def create_annotation_class( |
1360 | 1401 | :type color: str |
1361 | 1402 |
|
1362 | 1403 | :param attribute_groups: list of attribute group dicts. |
1363 | | - The values for the "group_type" key are "radio"|"checklist"|"text"|"numeric". |
| 1404 | + The values for the "group_type" key are "radio"|"checklist"|"text"|"numeric"|"ocr". |
| 1405 | + "ocr "group_type" key is only available for Vector projects. |
1364 | 1406 | Mandatory keys for each attribute group are |
1365 | 1407 |
|
1366 | 1408 | - "name" |
@@ -2340,7 +2382,7 @@ def query( |
2340 | 2382 | subset: Optional[NotEmptyStr] = None, |
2341 | 2383 | ): |
2342 | 2384 | """Return items that satisfy the given query. |
2343 | | - Query syntax should be in SuperAnnotate query language(https://doc.superannotate.com/docs/query-search-1). |
| 2385 | + Query syntax should be in SuperAnnotate query language(https://doc.superannotate.com/docs/explore-overview). |
2344 | 2386 |
|
2345 | 2387 | :param project: project name or folder path (e.g., “project1/folder1”) |
2346 | 2388 | :type project: str |
|
0 commit comments