Skip to content

Commit b78d67b

Browse files
committed
changes to test cases that were previously broken but we did not see it
1 parent 39927ca commit b78d67b

File tree

4 files changed

+171
-14
lines changed

4 files changed

+171
-14
lines changed

labelbox/data/generator.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import logging
12
import threading
23
from queue import Queue
34
from typing import Any, Iterable
5+
import threading
6+
7+
logger = logging.getLogger(__name__)
48

59

610
class ThreadSafeGen:
@@ -48,8 +52,9 @@ def __init__(self,
4852
self.completed_threads = 0
4953
# Can only iterate over once it the queue.get hangs forever.
5054
self.done = False
55+
self.multithread = multithread
5156

52-
if multithread:
57+
if self.multithread:
5358
self.num_executors = num_executors
5459
self.threads = [
5560
threading.Thread(target=self.fill_queue)
@@ -71,20 +76,23 @@ def fill_queue(self):
7176
if value is None:
7277
raise ValueError("Unexpected None")
7378
self.queue.put(value)
74-
except:
79+
except Exception as e:
7580
self.queue.put(
76-
ValueError("Unexpected exception while filling queue."))
81+
ValueError("Unexpected exception while filling queue. %r", e))
7782

7883
def __iter__(self):
7984
return self
8085

8186
def __next__(self) -> Any:
82-
if self.done:
87+
if self.done or self.queue.empty():
8388
raise StopIteration
84-
value = self.queue.get(block=False)
89+
value = self.queue.get()
8590
if isinstance(value, ValueError):
8691
raise value
8792
while value is None:
93+
if not self.multithread:
94+
value = self.queue.get()
95+
continue
8896
self.completed_threads += 1
8997
if self.completed_threads == self.num_executors:
9098
self.done = True

labelbox/data/serialization/coco/panoptic_dataset.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def from_common(cls,
131131

132132
for result in results:
133133
images.append(result[0])
134-
all_coco_annotations.extend(result[1])
134+
all_coco_annotations.append(result[1])
135135
coco_categories.update(result[2])
136136
coco_things.update(result[3])
137137

@@ -175,12 +175,12 @@ def to_common(self, image_root: Path, mask_root: Path):
175175
raise ValueError(
176176
f"Cannot find file {im_path}. Make sure `image_root` is set properly"
177177
)
178-
179-
if not annotation.file_name.endswith('.png'):
178+
if not str(annotation.file_name).endswith('.png'):
180179
raise ValueError(
181180
f"COCO masks must be stored as png files and their extension must be `.png`. Found {annotation.file_name}"
182181
)
183-
mask = MaskData(file_path=Path(mask_root, annotation.file_name))
182+
mask = MaskData(
183+
file_path=str(Path(mask_root, annotation.file_name)))
184184

185185
for segmentation in annotation.segments_info:
186186
category = category_lookup[segmentation.category_id]
@@ -189,6 +189,6 @@ def to_common(self, image_root: Path, mask_root: Path):
189189
value=Mask(mask=mask,
190190
color=id_to_rgb(
191191
segmentation.id))))
192-
data = ImageData(file_path=im_path)
192+
data = ImageData(file_path=str(im_path))
193193
yield Label(data=data, annotations=annotations)
194194
del annotation_lookup[image.id]
Lines changed: 153 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,153 @@
1-
[{"ID": "ckw3ce1mc78b50zc30dqf0qhj", "DataRow ID": "ckw3cctc41uqg0zo5023e59hn", "Labeled Data": "https://storage.labelbox.com/ckk4q1vgapsau07324awnsjq2%2F8821d3e2-9059-b616-9d4a-9723da3ea073-im1?Expires=1638367029433&KeyName=labelbox-assets-key-3&Signature=FPOQz-alx3gHMK30ib1iPqJj0W0", "Label": {"objects": [{"featureId": "ckw3ce58u00003e66w9rh0onm", "schemaId": "ckw3cdy207b6t0zbn3sh52xoh", "color": "#1CE6FF", "title": "obj", "value": "obj", "polygon": [{"x": 99.405, "y": 56.15}, {"x": 111.421, "y": 99.129}, {"x": 146.082, "y": 80.413}, {"x": 118.815, "y": 47.369}], "instanceURI": "https://api.labelbox.com/masks/feature/ckw3ce58u00003e66w9rh0onm?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJja2s0cTF2Z3djMHZwMDcwNHhoeDdtNHZrIiwib3JnYW5pemF0aW9uSWQiOiJja2s0cTF2Z2Fwc2F1MDczMjRhd25zanEyIiwiaWF0IjoxNjM3MTU3NDI5LCJleHAiOjE2Mzk3NDk0Mjl9.L4PvjcpSIWV_9R5_M7c_24sj79wtserE_2hkx3ZeCMU"}], "classifications": [], "relationships": []}, "Created By": "msokoloff@labelbox.com", "Project Name": "test", "Created At": "2021-11-17T09:48:56.000Z", "Updated At": "2021-11-17T09:48:56.305Z", "Seconds to Label": 2.239, "External ID": "im1", "Agreement": -1, "Benchmark Agreement": -1, "Benchmark ID": null, "Dataset Name": "no-name", "Reviews": [], "View Label": "https://editor.labelbox.com?project=ckw3cd90b38br0zd4dh4n1xou&label=ckw3ce1mc78b50zc30dqf0qhj", "Has Open Issues": 0, "Skipped": false}, {"ID": "ckw3cea3f7b9t0zbn2tgp2y83", "DataRow ID": "ckw3cctc41uqo0zo5gpma1mr2", "Labeled Data": "https://storage.labelbox.com/ckk4q1vgapsau07324awnsjq2%2F1bc65970-9880-78b4-d298-7a7ef7f8f3fc-im3?Expires=1638367029433&KeyName=labelbox-assets-key-3&Signature=GZUsyQqYYlQPWBYv7GApFYlHXAc", "Label": {"objects": [], "classifications": [{"featureId": "ckw3ced5e00023e66236meh70", "schemaId": "ckw3cdy207b6v0zbn11gp0zz4", "title": "classification", "value": "classification", "answer": {"featureId": "ckw3ced5e00013e6652355ejd", "schemaId": "ckw3cdy207b6w0zbn2hgp3321", "title": "op1", "value": "op_1"}}], "relationships": []}, "Created By": "msokoloff@labelbox.com", "Project Name": "test", "Created At": "2021-11-17T09:49:02.000Z", "Updated At": "2021-11-17T09:49:02.220Z", "Seconds to Label": 5.373, "External ID": "im3", "Agreement": -1, "Benchmark Agreement": -1, "Benchmark ID": null, "Dataset Name": "no-name", "Reviews": [], "View Label": "https://editor.labelbox.com?project=ckw3cd90b38br0zd4dh4n1xou&label=ckw3cea3f7b9t0zbn2tgp2y83", "Has Open Issues": 0, "Skipped": false}, {"ID": "ckw3cec4v78ex0zc3aodwdekw", "DataRow ID": "ckw3cctc41uqs0zo52cy6eus1", "Labeled Data": "https://storage.labelbox.com/ckk4q1vgapsau07324awnsjq2%2Fdb42c0e8-e005-3305-ed35-b021f109b6a7-im4?Expires=1638367029433&KeyName=labelbox-assets-key-3&Signature=Hms9mqcIyWNDzoJUdvMa6_hRKY4", "Label": {"objects": [{"featureId": "ckw3cefl900033e66k41q6zpc", "schemaId": "ckw3cdy207b6t0zbn3sh52xoh", "color": "#1CE6FF", "title": "obj", "value": "obj", "polygon": [{"x": 69.58, "y": 42.292}, {"x": 64.932, "y": 74.128}, {"x": 91.888, "y": 64.601}, {"x": 86.775, "y": 41.828}], "instanceURI": "https://api.labelbox.com/masks/feature/ckw3cefl900033e66k41q6zpc?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJja2s0cTF2Z3djMHZwMDcwNHhoeDdtNHZrIiwib3JnYW5pemF0aW9uSWQiOiJja2s0cTF2Z2Fwc2F1MDczMjRhd25zanEyIiwiaWF0IjoxNjM3MTU3NDI5LCJleHAiOjE2Mzk3NDk0Mjl9.L4PvjcpSIWV_9R5_M7c_24sj79wtserE_2hkx3ZeCMU"}], "classifications": [{"featureId": "ckw3ceijf00053e669zaplftd", "schemaId": "ckw3cdy207b6v0zbn11gp0zz4", "title": "classification", "value": "classification", "answer": {"featureId": "ckw3ceijf00043e665ex22xkp", "schemaId": "ckw3cdy207b6y0zbn77201rux", "title": "op2", "value": "op_2"}}], "relationships": []}, "Created By": "msokoloff@labelbox.com", "Project Name": "test", "Created At": "2021-11-17T09:49:15.000Z", "Updated At": "2021-11-17T09:49:15.785Z", "Seconds to Label": 5, "External ID": "im4", "Agreement": -1, "Benchmark Agreement": -1, "Benchmark ID": null, "Dataset Name": "no-name", "Reviews": [], "View Label": "https://editor.labelbox.com?project=ckw3cd90b38br0zd4dh4n1xou&label=ckw3cec4v78ex0zc3aodwdekw", "Has Open Issues": 0, "Skipped": false}, {"ID": "ckw3ce1s34c1i0zbp32067q4v", "DataRow ID": "ckw3cctc41uqk0zo52n31egs1", "Labeled Data": "https://storage.labelbox.com/ckk4q1vgapsau07324awnsjq2%2F402cbd62-9127-5b50-57d6-d77aaf89f643-im2?Expires=1638367029433&KeyName=labelbox-assets-key-3&Signature=QIwHFUXN1mjBn8K4ZLWVQGQekmE", "Label": {}, "Created By": "msokoloff@labelbox.com", "Project Name": "test", "Created At": "2021-11-17T09:48:59.000Z", "Updated At": "2021-11-17T09:49:02.000Z", "Seconds to Label": 3.524, "External ID": "im2", "Agreement": -1, "Benchmark Agreement": -1, "Benchmark ID": null, "Dataset Name": "no-name", "Reviews": [], "View Label": "https://editor.labelbox.com?project=ckw3cd90b38br0zd4dh4n1xou&label=ckw3ce1s34c1i0zbp32067q4v", "Has Open Issues": 0, "Skipped": true}]
1+
[{
2+
"ID": "ckw3ce1mc78b50zc30dqf0qhj",
3+
"DataRow ID": "ckw3cctc41uqg0zo5023e59hn",
4+
"Labeled Data": "https://storage.labelbox.com/ckk4q1vgapsau07324awnsjq2%2F8821d3e2-9059-b616-9d4a-9723da3ea073-im1?Expires=1638367029433&KeyName=labelbox-assets-key-3&Signature=FPOQz-alx3gHMK30ib1iPqJj0W0",
5+
"Label": {
6+
"objects": [{
7+
"featureId": "ckw3ce58u00003e66w9rh0onm",
8+
"schemaId": "ckw3cdy207b6t0zbn3sh52xoh",
9+
"color": "#1CE6FF",
10+
"title": "obj",
11+
"value": "obj",
12+
"polygon": [{
13+
"x": 99.405,
14+
"y": 56.15
15+
}, {
16+
"x": 111.421,
17+
"y": 99.129
18+
}, {
19+
"x": 146.082,
20+
"y": 80.413
21+
}, {
22+
"x": 118.815,
23+
"y": 47.369
24+
}],
25+
"instanceURI": "https://api.labelbox.com/masks/feature/ckw3ce58u00003e66w9rh0onm?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJja2s0cTF2Z3djMHZwMDcwNHhoeDdtNHZrIiwib3JnYW5pemF0aW9uSWQiOiJja2s0cTF2Z2Fwc2F1MDczMjRhd25zanEyIiwiaWF0IjoxNjM3MTU3NDI5LCJleHAiOjE2Mzk3NDk0Mjl9.L4PvjcpSIWV_9R5_M7c_24sj79wtserE_2hkx3ZeCMU"
26+
}],
27+
"classifications": [],
28+
"relationships": []
29+
},
30+
"Created By": "msokoloff@labelbox.com",
31+
"Project Name": "test",
32+
"Created At": "2021-11-17T09:48:56.000Z",
33+
"Updated At": "2021-11-17T09:48:56.305Z",
34+
"Seconds to Label": 2.239,
35+
"External ID": "im1",
36+
"Agreement": -1,
37+
"Benchmark Agreement": -1,
38+
"Benchmark ID": null,
39+
"Dataset Name": "no-name",
40+
"Reviews": [],
41+
"View Label": "https://editor.labelbox.com?project=ckw3cd90b38br0zd4dh4n1xou&label=ckw3ce1mc78b50zc30dqf0qhj",
42+
"Has Open Issues": 0,
43+
"Skipped": false
44+
}, {
45+
"ID": "ckw3cea3f7b9t0zbn2tgp2y83",
46+
"DataRow ID": "ckw3cctc41uqo0zo5gpma1mr2",
47+
"Labeled Data": "https://storage.labelbox.com/ckk4q1vgapsau07324awnsjq2%2F1bc65970-9880-78b4-d298-7a7ef7f8f3fc-im3?Expires=1638367029433&KeyName=labelbox-assets-key-3&Signature=GZUsyQqYYlQPWBYv7GApFYlHXAc",
48+
"media_type": "image",
49+
"Label": {
50+
"objects": [],
51+
"classifications": [{
52+
"featureId": "ckw3ced5e00023e66236meh70",
53+
"schemaId": "ckw3cdy207b6v0zbn11gp0zz4",
54+
"title": "classification",
55+
"value": "classification",
56+
"answer": {
57+
"featureId": "ckw3ced5e00013e6652355ejd",
58+
"schemaId": "ckw3cdy207b6w0zbn2hgp3321",
59+
"title": "op1",
60+
"value": "op_1"
61+
}
62+
}],
63+
"relationships": []
64+
},
65+
"Created By": "msokoloff@labelbox.com",
66+
"Project Name": "test",
67+
"Created At": "2021-11-17T09:49:02.000Z",
68+
"Updated At": "2021-11-17T09:49:02.220Z",
69+
"Seconds to Label": 5.373,
70+
"External ID": "im3",
71+
"Agreement": -1,
72+
"Benchmark Agreement": -1,
73+
"Benchmark ID": null,
74+
"Dataset Name": "no-name",
75+
"Reviews": [],
76+
"View Label": "https://editor.labelbox.com?project=ckw3cd90b38br0zd4dh4n1xou&label=ckw3cea3f7b9t0zbn2tgp2y83",
77+
"Has Open Issues": 0,
78+
"Skipped": false
79+
}, {
80+
"ID": "ckw3cec4v78ex0zc3aodwdekw",
81+
"DataRow ID": "ckw3cctc41uqs0zo52cy6eus1",
82+
"Labeled Data": "https://storage.labelbox.com/ckk4q1vgapsau07324awnsjq2%2Fdb42c0e8-e005-3305-ed35-b021f109b6a7-im4?Expires=1638367029433&KeyName=labelbox-assets-key-3&Signature=Hms9mqcIyWNDzoJUdvMa6_hRKY4",
83+
"Label": {
84+
"objects": [{
85+
"featureId": "ckw3cefl900033e66k41q6zpc",
86+
"schemaId": "ckw3cdy207b6t0zbn3sh52xoh",
87+
"color": "#1CE6FF",
88+
"title": "obj",
89+
"value": "obj",
90+
"polygon": [{
91+
"x": 69.58,
92+
"y": 42.292
93+
}, {
94+
"x": 64.932,
95+
"y": 74.128
96+
}, {
97+
"x": 91.888,
98+
"y": 64.601
99+
}, {
100+
"x": 86.775,
101+
"y": 41.828
102+
}],
103+
"instanceURI": "https://api.labelbox.com/masks/feature/ckw3cefl900033e66k41q6zpc?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJja2s0cTF2Z3djMHZwMDcwNHhoeDdtNHZrIiwib3JnYW5pemF0aW9uSWQiOiJja2s0cTF2Z2Fwc2F1MDczMjRhd25zanEyIiwiaWF0IjoxNjM3MTU3NDI5LCJleHAiOjE2Mzk3NDk0Mjl9.L4PvjcpSIWV_9R5_M7c_24sj79wtserE_2hkx3ZeCMU"
104+
}],
105+
"classifications": [{
106+
"featureId": "ckw3ceijf00053e669zaplftd",
107+
"schemaId": "ckw3cdy207b6v0zbn11gp0zz4",
108+
"title": "classification",
109+
"value": "classification",
110+
"answer": {
111+
"featureId": "ckw3ceijf00043e665ex22xkp",
112+
"schemaId": "ckw3cdy207b6y0zbn77201rux",
113+
"title": "op2",
114+
"value": "op_2"
115+
}
116+
}],
117+
"relationships": []
118+
},
119+
"Created By": "msokoloff@labelbox.com",
120+
"Project Name": "test",
121+
"Created At": "2021-11-17T09:49:15.000Z",
122+
"Updated At": "2021-11-17T09:49:15.785Z",
123+
"Seconds to Label": 5,
124+
"External ID": "im4",
125+
"Agreement": -1,
126+
"Benchmark Agreement": -1,
127+
"Benchmark ID": null,
128+
"Dataset Name": "no-name",
129+
"Reviews": [],
130+
"View Label": "https://editor.labelbox.com?project=ckw3cd90b38br0zd4dh4n1xou&label=ckw3cec4v78ex0zc3aodwdekw",
131+
"Has Open Issues": 0,
132+
"Skipped": false
133+
}, {
134+
"ID": "ckw3ce1s34c1i0zbp32067q4v",
135+
"DataRow ID": "ckw3cctc41uqk0zo52n31egs1",
136+
"Labeled Data": "https://storage.labelbox.com/ckk4q1vgapsau07324awnsjq2%2F402cbd62-9127-5b50-57d6-d77aaf89f643-im2?Expires=1638367029433&KeyName=labelbox-assets-key-3&Signature=QIwHFUXN1mjBn8K4ZLWVQGQekmE",
137+
"media_type": "image",
138+
"Label": {},
139+
"Created By": "msokoloff@labelbox.com",
140+
"Project Name": "test",
141+
"Created At": "2021-11-17T09:48:59.000Z",
142+
"Updated At": "2021-11-17T09:49:02.000Z",
143+
"Seconds to Label": 3.524,
144+
"External ID": "im2",
145+
"Agreement": -1,
146+
"Benchmark Agreement": -1,
147+
"Benchmark ID": null,
148+
"Dataset Name": "no-name",
149+
"Reviews": [],
150+
"View Label": "https://editor.labelbox.com?project=ckw3cd90b38br0zd4dh4n1xou&label=ckw3ce1s34c1i0zbp32067q4v",
151+
"Has Open Issues": 0,
152+
"Skipped": true
153+
}]

tests/integration/test_data_rows.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ def test_data_row_bulk_creation(dataset, rand_gen, image_url):
5757
},
5858
])
5959
assert task in client.get_user().created_tasks()
60-
# TODO make Tasks expandable
61-
with pytest.raises(InvalidQueryError):
62-
assert task.created_by() == client.get_user()
6360
task.wait_till_done()
6461
assert task.status == "COMPLETE"
6562

0 commit comments

Comments
 (0)