Skip to content

Commit 3e1bdfd

Browse files
author
Matt Sokoloff
committed
label registration working with local deployment
1 parent c0e8e43 commit 3e1bdfd

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

labelbox/schema/model_run.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ def upsert_labels(self, label_ids, timeout_seconds=60):
3737
""" % (mutation_name)
3838

3939
res = self.client.execute(create_task_query_str, {
40-
'modelRunId': self.uid,
41-
'labelIds': label_ids
42-
})
40+
'modelRunId': self.uid,
41+
'labelIds': label_ids
42+
})
4343
task_id = res[mutation_name]
4444

4545
status_query_str = """query MEALabelRegistrationTaskStatusPyApi($where: WhereUniqueIdInput!){
@@ -48,14 +48,21 @@ def upsert_labels(self, label_ids, timeout_seconds=60):
4848
"""
4949

5050
while True:
51-
res = self.client.execute(status_query_str, {'where': {'id': task_id}})['MEALabelRegistrationTaskStatus']
52-
breakpoint()
53-
if res:
51+
res = self.client.execute(status_query_str,
52+
{'where': {
53+
'id': task_id
54+
}})['MEALabelRegistrationTaskStatus']
55+
if res['status'] == 'COMPLETE':
5456
return res
57+
elif res['status'] == 'FAILED':
58+
raise Exception(
59+
f"MEA Label Import Failed. Details : {res['errorMessage']}")
5560

5661
timeout_seconds -= sleep_time
5762
if timeout_seconds <= 0:
58-
return None
63+
raise TimeoutError(
64+
f"Unable to complete import within {timeout_seconds} seconds."
65+
)
5966

6067
time.sleep(sleep_time)
6168

0 commit comments

Comments
 (0)