Skip to content
Merged
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
26 changes: 25 additions & 1 deletion labelbox/schema/data_row.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Optional
import json

from labelbox.orm import query
Expand Down Expand Up @@ -82,6 +82,30 @@ def bulk_delete(data_rows) -> None:
"""
BulkDeletable._bulk_delete(data_rows, True)

def get_winning_label_id(self, project_id: str) -> Optional[str]:
""" Retrieves the winning label ID, i.e. the one that was marked as the
best for a particular data row, in a project's workflow.

Args:
project_id (str): ID of the project containing the data row
"""
data_row_id_param = "dataRowId"
project_id_param = "projectId"
query_str = """query GetWinningLabelIdPyApi($%s: ID!, $%s: ID!) {
dataRow(where: { id: $%s }) {
labelingActivity(where: { projectId: $%s }) {
selectedLabelId
}
}} """ % (data_row_id_param, project_id_param, data_row_id_param,
project_id_param)

res = self.client.execute(query_str, {
data_row_id_param: self.uid,
project_id_param: project_id,
})

return res["dataRow"]["labelingActivity"]["selectedLabelId"]

def create_attachment(self, attachment_type,
attachment_value) -> "AssetAttachment":
""" Adds an AssetAttachment to a DataRow.
Expand Down