@@ -106,8 +106,10 @@ def get_winning_label_id(self, project_id: str) -> Optional[str]:
106106
107107 return res ["dataRow" ]["labelingActivity" ]["selectedLabelId" ]
108108
109- def create_attachment (self , attachment_type ,
110- attachment_value ) -> "AssetAttachment" :
109+ def create_attachment (self ,
110+ attachment_type ,
111+ attachment_value ,
112+ attachment_name = None ) -> "AssetAttachment" :
111113 """ Adds an AssetAttachment to a DataRow.
112114 Labelers can view these attachments while labeling.
113115
@@ -117,6 +119,7 @@ def create_attachment(self, attachment_type,
117119 attachment_type (str): Asset attachment type, must be one of:
118120 VIDEO, IMAGE, TEXT, IMAGE_OVERLAY (AssetAttachment.AttachmentType)
119121 attachment_value (str): Asset attachment value.
122+ attachment_name (str): (Optional) Asset attachment name.
120123 Returns:
121124 `AssetAttachment` DB object.
122125 Raises:
@@ -126,19 +129,23 @@ def create_attachment(self, attachment_type,
126129
127130 attachment_type_param = "type"
128131 attachment_value_param = "value"
132+ attachment_name_param = "name"
129133 data_row_id_param = "dataRowId"
134+
130135 query_str = """mutation CreateDataRowAttachmentPyApi(
131- $%s: AttachmentType!, $%s: String!, $%s: ID!) {
136+ $%s: AttachmentType!, $%s: String!, $%s: String, $%s: ID!) {
132137 createDataRowAttachment(data: {
133- type: $%s value: $%s dataRowId: $%s}) {%s}} """ % (
134- attachment_type_param , attachment_value_param , data_row_id_param ,
135- attachment_type_param , attachment_value_param , data_row_id_param ,
138+ type: $%s value: $%s name: $%s dataRowId: $%s}) {%s}} """ % (
139+ attachment_type_param , attachment_value_param ,
140+ attachment_name_param , data_row_id_param , attachment_type_param ,
141+ attachment_value_param , attachment_name_param , data_row_id_param ,
136142 query .results_query_part (Entity .AssetAttachment ))
137143
138144 res = self .client .execute (
139145 query_str , {
140146 attachment_type_param : attachment_type ,
141147 attachment_value_param : attachment_value ,
148+ attachment_name_param : attachment_name ,
142149 data_row_id_param : self .uid
143150 })
144151 return Entity .AssetAttachment (self .client ,
0 commit comments