diff --git a/README.md b/README.md index 58ac262..91832bc 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,11 @@ - [PCD](#pcd) - [Sequential PCD](#sequential-pcd) - [DICOM](#dicom) + - [Robotics](#robotics) - [Common](#common) - [Appendix](#appendix) - [Annotation](#annotation) +- [Metadata](#metadata) - [Project](#project) - [Dataset](#dataset) - [Converter](#converter) @@ -98,7 +100,7 @@ task_id = client.create_image_task( ) ``` -Create a new task with pre-defined annotations. (Class should be configured on your project in advance) +Create a new task with pre-defined annotations and metadatas. (Class and metadata should be configured on your project in advance) ```python task_id = client.create_image_task( @@ -121,7 +123,13 @@ task_id = client.create_image_task( 200, # bottom-right x 200 # bottom-right y ] - }] + }], + metadatas=[ # (optional) pre-defined metadata key-value pairs + { + "key": "metadata_key", + "value": "metadata_value" + } + ] ) ``` @@ -144,10 +152,10 @@ task_id = client.create_integrated_image_task( ) ``` -Create a new task with pre-defined annotations. (Class should be configured on your project in advance) +Create a new task with pre-defined annotations and metadatas. (Class and metadata should be configured on your project in advance) ```python -task_id = client.create_image_task( +task_id = client.create_integrated_image_task( project="YOUR_PROJECT_SLUG", file_path="/sample.jpg", storage_type="gcp", @@ -166,7 +174,13 @@ task_id = client.create_image_task( 200, # bottom-right x 200 # bottom-right y ] - }] + }], + metadatas=[ # (optional) pre-defined metadata key-value pairs + { + "key": "metadata_key", + "value": "some_value" + } + ] ) ``` @@ -264,6 +278,12 @@ task_id = client.update_image_task( "startIndex": 2, "endIndex": 0 } + ], + metadatas=[ # (optional) metadata key-value pairs (metadata should be configured on your project in advance) + { + "key": "metadata_key", + "value": "metadata_value" + } ] ) ``` @@ -734,7 +754,13 @@ task = client.create_sequential_image_task( 100, 100 ]]] # clockwise rotation - }] + }], + metadatas=[ # (optional) pre-defined metadata key-value pairs + { + "key": "metadata_key", + "value": "some_value" + } + ] ) ``` @@ -787,6 +813,12 @@ task_id = client.update_sequential_image_task( ], "points": [990, 560, 980, 550] } + ], + metadatas=[ # (optional) metadata key-value pairs + { + "key": "metadata_key", + "value": "metadata_value" + } ] ) ``` @@ -862,7 +894,7 @@ task_id = client.create_video_task( ) ``` -Create a new task with pre-defined annotations. (Class should be configured on your project in advance) +Create a new task with pre-defined annotations and metadatas. (Class and metadata should be configured on your project in advance) ```python task_id = client.create_video_task( @@ -904,7 +936,13 @@ task_id = client.create_video_task( "autogenerated": False } } - }] + }], + metadatas=[ # (optional) pre-defined metadata key-value pairs + { + "key": "metadata_key", + "value": "metadata_value" + } + ] ) ``` @@ -979,7 +1017,13 @@ task_id = client.update_video_task( "autogenerated": False } } - }] + }], + metadatas=[ # (optional) metadata key-value pairs + { + "key": "metadata_key", + "value": "metadata_value" + } + ] ) ``` @@ -1164,7 +1208,7 @@ task_id = client.create_text_task( ) ``` -Create a new task with pre-defined annotations. (Class should be configured on your project in advance) +Create a new task with pre-defined annotations and metadatas. (Class and metadata should be configured on your project in advance) ```python task_id = client.create_text_task( @@ -1178,7 +1222,13 @@ task_id = client.create_text_task( "start": 0, "end": 10, "text": "1234567890" - }] + }], + metadatas=[ # (optional) pre-defined metadata key-value pairs + { + "key": "metadata_key", + "value": "metadata_value" + } + ] ) ``` @@ -1225,7 +1275,13 @@ task_id = client.update_text_task( "start": 0, "end": 10, "text": "0123456789" - }] + }], + metadatas=[ # (optional) metadata key-value pairs + { + "key": "metadata_key", + "value": "metadata_value" + } + ] ) ``` @@ -1352,7 +1408,7 @@ task_id = client.create_audio_task( ) ``` -Create a new task with pre-defined annotations. (Class should be configured on your project in advance) +Create a new task with pre-defined annotations and metadatas. (Class and metadata should be configured on your project in advance) ```python task_id = client.create_audio_task( @@ -1365,7 +1421,13 @@ task_id = client.create_audio_task( "value": "person", "start": 0.4, "end": 0.5 - }] + }], + metadatas=[ # (optional) pre-defined metadata key-value pairs + { + "key": "metadata_key", + "value": "metadata_value" + } + ] ) ``` @@ -1411,7 +1473,13 @@ task_id = client.update_audio_task( "value": "bird", "start": 0.4, "end": 0.5 - }] + }], + metadatas=[ # (optional) metadata key-value pairs + { + "key": "metadata_key", + "value": "metadata_value" + } + ] ) ``` @@ -1588,7 +1656,7 @@ task_id = client.create_pcd_task( ) ``` -Create a new task with pre-defined annotations. (Class should be configured on your project in advance) +Create a new task with pre-defined annotations and metadatas. (Class and metadata should be configured on your project in advance) Annotation Type: cuboid @@ -1615,6 +1683,12 @@ task_id = client.create_pcd_task( ], } ], + metadatas=[ # (optional) pre-defined metadata key-value pairs + { + "key": "metadata_key", + "value": "metadata_value" + } + ] ) ``` @@ -1690,6 +1764,12 @@ task_id = client.update_pcd_task( ], } ], + metadatas=[ # (optional) metadata key-value pairs + { + "key": "metadata_key", + "value": "metadata_value" + } + ] ) ``` @@ -1815,6 +1895,12 @@ task_id = client.create_sequential_pcd_task( }, }, }, + ], + metadatas=[ # (optional) pre-defined metadata key-value pairs + { + "key": "metadata_key", + "value": "some_value" + } ] ) ``` @@ -1891,6 +1977,12 @@ task_id = client.update_sequential_pcd_task( }, }, }, + ], + metadatas=[ # (optional) metadata key-value pairs + { + "key": "metadata_key", + "value": "metadata_value" + } ] ) ``` @@ -1987,7 +2079,13 @@ Once you receive the status completed, you can get the task. ```python history = client.create_dicom_task( project="YOUR_PROJECT_SLUG", - file_path="./sample.zip" + file_path="./sample.zip", + metadatas=[ # (optional) pre-defined metadata key-value pairs + { + "key": "metadata_key", + "value": "some_value" + } + ] ) ``` @@ -2026,7 +2124,13 @@ task_id = client.update_dicom_task( task_id="YOUR_TASK_ID", status="approved", assignee="USER_SLUG", - tags=["tag1", "tag2"] + tags=["tag1", "tag2"], + metadatas=[ # (optional) metadata key-value pairs + { + "key": "metadata_key", + "value": "metadata_value" + } + ] ) ``` @@ -2064,6 +2168,40 @@ Example of a single dicom task object } ``` +### Robotics + +Supported following project types: + +- Robotics - Task Classification + +#### Create Tasks + +Create a new task (Content creation is required separately). + +```python +task_id = client.create_robotics_task( + project="YOUR_PROJECT_SLUG", + name="TASK_NAME", + metadatas=[ # (optional) pre-defined metadata key-value pairs + { + "key": "metadata_key", + "value": "some_value" + } + ] +) +``` + +#### Import Contents + +Import contents zip file + +```python +history = client.import_robotics_contents_file( + project="YOUR_PROJECT_SLUG", + file_path="ZIP_FILE_PATH", +) +``` + ### Common APIs for update and delete and count are same over all tasks. @@ -2104,6 +2242,31 @@ client.delete_task_annotations(task_id="YOUR_TASK_ID") id_name_map = client.get_task_id_name_map(project="YOUR_PROJECT_SLUG") ``` +#### Get Task Appendix Data + +Get appendix data (URLs and parameters) for tasks. + +```python +appendix_data = client.get_task_appendix_data(project="YOUR_PROJECT_SLUG") +``` + +Filter by task name: + +```python +appendix_data = client.get_task_appendix_data( + project="YOUR_PROJECT_SLUG", + task_name="YOUR_TASK_NAME" +) +``` + +Response includes: + +- `id`: UUID of the appendix +- `url`: Image file URL +- `name`: Format is `{task_name}/{content_name}/{file_name}` +- `format`: `yml`, `kitti`, or `none` +- `calibration`: Calibration data + #### Count Task ```python @@ -2458,6 +2621,35 @@ Delete an annotation. client.delete_annotation(annotation_id="YOUR_ANNOTATION_ID") ``` +## Metadata + +### Get Metadatas + +Get metadatas. (Up to 1000 metadatas) + +```python +metadatas = client.get_metadatas(project="YOUR_PROJECT_SLUG") +``` + +### Response + +Example of a metadata object + +```python +{ + "id": "YOUR_METADATA_ID", + "key": "YOUR_METADATA_KEY", + "type": "text", + "options": [], + "defaultValue": "", + "order": 1, + "isAdmin": True, + "isRequired": False, + "createdAt": "2021-04-20T03:20:41.427Z", + "updatedAt": "2021-04-20T03:20:41.427Z", +} +``` + ## Project ### Create Project @@ -2568,8 +2760,9 @@ result = client.update_project_user_permission( ``` Available roles: + - `annotator`: Annotator -- `reviewer`: Reviewer +- `reviewer`: Reviewer - `owner`: Project owner - `none`: Remove user from project diff --git a/examples/get_metadatas.py b/examples/get_metadatas.py new file mode 100644 index 0000000..0e6e2dc --- /dev/null +++ b/examples/get_metadatas.py @@ -0,0 +1,8 @@ +from pprint import pprint + +import fastlabel + +client = fastlabel.Client() + +metadatas = client.get_metadatas(project="robotics-task-classification") +pprint(metadatas) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 5a79d51..97daed4 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -955,6 +955,7 @@ def create_image_task( priority: Priority = None, annotations: list = [], tags: list = [], + metadatas: list = [], is_delete_exif: bool = False, **kwargs, ) -> str: @@ -978,6 +979,8 @@ def create_image_task( 'sent_back', 'approved', 'declined', 'customer_declined' (Optional). annotations is a list of annotation to be set in advance (Optional). tags is a list of tag to be set in advance (Optional). + metadatas is a list of metadata key-value pairs to be set in advance (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] assignee is slug of assigned user (Optional). reviewer is slug of review user (Optional). approver is slug of approve user (Optional). @@ -1008,6 +1011,8 @@ def create_image_task( payload["annotations"] = delete_extra_annotations_parameter(annotations) if tags: payload["tags"] = tags + if metadatas: + payload["metadatas"] = metadatas if is_delete_exif: payload["isDeleteExif"] = is_delete_exif if custom_task_status: @@ -1026,6 +1031,7 @@ def create_integrated_image_task( external_status: str = None, annotations: list = None, tags: list = None, + metadatas: list = [], **kwargs, ) -> str: """ @@ -1040,6 +1046,8 @@ def create_integrated_image_task( 'sent_back', 'approved', 'declined', 'customer_declined' (Optional). annotations is a list of annotation to be set in advance (Optional). tags is a list of tag to be set in advance (Optional). + metadatas is a list of metadata key-value pairs to be set in advance (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] assignee is slug of assigned user (Optional). reviewer is slug of review user (Optional). approver is slug of approve user (Optional). @@ -1068,6 +1076,8 @@ def create_integrated_image_task( payload["annotations"] = delete_extra_annotations_parameter(annotations) if tags: payload["tags"] = tags + if metadatas: + payload["metadatas"] = metadatas self.__fill_assign_users(payload, **kwargs) @@ -1299,6 +1309,7 @@ def create_sequential_image_task( priority: Priority = None, annotations: list = [], tags: list = [], + metadatas: list = [], is_delete_exif: bool = False, **kwargs, ) -> str: @@ -1322,6 +1333,8 @@ def create_sequential_image_task( 'sent_back', 'approved', 'declined', 'customer_declined' (Optional). annotations is a list of annotation to be set in advance (Optional). tags is a list of tag to be set in advance (Optional). + metadatas is a list of metadata key-value pairs to be set in advance (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] assignee is slug of assigned user (Optional). reviewer is slug of review user (Optional). approver is slug of approve user (Optional). @@ -1375,6 +1388,8 @@ def create_sequential_image_task( payload["annotations"] = delete_extra_annotations_parameter(annotations) if tags: payload["tags"] = tags + if metadatas: + payload["metadatas"] = metadatas if is_delete_exif: payload["isDeleteExif"] = is_delete_exif @@ -1392,6 +1407,7 @@ def create_video_task( priority: Priority = None, annotations: list = [], tags: list = [], + metadatas: list = [], **kwargs, ) -> str: """ @@ -1412,6 +1428,8 @@ def create_video_task( 'sent_back', 'approved', 'declined', 'customer_declined' (Optional). annotations is a list of annotation to be set in advance (Optional). tags is a list of tag to be set in advance (Optional). + metadatas is a list of metadata key-value pairs to be set in advance (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] assignee is slug of assigned user (Optional). reviewer is slug of review user (Optional). approver is slug of approve user (Optional). @@ -1446,6 +1464,8 @@ def create_video_task( payload["annotations"] = delete_extra_annotations_parameter(annotations) if tags: payload["tags"] = tags + if metadatas: + payload["metadatas"] = metadatas self.__fill_assign_users(payload, **kwargs) @@ -1528,6 +1548,7 @@ def create_text_task( priority: Priority = None, annotations: list = [], tags: list = [], + metadatas: list = [], **kwargs, ) -> str: """ @@ -1548,6 +1569,8 @@ def create_text_task( 'sent_back', 'approved', 'declined', 'customer_declined' (Optional). annotations is a list of annotation to be set in advance (Optional). tags is a list of tag to be set in advance (Optional). + metadatas is a list of metadata key-value pairs to be set in advance (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] assignee is slug of assigned user (Optional). reviewer is slug of review user (Optional). approver is slug of approve user (Optional). @@ -1575,6 +1598,8 @@ def create_text_task( payload["annotations"] = delete_extra_annotations_parameter(annotations) if tags: payload["tags"] = tags + if metadatas: + payload["metadatas"] = metadatas self.__fill_assign_users(payload, **kwargs) @@ -1650,6 +1675,7 @@ def create_audio_task( priority: Priority = None, annotations: list = [], tags: list = [], + metadatas: list = [], **kwargs, ) -> str: """ @@ -1670,6 +1696,8 @@ def create_audio_task( 'sent_back', 'approved', 'declined', 'customer_declined' (Optional). annotations is a list of annotation to be set in advance (Optional). tags is a list of tag to be set in advance (Optional). + metadatas is a list of metadata key-value pairs to be set in advance (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] assignee is slug of assigned user (Optional). reviewer is slug of review user (Optional). approver is slug of approve user (Optional). @@ -1701,6 +1729,8 @@ def create_audio_task( payload["annotations"] = delete_extra_annotations_parameter(annotations) if tags: payload["tags"] = tags + if metadatas: + payload["metadatas"] = metadatas self.__fill_assign_users(payload, **kwargs) @@ -1777,6 +1807,7 @@ def create_dicom_task( status: str = None, external_status: str = None, tags: list = [], + metadatas: list = [], **kwargs, ) -> str: """ @@ -1790,6 +1821,8 @@ def create_dicom_task( external_status can be 'registered', 'completed', 'skipped', 'reviewed', 'sent_back', 'approved', 'declined', 'customer_declined' (Optional). tags is a list of tag to be set in advance (Optional). + metadatas is a list of metadata key-value pairs to be set in advance (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] assignee is slug of assigned user (Optional). reviewer is slug of review user (Optional). approver is slug of approve user (Optional). @@ -1810,6 +1843,8 @@ def create_dicom_task( payload["externalStatus"] = external_status if tags: payload["tags"] = tags + if metadatas: + payload["metadatas"] = metadatas self.__fill_assign_users(payload, **kwargs) @@ -1833,6 +1868,7 @@ def create_pcd_task( priority: Priority = None, annotations: list = [], tags: list = [], + metadatas: list = [], **kwargs, ) -> str: """ @@ -1853,6 +1889,8 @@ def create_pcd_task( 'sent_back', 'approved', 'declined', 'customer_declined' (Optional). annotations is a list of annotation to be set in advance (Optional). tags is a list of tag to be set in advance (Optional). + metadatas is a list of metadata key-value pairs to be set in advance (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] assignee is slug of assigned user (Optional). reviewer is slug of review user (Optional). approver is slug of approve user (Optional). @@ -1880,6 +1918,8 @@ def create_pcd_task( payload["annotations"] = delete_extra_annotations_parameter(annotations) if tags: payload["tags"] = tags + if metadatas: + payload["metadatas"] = metadatas self.__fill_assign_users(payload, **kwargs) @@ -1895,6 +1935,7 @@ def create_sequential_pcd_task( priority: Priority = None, annotations: list = [], tags: list = [], + metadatas: list = [], **kwargs, ) -> str: """ @@ -1917,6 +1958,8 @@ def create_sequential_pcd_task( 'sent_back', 'approved', 'declined', 'customer_declined' (Optional). annotations is a list of annotation to be set in advance (Optional). tags is a list of tag to be set in advance (Optional). + metadatas is a list of metadata key-value pairs to be set in advance (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] assignee is slug of assigned user (Optional). reviewer is slug of review user (Optional). approver is slug of approve user (Optional). @@ -1970,6 +2013,60 @@ def create_sequential_pcd_task( payload["annotations"] = delete_extra_annotations_parameter(annotations) if tags: payload["tags"] = tags + if metadatas: + payload["metadatas"] = metadatas + + self.__fill_assign_users(payload, **kwargs) + + return self.api.post_request(endpoint, payload=payload) + + def create_robotics_task( + self, + project: str, + name: str, + status: Optional[str] = None, + external_status: Optional[str] = None, + priority: Optional[Priority] = None, + tags: Optional[list[str]] = None, + metadatas: Optional[list] = None, + **kwargs, + ) -> str: + """ + Create a single robotics task without content. + + project is slug of your project (Required). + name is an unique identifier of task in your project (Required). + status can be 'registered', 'completed', 'skipped', 'reviewed', 'sent_back', 'approved', 'declined' (Optional). + external_status can be 'registered', 'completed', 'skipped', 'reviewed', 'sent_back', 'approved', 'declined', 'customer_declined' (Optional). + priority is the priority of the task (default: none) (Optional). + Set one of the numbers corresponding to: + none = 0, + low = 10, + medium = 20, + high = 30, + tags is a list of tag to be set in advance (Optional). + metadatas is a list of metadata key-value pairs to be set in advance (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] + assignee is slug of assigned user (Optional). + reviewer is slug of review user (Optional). + approver is slug of approve user (Optional). + external_assignee is slug of external assigned user (Optional). + external_reviewer is slug of external review user (Optional). + external_approver is slug of external approve user (Optional). + """ + endpoint = "tasks/robotics" + + payload = {"project": project, "name": name} + if status: + payload["status"] = status + if external_status: + payload["externalStatus"] = external_status + if priority is not None: + payload["priority"] = priority + if tags: + payload["tags"] = tags or [] + if metadatas: + payload["metadatas"] = metadatas self.__fill_assign_users(payload, **kwargs) @@ -2053,6 +2150,69 @@ def get_appendix_data( return self.api.get_request(endpoint, params=params) + def get_task_appendix_data( + self, + project: str, + task_name: Optional[str] = None, + offset: Optional[int] = None, + limit: int = 10000, + ) -> list: + """ + Returns a list of appendixes urls and params. + params = { + id: uuid, + url: image file url, + name: {task_name}/{content_name}/{file_name}, + format: yml or kitti or none, + calibration: calibration data, + } + + project is slug of your project (Required). + task_name is a task name (Optional). + offset is the starting position number to fetch (Optional). + limit is the max number to fetch (Optional). + """ + if limit > 10000: + raise FastLabelInvalidException( + "Limit must be less than or equal to 10000.", 422 + ) + endpoint = "tasks/appendix" + params = {"project": project} + if task_name: + params["taskName"] = task_name + if offset: + params["offset"] = offset + if limit: + params["limit"] = limit + + return self.api.get_request(endpoint, params=params) + + def import_robotics_contents_file( + self, + project: str, + file_path: str, + ) -> list: + """ + Import robotics contents file zip. + project is slug of your project (Required). + file_path is a path to data. Supported extensions are zip (Required). + """ + + if not utils.is_robotics_contents_supported_ext(file_path): + raise FastLabelInvalidException("Supported extensions are zip.", 422) + + endpoint = "contents/imports/robotics-contents/batch" + payload = {"project": project} + signed_url = self.__get_signed_path( + project=project, + file_name=os.path.basename(file_path), + file_type="application/zip", + ) + self.api.upload_zipfile(url=signed_url["url"], file_path=file_path) + payload["fileKey"] = signed_url["name"] + + return self.api.post_request(endpoint, payload=payload) + # Task Update def update_task( @@ -2062,6 +2222,7 @@ def update_task( external_status: str = None, priority: Priority = None, tags: list = [], + metadatas: list = [], **kwargs, ) -> str: """ @@ -2079,6 +2240,8 @@ def update_task( high = 30, 'sent_back', 'approved', 'declined', 'customer_declined'. (Optional) tags is a list of tag to be set (Optional). + metadatas is a list of metadata key-value pairs to be set (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] assignee is slug of assigned user (Optional). reviewer is slug of review user (Optional). approver is slug of approve user (Optional). @@ -2096,6 +2259,8 @@ def update_task( payload["priority"] = priority if tags: payload["tags"] = tags + if metadatas: + payload["metadatas"] = metadatas self.__fill_assign_users(payload, **kwargs) @@ -2111,6 +2276,7 @@ def update_image_task( tags: list = [], annotations: List[dict] = [], relations: Optional[List[dict]] = None, + metadatas: list = [], **kwargs, ) -> str: """ @@ -2132,6 +2298,8 @@ def update_image_task( tags is a list of tag to be set (Optional). annotations is a list of annotation to be set (Optional). relations is a list of annotation relations to be set (Optional). + metadatas is a list of metadata key-value pairs to be set (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] assignee is slug of assigned user (Optional). reviewer is slug of review user (Optional). approver is slug of approve user (Optional). @@ -2160,6 +2328,8 @@ def update_image_task( payload["relations"] = relations if custom_task_status: payload["customTaskStatus"] = custom_task_status + if metadatas: + payload["metadatas"] = metadatas self.__fill_assign_users(payload, **kwargs) @@ -2273,6 +2443,7 @@ def update_sequential_image_task( priority: Priority = None, tags: list = [], annotations: List[dict] = [], + metadatas: list = [], **kwargs, ) -> str: """ @@ -2291,6 +2462,8 @@ def update_sequential_image_task( 'sent_back', 'approved', 'declined', 'customer_declined'. (Optional) tags is a list of tag to be set (Optional). annotations is a list of annotation to be set (Optional). + metadatas is a list of metadata key-value pairs to be set (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] assignee is slug of assigned user (Optional). reviewer is slug of review user (Optional). approver is slug of approve user (Optional). @@ -2310,6 +2483,8 @@ def update_sequential_image_task( payload["tags"] = tags if annotations: payload["annotations"] = delete_extra_annotations_parameter(annotations) + if metadatas: + payload["metadatas"] = metadatas self.__fill_assign_users(payload, **kwargs) @@ -2323,6 +2498,7 @@ def update_video_task( priority: Priority = None, tags: list = [], annotations: List[dict] = [], + metadatas: list = [], **kwargs, ) -> str: """ @@ -2341,6 +2517,8 @@ def update_video_task( 'sent_back', 'approved', 'declined', 'customer_declined' (Optional). tags is a list of tag to be set (Optional). annotations is a list of annotation to be set (Optional). + metadatas is a list of metadata key-value pairs to be set (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] assignee is slug of assigned user (Optional). reviewer is slug of review user (Optional). approver is slug of approve user (Optional). @@ -2362,6 +2540,8 @@ def update_video_task( for annotation in annotations: annotation["content"] = "" payload["annotations"] = delete_extra_annotations_parameter(annotations) + if metadatas: + payload["metadatas"] = metadatas self.__fill_assign_users(payload, **kwargs) @@ -2425,6 +2605,7 @@ def update_text_task( priority: Priority = None, tags: list = [], annotations: List[dict] = [], + metadatas: list = [], **kwargs, ) -> str: """ @@ -2443,6 +2624,8 @@ def update_text_task( 'sent_back', 'approved', 'declined', 'customer_declined' (Optional). tags is a list of tag to be set (Optional). annotations is a list of annotation to be set (Optional). + metadatas is a list of metadata key-value pairs to be set (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] assignee is slug of assigned user (Optional). reviewer is slug of review user (Optional). approver is slug of approve user (Optional). @@ -2464,6 +2647,8 @@ def update_text_task( for annotation in annotations: annotation["content"] = "" payload["annotations"] = delete_extra_annotations_parameter(annotations) + if metadatas: + payload["metadatas"] = metadatas self.__fill_assign_users(payload, **kwargs) @@ -2527,6 +2712,7 @@ def update_audio_task( priority: Priority = None, tags: list = [], annotations: List[dict] = [], + metadatas: list = [], **kwargs, ) -> str: """ @@ -2545,6 +2731,8 @@ def update_audio_task( 'sent_back', 'approved', 'declined', 'customer_declined' (Optional). tags is a list of tag to be set (Optional). annotations is a list of annotation to be set (Optional). + metadatas is a list of metadata key-value pairs to be set (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] assignee is slug of assigned user (Optional). reviewer is slug of review user (Optional). approver is slug of approve user (Optional). @@ -2566,6 +2754,8 @@ def update_audio_task( for annotation in annotations: annotation["content"] = "" payload["annotations"] = delete_extra_annotations_parameter(annotations) + if metadatas: + payload["metadatas"] = metadatas self.__fill_assign_users(payload, **kwargs) @@ -2629,6 +2819,7 @@ def update_pcd_task( priority: Priority = None, tags: list = [], annotations: List[dict] = [], + metadatas: list = [], **kwargs, ) -> str: """ @@ -2647,6 +2838,8 @@ def update_pcd_task( 'sent_back', 'approved', 'declined', 'customer_declined'. (Optional) tags is a list of tag to be set (Optional). annotations is a list of annotation to be set (Optional). + metadatas is a list of metadata key-value pairs to be set (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] assignee is slug of assigned user (Optional). reviewer is slug of review user (Optional). approver is slug of approve user (Optional). @@ -2670,6 +2863,8 @@ def update_pcd_task( # the content will be filled on the server side. annotation["content"] = "" payload["annotations"] = delete_extra_annotations_parameter(annotations) + if metadatas: + payload["metadatas"] = metadatas self.__fill_assign_users(payload, **kwargs) @@ -2683,6 +2878,7 @@ def update_sequential_pcd_task( priority: Priority = None, tags: list = [], annotations: List[dict] = [], + metadatas: list = [], **kwargs, ) -> str: """ @@ -2701,6 +2897,8 @@ def update_sequential_pcd_task( 'sent_back', 'approved', 'declined', 'customer_declined'. (Optional) tags is a list of tag to be set (Optional). annotations is a list of annotation to be set (Optional). + metadatas is a list of metadata key-value pairs to be set (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] assignee is slug of assigned user (Optional). reviewer is slug of review user (Optional). approver is slug of approve user (Optional). @@ -2724,6 +2922,8 @@ def update_sequential_pcd_task( # the content will be filled on the server side. annotation["content"] = "" payload["annotations"] = delete_extra_annotations_parameter(annotations) + if metadatas: + payload["metadatas"] = metadatas self.__fill_assign_users(payload, **kwargs) @@ -3907,6 +4107,35 @@ def delete_annotation(self, annotation_id: str) -> None: endpoint = "annotations/" + annotation_id self.api.delete_request(endpoint) + # Metadata + + def get_metadatas( + self, + project: str = None, + offset: int = None, + limit: int = 100, + ) -> list: + """ + Returns a list of metadatas. + Returns up to 1000 at a time, to get more, set offset as the starting position + to fetch. + + project is slug of your project (Required). + offset is the starting position number to fetch (Optional). + limit is the max number to fetch (Optional). + """ + if limit > 1000: + raise FastLabelInvalidException( + "Limit must be less than or equal to 1000.", 422 + ) + endpoint = "metadatas" + params = {"project": project} + if offset: + params["offset"] = offset + if limit: + params["limit"] = limit + return self.api.get_request(endpoint, params=params) + # Project def find_project(self, project_id: str) -> dict: @@ -3933,6 +4162,7 @@ def update_dicom_task( status: str = None, external_status: str = None, tags: list = [], + metadatas: list = [], **kwargs, ) -> str: """ @@ -3944,6 +4174,8 @@ def update_dicom_task( external_status can be 'registered', 'completed', 'skipped', 'reviewed', 'sent_back', 'approved', 'declined', 'customer_declined'. (Optional) tags is a list of tag to be set (Optional). + metadatas is a list of metadata key-value pairs to be set (Optional). + e.g.) [{"key": "metadata_key", "value": "some_value"}] assignee is slug of assigned user (Optional). reviewer is slug of review user (Optional). approver is slug of approve user (Optional). @@ -3959,6 +4191,8 @@ def update_dicom_task( payload["externalStatus"] = external_status if tags: payload["tags"] = tags + if metadatas: + payload["metadatas"] = metadatas self.__fill_assign_users(payload, **kwargs) diff --git a/fastlabel/utils/__init__.py b/fastlabel/utils/__init__.py index 3b90d73..ae435ae 100644 --- a/fastlabel/utils/__init__.py +++ b/fastlabel/utils/__init__.py @@ -46,6 +46,10 @@ def is_appendix_supported_ext(file_path: str) -> bool: return file_path.lower().endswith((".zip")) +def is_robotics_contents_supported_ext(file_path: str) -> bool: + return file_path.lower().endswith((".zip")) + + def is_pcd_supported_ext(file_path: str) -> bool: # .ply is not yet supported. To support it, modification of the API # needs to be considered as well.