diff --git a/README.md b/README.md index 8a39f42..785ef11 100644 --- a/README.md +++ b/README.md @@ -2082,6 +2082,17 @@ task_id = client.create_robotics_task( ) ``` +#### 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. diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 97cc308..592e597 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -2100,6 +2100,32 @@ def get_appendix_data( 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( 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.