|
59 | 59 | }, |
60 | 60 | { |
61 | 61 | "cell_type": "code", |
62 | | - "execution_count": null, |
| 62 | + "execution_count": 1, |
63 | 63 | "id": "dimensional-celebrity", |
64 | 64 | "metadata": {}, |
65 | | - "outputs": [], |
| 65 | + "outputs": [ |
| 66 | + { |
| 67 | + "name": "stdout", |
| 68 | + "output_type": "stream", |
| 69 | + "text": [ |
| 70 | + "zsh:1: command not found: pip\n", |
| 71 | + "zsh:1: command not found: pip\n", |
| 72 | + "zsh:1: command not found: pip\n" |
| 73 | + ] |
| 74 | + } |
| 75 | + ], |
66 | 76 | "source": [ |
67 | 77 | "!pip install labelbox\n", |
68 | 78 | "!pip install ndjson\n", |
|
71 | 81 | }, |
72 | 82 | { |
73 | 83 | "cell_type": "code", |
74 | | - "execution_count": 6, |
| 84 | + "execution_count": 2, |
75 | 85 | "id": "american-confusion", |
76 | 86 | "metadata": {}, |
77 | 87 | "outputs": [], |
|
89 | 99 | }, |
90 | 100 | { |
91 | 101 | "cell_type": "code", |
92 | | - "execution_count": 2, |
| 102 | + "execution_count": 3, |
93 | 103 | "id": "indoor-pharmacy", |
94 | 104 | "metadata": {}, |
95 | 105 | "outputs": [], |
|
102 | 112 | }, |
103 | 113 | { |
104 | 114 | "cell_type": "code", |
105 | | - "execution_count": 3, |
| 115 | + "execution_count": 4, |
106 | 116 | "id": "healthy-perry", |
107 | 117 | "metadata": {}, |
108 | 118 | "outputs": [], |
|
112 | 122 | }, |
113 | 123 | { |
114 | 124 | "cell_type": "code", |
115 | | - "execution_count": 4, |
| 125 | + "execution_count": 5, |
116 | 126 | "id": "instrumental-ontario", |
117 | 127 | "metadata": {}, |
118 | 128 | "outputs": [], |
|
126 | 136 | }, |
127 | 137 | { |
128 | 138 | "cell_type": "code", |
129 | | - "execution_count": 7, |
| 139 | + "execution_count": 6, |
130 | 140 | "id": "particular-blocking", |
131 | 141 | "metadata": {}, |
132 | 142 | "outputs": [], |
|
143 | 153 | }, |
144 | 154 | { |
145 | 155 | "cell_type": "code", |
146 | | - "execution_count": 8, |
| 156 | + "execution_count": 7, |
147 | 157 | "id": "cross-assumption", |
148 | 158 | "metadata": {}, |
149 | 159 | "outputs": [], |
|
160 | 170 | }, |
161 | 171 | { |
162 | 172 | "cell_type": "code", |
163 | | - "execution_count": 9, |
| 173 | + "execution_count": 8, |
164 | 174 | "id": "monetary-catalyst", |
165 | 175 | "metadata": {}, |
166 | 176 | "outputs": [ |
167 | 177 | { |
168 | 178 | "data": { |
169 | 179 | "text/plain": [ |
170 | | - "'ckmtsvzx421fb0y62bbsmbavz'" |
| 180 | + "'ckmunvlqt4w9u0y625l7cd7zq'" |
171 | 181 | ] |
172 | 182 | }, |
173 | | - "execution_count": 9, |
| 183 | + "execution_count": 8, |
174 | 184 | "metadata": {}, |
175 | 185 | "output_type": "execute_result" |
176 | 186 | } |
|
181 | 191 | }, |
182 | 192 | { |
183 | 193 | "cell_type": "code", |
184 | | - "execution_count": 10, |
| 194 | + "execution_count": 9, |
185 | 195 | "id": "designing-cricket", |
186 | 196 | "metadata": {}, |
187 | 197 | "outputs": [ |
|
192 | 202 | "traceback": [ |
193 | 203 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
194 | 204 | "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", |
195 | | - "\u001b[0;32m~/Library/Python/3.8/lib/python/site-packages/labelbox/schema/bulk_import_request.py\u001b[0m in \u001b[0;36m_validate_ndjson\u001b[0;34m(lines, project)\u001b[0m\n\u001b[1;32m 346\u001b[0m \u001b[0mannotation\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mNDAnnotation\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 347\u001b[0;31m \u001b[0mannotation\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalidate_instance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata_row_ids\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfeature_schemas\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 348\u001b[0m \u001b[0muuid\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mannotation\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0muuid\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
196 | | - "\u001b[0;32m~/Library/Python/3.8/lib/python/site-packages/labelbox/schema/bulk_import_request.py\u001b[0m in \u001b[0;36mvalidate_instance\u001b[0;34m(self, valid_datarows, valid_feature_schemas)\u001b[0m\n\u001b[1;32m 545\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalidate_feature_schemas\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalid_feature_schemas\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 546\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalidate_datarow\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalid_datarows\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 547\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", |
197 | | - "\u001b[0;32m~/Library/Python/3.8/lib/python/site-packages/labelbox/schema/bulk_import_request.py\u001b[0m in \u001b[0;36mvalidate_datarow\u001b[0;34m(self, valid_datarows)\u001b[0m\n\u001b[1;32m 528\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdataRow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mid\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mvalid_datarows\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 529\u001b[0;31m raise ValueError(\n\u001b[0m\u001b[1;32m 530\u001b[0m \u001b[0;34mf\"datarow {self.dataRow.id} is not attached to the specified project\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
| 205 | + "\u001b[0;32m~/Library/Python/3.8/lib/python/site-packages/labelbox/schema/bulk_import_request.py\u001b[0m in \u001b[0;36m_validate_ndjson\u001b[0;34m(lines, project)\u001b[0m\n\u001b[1;32m 401\u001b[0m \u001b[0mannotation\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mNDAnnotation\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 402\u001b[0;31m \u001b[0mannotation\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalidate_instance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata_row_ids\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfeature_schemas\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 403\u001b[0m \u001b[0muuid\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mannotation\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0muuid\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
| 206 | + "\u001b[0;32m~/Library/Python/3.8/lib/python/site-packages/labelbox/schema/bulk_import_request.py\u001b[0m in \u001b[0;36mvalidate_instance\u001b[0;34m(self, valid_datarows, valid_feature_schemas)\u001b[0m\n\u001b[1;32m 600\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalidate_feature_schemas\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalid_feature_schemas\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 601\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalidate_datarow\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalid_datarows\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 602\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", |
| 207 | + "\u001b[0;32m~/Library/Python/3.8/lib/python/site-packages/labelbox/schema/bulk_import_request.py\u001b[0m in \u001b[0;36mvalidate_datarow\u001b[0;34m(self, valid_datarows)\u001b[0m\n\u001b[1;32m 583\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdataRow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mid\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mvalid_datarows\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 584\u001b[0;31m raise ValueError(\n\u001b[0m\u001b[1;32m 585\u001b[0m \u001b[0;34mf\"datarow {self.dataRow.id} is not attached to the specified project\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
198 | 208 | "\u001b[0;31mValueError\u001b[0m: datarow cjxav4aa07r1g0dsq70t9eveg is not attached to the specified project", |
199 | 209 | "\nThe above exception was the direct cause of the following exception:\n", |
200 | 210 | "\u001b[0;31mMALValidationError\u001b[0m Traceback (most recent call last)", |
201 | | - "\u001b[0;32m<ipython-input-10-9b20d211103c>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0m_validate_ndjson\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mpoly_example\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mproject\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", |
202 | | - "\u001b[0;32m~/Library/Python/3.8/lib/python/site-packages/labelbox/schema/bulk_import_request.py\u001b[0m in \u001b[0;36m_validate_ndjson\u001b[0;34m(lines, project)\u001b[0m\n\u001b[1;32m 353\u001b[0m \u001b[0muids\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0muuid\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 354\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mpydantic\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mValidationError\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 355\u001b[0;31m raise labelbox.exceptions.MALValidationError(\n\u001b[0m\u001b[1;32m 356\u001b[0m f\"Invalid NDJson on line {idx}\") from e\n\u001b[1;32m 357\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", |
| 211 | + "\u001b[0;32m<ipython-input-9-9b20d211103c>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0m_validate_ndjson\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mpoly_example\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mproject\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", |
| 212 | + "\u001b[0;32m~/Library/Python/3.8/lib/python/site-packages/labelbox/schema/bulk_import_request.py\u001b[0m in \u001b[0;36m_validate_ndjson\u001b[0;34m(lines, project)\u001b[0m\n\u001b[1;32m 408\u001b[0m \u001b[0muids\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0muuid\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 409\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mpydantic\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mValidationError\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 410\u001b[0;31m raise labelbox.exceptions.MALValidationError(\n\u001b[0m\u001b[1;32m 411\u001b[0m f\"Invalid NDJson on line {idx}\") from e\n\u001b[1;32m 412\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", |
203 | 213 | "\u001b[0;31mMALValidationError\u001b[0m: Invalid NDJson on line 0('Invalid NDJson on line 0', None)" |
204 | 214 | ] |
205 | 215 | } |
|
222 | 232 | }, |
223 | 233 | { |
224 | 234 | "cell_type": "code", |
225 | | - "execution_count": 11, |
| 235 | + "execution_count": 10, |
226 | 236 | "id": "thick-juvenile", |
227 | 237 | "metadata": {}, |
228 | 238 | "outputs": [], |
|
242 | 252 | }, |
243 | 253 | { |
244 | 254 | "cell_type": "code", |
245 | | - "execution_count": 12, |
| 255 | + "execution_count": 11, |
246 | 256 | "id": "stock-correction", |
247 | 257 | "metadata": {}, |
248 | 258 | "outputs": [ |
249 | 259 | { |
250 | | - "data": { |
251 | | - "text/plain": [ |
252 | | - "[{'uuid': '1b5762e9-416c-44cf-9a5f-07effb51f863',\n", |
253 | | - " 'dataRow': {'id': 'cjxav4aa07r1g0dsq70t9eveg'},\n", |
254 | | - " 'status': 'FAILURE',\n", |
255 | | - " 'errors': [{'name': 'DataRowNotFound',\n", |
256 | | - " 'message': 'dataRow.id cjxav4aa07r1g0dsq70t9eveg invalid',\n", |
257 | | - " 'additionalInfo': None}]},\n", |
258 | | - " {'uuid': '1b5762e9-416c-44cf-9a5f-07effb51f863',\n", |
259 | | - " 'dataRow': {'id': 'cjxav4aa07r1g0dsq70t9eveg'},\n", |
260 | | - " 'status': 'FAILURE',\n", |
261 | | - " 'errors': [{'name': 'DataRowNotFound',\n", |
262 | | - " 'message': 'dataRow.id cjxav4aa07r1g0dsq70t9eveg invalid',\n", |
263 | | - " 'additionalInfo': None},\n", |
264 | | - " {'name': 'GeometryInvalid',\n", |
265 | | - " 'message': 'Invalid geometry: Each linear ring must contain at least 4 positions',\n", |
266 | | - " 'additionalInfo': None}]}]" |
267 | | - ] |
268 | | - }, |
269 | | - "execution_count": 12, |
270 | | - "metadata": {}, |
271 | | - "output_type": "execute_result" |
| 260 | + "name": "stdout", |
| 261 | + "output_type": "stream", |
| 262 | + "text": [ |
| 263 | + "{'uuid': '1b5762e9-416c-44cf-9a5f-07effb51f863', 'dataRow': {'id': 'cjxav4aa07r1g0dsq70t9eveg'}, 'status': 'FAILURE', 'errors': [{'name': 'DataRowNotFound', 'message': 'dataRow.id cjxav4aa07r1g0dsq70t9eveg invalid', 'additionalInfo': None}]}\n", |
| 264 | + "{'uuid': '1b5762e9-416c-44cf-9a5f-07effb51f863', 'dataRow': {'id': 'cjxav4aa07r1g0dsq70t9eveg'}, 'status': 'FAILURE', 'errors': [{'name': 'DataRowNotFound', 'message': 'dataRow.id cjxav4aa07r1g0dsq70t9eveg invalid', 'additionalInfo': None}, {'name': 'GeometryInvalid', 'message': 'Invalid geometry: Each linear ring must contain at least 4 positions', 'additionalInfo': None}]}\n" |
| 265 | + ] |
272 | 266 | } |
273 | 267 | ], |
274 | 268 | "source": [ |
275 | 269 | "# Let's check the status:\n", |
276 | | - "ndjson.loads(requests.get(bulk_import_request.status_file_url).text)" |
| 270 | + "for status in bulk_import_request.statuses:\n", |
| 271 | + " print(status)\n", |
| 272 | + " \n", |
| 273 | + "for error in bulk_import_request.errors:\n", |
| 274 | + " print(error)" |
277 | 275 | ] |
278 | 276 | }, |
279 | 277 | { |
280 | 278 | "cell_type": "code", |
281 | | - "execution_count": 13, |
| 279 | + "execution_count": null, |
282 | 280 | "id": "square-david", |
283 | 281 | "metadata": {}, |
284 | 282 | "outputs": [], |
|
0 commit comments