Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2915,6 +2915,7 @@ Example of a comment object
"id": "YOUR_COMMENT_ID",
"taskId": "YOUR_TASK_ID",
"contentId": "YOUR_CONTENT_ID",
"contentName": "01.jpg",
"type": "text",
"isResolved": False,
"points": [185.98, 86.55],
Expand Down Expand Up @@ -2970,6 +2971,7 @@ Example of a comment thread object
"id": "YOUR_COMMENT_ID",
"taskId": "YOUR_TASK_ID",
"contentId": "YOUR_CONTENT_ID",
"contentName": "01.jpg",
"type": "text",
"isResolved": False,
"points": [185.98, 86.55],
Expand Down Expand Up @@ -3001,14 +3003,29 @@ comment = client.create_task_comment(
)
```

For a task with multiple contents (e.g. sequential image), specify which frame
the comment belongs to with `content_name`. The name is the file name returned
as `contents[].name` by Get Tasks, and `contents` is not guaranteed to be
ordered, so match on the name rather than on the array index.

```python
comment = client.create_task_comment(
task_id="YOUR_TASK_ID",
content_name="01.jpg",
points=[185.98, 86.55],
text="comment on frame 01.jpg",
)
```

#### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| task_id | str | Yes | Task ID the comment belongs to (the task is resolved by task_id alone) |
| points | list | Yes | Comment position as a numeric array |
| text | str | Yes | Comment body text |
| content_id | str | No | Content ID. If omitted and the task has a single content it is auto-selected; required for multi-content tasks |
| content_name | str | No | Frame file name (`contents[].name` from Get Tasks). Use this to target a frame of a multi-content task such as sequential image. Mutually exclusive with `content_id` |
| content_id | str | No | Content ID. Mutually exclusive with `content_name`. If both are omitted and the task has a single content it is auto-selected; one of them is required for multi-content tasks |
| type | str | No | Comment type. Only `text` is supported (default: `text`) |
| scale | float | No | Canvas scale |
| frame | int | No | Frame index for sequential/video (1-indexed) |
Expand Down
12 changes: 12 additions & 0 deletions fastlabel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5545,6 +5545,7 @@ def create_task_comment(
task_id: str = None,
points: list = None,
text: str = None,
content_name: str = None,
content_id: str = None,
type: str = "text",
scale: float = 0,
Expand All @@ -5559,7 +5560,16 @@ def create_task_comment(
"""
Create a comment, or add a thread (message/reply) to an existing comment.
The author is recorded as "via API".

For a task with multiple contents (e.g. sequential image), specify the
frame with content_name, which is the file name returned as
contents[].name by get_tasks. content_id is also accepted, but the two
are mutually exclusive.
"""
if content_name is not None and content_id is not None:
raise FastLabelInvalidException(
"Specify either content_name or content_id, not both.", 422
)
if comment_id is not None:
return self.api.post_request(
"comments/" + comment_id + "/threads", payload={"text": text}
Expand All @@ -5574,6 +5584,8 @@ def create_task_comment(
"scale": scale,
"frame": frame,
}
if content_name is not None:
payload["contentName"] = content_name
if content_id is not None:
payload["contentId"] = content_id
if status is not None:
Expand Down