Skip to content

Commit b36583c

Browse files
authored
Merge pull request #253 from fastlabel/feature/10399-add-robotics-contents-import-for-sdk
SDKからロボティクスコンテンツをインポートできる
2 parents fd1a9c7 + 9980636 commit b36583c

3 files changed

Lines changed: 41 additions & 0 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,6 +2082,17 @@ task_id = client.create_robotics_task(
20822082
)
20832083
```
20842084

2085+
#### Import Contents
2086+
2087+
Import contents zip file
2088+
2089+
```python
2090+
history = client.import_robotics_contents_file(
2091+
project="YOUR_PROJECT_SLUG",
2092+
file_path="ZIP_FILE_PATH",
2093+
)
2094+
```
2095+
20852096
### Common
20862097

20872098
APIs for update and delete and count are same over all tasks.

fastlabel/__init__.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,6 +2100,32 @@ def get_appendix_data(
21002100

21012101
return self.api.get_request(endpoint, params=params)
21022102

2103+
def import_robotics_contents_file(
2104+
self,
2105+
project: str,
2106+
file_path: str,
2107+
) -> list:
2108+
"""
2109+
Import robotics contents file zip.
2110+
project is slug of your project (Required).
2111+
file_path is a path to data. Supported extensions are zip (Required).
2112+
"""
2113+
2114+
if not utils.is_robotics_contents_supported_ext(file_path):
2115+
raise FastLabelInvalidException("Supported extensions are zip.", 422)
2116+
2117+
endpoint = "contents/imports/robotics-contents/batch"
2118+
payload = {"project": project}
2119+
signed_url = self.__get_signed_path(
2120+
project=project,
2121+
file_name=os.path.basename(file_path),
2122+
file_type="application/zip",
2123+
)
2124+
self.api.upload_zipfile(url=signed_url["url"], file_path=file_path)
2125+
payload["fileKey"] = signed_url["name"]
2126+
2127+
return self.api.post_request(endpoint, payload=payload)
2128+
21032129
# Task Update
21042130

21052131
def update_task(

fastlabel/utils/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ def is_appendix_supported_ext(file_path: str) -> bool:
4646
return file_path.lower().endswith((".zip"))
4747

4848

49+
def is_robotics_contents_supported_ext(file_path: str) -> bool:
50+
return file_path.lower().endswith((".zip"))
51+
52+
4953
def is_pcd_supported_ext(file_path: str) -> bool:
5054
# .ply is not yet supported. To support it, modification of the API
5155
# needs to be considered as well.

0 commit comments

Comments
 (0)