Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2230,6 +2230,20 @@ history = client.import_robotics_contents_file(
)
```

#### Import mcap

Import an mcap zip file into an existing robotics task.

This method starts an import pipeline, uploads the zip file via a signed URL, and triggers the batch import.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

大した事項ではないんですが、このAPIを使うユーザーにとってimport pipelinesigned URLの存在って重要でしょうか?
ユーザーが意識することではないのであれば、そこは省いても良いかなと(むしろ書いてあるとそのURL使ってなんかやる必要あるんだっけ?となってしまいそう)思います。

むしろ、この処理が同期なのか非同期なのかを明記した方が良いかなと思います。triggers the batch importで察することはできるかもしれませんが、そのbatch importを待って result が返ってくるのかどうかは分からないので。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yo-tak
readme の文言を修正しました!


```python
result = client.import_robotics_mcap(
project="YOUR_PROJECT_SLUG",
task_id="YOUR_TASK_ID",
file_path="ZIP_FILE_PATH", # Supported extension is .zip
)
```

#### Import LeRobot Dataset

Import a [LeRobot](https://github.com/huggingface/lerobot) dataset (v3) into a FastLabel robotics project.
Expand Down
19 changes: 19 additions & 0 deletions examples/import_robotics_mcap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
Import an mcap zip file into an existing FastLabel robotics task.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このファイルの説明文も d446c4d に合わせた内容に変更をお願いします!


This starts an import pipeline, uploads the zip via a signed URL,
and triggers the batch import.
"""

from pprint import pprint

import fastlabel

client = fastlabel.Client()

result = client.import_robotics_mcap(
project="YOUR_PROJECT_SLUG",
task_id="YOUR_TASK_ID",
file_path="ZIP_FILE_PATH", # Supported extension is .zip
)
pprint(result)
49 changes: 49 additions & 0 deletions fastlabel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2451,6 +2451,55 @@ def import_robotics_contents_file(

return self.api.post_request(endpoint, payload=payload)

def import_robotics_mcap(self, project: str, task_id: str, file_path: str) -> dict:
"""
Import robotics mcap zip file.
project is slug of your project (Required).
task_id is a id of the robotics task to import contents (Required).
file_path is a path to data. Supported extensions are zip (Required).
"""
if not file_path.endswith(".zip"):
raise FastLabelInvalidException(
"Supported extensions are zip (Required).", 422
)
history_id = self._start_pipeline(project=project, task_id=task_id)
self._upload_zip_with_signed_url(
history_id=history_id,
file_path=file_path,
)
return self._trigger_batch_import(history_id=history_id)

def _start_pipeline(
self,
project: str,
task_id: str,
) -> str:
history: dict = self.api.post_request(
"data-lake/robotics/import-pipeline/start",
payload={
"project": project,
"taskId": task_id,
},
)
logger.info(f"Started data lake pipeline with history ID: {history['id']}")
return history["id"]

def _upload_zip_with_signed_url(self, history_id: str, file_path: str) -> None:
signed_url_data = self.api.get_request(
"data-lake/robotics/import-pipeline/signed-url",
params={"historyId": history_id},
)
res = self.api.upload_zipfile(url=signed_url_data["url"], file_path=file_path)
res.raise_for_status()

def _trigger_batch_import(self, history_id: str) -> dict:
return self.api.post_request(
"data-lake/robotics/import-pipeline/run",
payload={
"historyId": history_id,
},
)

# Task Update

def update_task(
Expand Down
Loading