-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #412 from Labelbox/al-1280
adds to raise exception to main caller thread from prefetch generator
- Loading branch information
Showing
8 changed files
with
243 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 153 additions & 1 deletion
154
tests/data/assets/labelbox_v1/unkown_media_type_export.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,153 @@ | ||
[{"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}] | ||
[{ | ||
"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", | ||
"media_type": "image", | ||
"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", | ||
"media_type": "image", | ||
"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 | ||
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import pytest | ||
from labelbox.data.generator import PrefetchGenerator | ||
from random import random | ||
|
||
|
||
class ChildClassGenerator(PrefetchGenerator): | ||
|
||
def __init__(self, examples, num_executors=1): | ||
super().__init__(data=examples, num_executors=num_executors) | ||
|
||
def _process(self, value): | ||
num = random() | ||
if num < .2: | ||
raise ValueError("Randomized value error") | ||
return value | ||
|
||
|
||
amount = (i for i in range(50)) | ||
|
||
|
||
def test_single_thread_generator(): | ||
generator = ChildClassGenerator(amount, num_executors=1) | ||
|
||
with pytest.raises(ValueError): | ||
for _ in range(51): | ||
next(generator) | ||
|
||
|
||
def test_multi_thread_generator(): | ||
generator = ChildClassGenerator(amount, num_executors=4) | ||
|
||
with pytest.raises(ValueError): | ||
for _ in range(51): | ||
next(generator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters