Skip to content

Commit 9c1ed73

Browse files
committed
moving fn to be on attachment instead
1 parent e6a8388 commit 9c1ed73

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

labelbox/schema/asset_attachment.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from enum import Enum
22
from typing import Dict
33

4-
from labelbox.orm.db_object import DbObject
4+
from labelbox.orm.db_object import DbObject, Deletable
55
from labelbox.orm.model import Field
66

77

8-
class AssetAttachment(DbObject):
8+
class AssetAttachment(DbObject, Deletable):
99
""" Asset attachment provides extra context about an asset while labeling.
1010
1111
Attributes:
@@ -42,3 +42,11 @@ def validate_attachment_type(cls, attachment_type: str) -> None:
4242
raise ValueError(
4343
f"meta_type must be one of {valid_types}. Found {attachment_type}"
4444
)
45+
46+
def delete(self) -> None:
47+
"""Deletes an attachment on the data row."""
48+
query_str = """mutation deleteDataRowAttachmentPyApi($attachment_id: ID!) {
49+
deleteDataRowAttachment(where: {id: $attachment_id}) {
50+
id}
51+
}"""
52+
self.client.execute(query_str, {"attachment_id": self.uid})

labelbox/schema/data_row.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,4 @@ def create_attachment(self, attachment_type,
9595
data_row_id_param: self.uid
9696
})
9797
return Entity.AssetAttachment(self.client,
98-
res["createDataRowAttachment"])
99-
100-
def delete_attachment(self, attachment_id: str) -> None:
101-
"""Deletes an attachment on the data row."""
102-
query_str = """mutation deleteDataRowAttachmentPyApi($attachment_id: ID!) {
103-
deleteDataRowAttachment(where: {id: $attachment_id}) {
104-
id}
105-
}"""
106-
self.client.execute(query_str, {"attachment_id": attachment_id})
98+
res["createDataRowAttachment"])

0 commit comments

Comments
 (0)