|
43 | 43 | { |
44 | 44 | "metadata": {}, |
45 | 45 | "source": [ |
46 | | - "!pip install labelbox" |
| 46 | + "!pip install labelbox -q" |
47 | 47 | ], |
48 | 48 | "cell_type": "code", |
49 | 49 | "outputs": [], |
|
71 | 71 | "metadata": {}, |
72 | 72 | "source": [ |
73 | 73 | "# Add your api key\n", |
74 | | - "API_KEY = None\n", |
| 74 | + "API_KEY = \"Enter api key here\"\n", |
75 | 75 | "client = lb.Client(api_key=API_KEY)" |
76 | 76 | ], |
77 | 77 | "cell_type": "code", |
|
212 | 212 | { |
213 | 213 | "metadata": {}, |
214 | 214 | "source": [ |
215 | | - "### Update and Delete\n", |
216 | | - "- At this time, these options are not supported from the SDK.\n", |
217 | | - "- Updating an ontology is dangerous and could cause labels to be hidden. \n", |
218 | | - " - Use caution when doing so" |
| 215 | + "### Update and Delete" |
219 | 216 | ], |
220 | 217 | "cell_type": "markdown" |
221 | 218 | }, |
| 219 | + { |
| 220 | + "metadata": {}, |
| 221 | + "source": [ |
| 222 | + "# Check if feature is archived\n", |
| 223 | + "feature_schema = next(client.get_feature_schemas(\"cat\"))\n", |
| 224 | + "client.is_feature_schema_archived(ontology_id=ontology.uid, feature_schema_id=feature_schema.uid)" |
| 225 | + ], |
| 226 | + "cell_type": "code", |
| 227 | + "outputs": [], |
| 228 | + "execution_count": null |
| 229 | + }, |
| 230 | + { |
| 231 | + "metadata": {}, |
| 232 | + "source": [ |
| 233 | + "Delete or Archived a feature:\n", |
| 234 | + "\n", |
| 235 | + "If the feature schema is a root level node with associated labels, it will be archived.\n", |
| 236 | + "If the feature schema is a nested node in the ontology and does not have associated labels, it will be deleted.\n", |
| 237 | + "If the feature schema is a nested node in the ontology and has associated labels, it will not be deleted." |
| 238 | + ], |
| 239 | + "cell_type": "markdown" |
| 240 | + }, |
| 241 | + { |
| 242 | + "metadata": {}, |
| 243 | + "source": [ |
| 244 | + "client.delete_feature_schema_from_ontology(ontology_id=ontology.uid, feature_schema_id=feature_schema.uid)" |
| 245 | + ], |
| 246 | + "cell_type": "code", |
| 247 | + "outputs": [], |
| 248 | + "execution_count": null |
| 249 | + }, |
222 | 250 | { |
223 | 251 | "metadata": {}, |
224 | 252 | "source": [ |
|
286 | 314 | " name=\"cat\",\n", |
287 | 315 | " classifications=[\n", |
288 | 316 | " lb.Classification(class_type=lb.Classification.Type.TEXT,\n", |
289 | | - " instructions=\"name\")\n", |
| 317 | + " name=\"name\")\n", |
290 | 318 | " ])\n", |
291 | 319 | " ],\n", |
292 | 320 | " classifications=[\n", |
293 | 321 | " lb.Classification(class_type=lb.Classification.Type.RADIO,\n", |
294 | | - " instructions=\"image_quality\",\n", |
| 322 | + " name=\"image_quality\",\n", |
295 | 323 | " options=[lb.Option(value=\"clear\"),\n", |
296 | 324 | " lb.Option(value=\"blurry\")])\n", |
297 | 325 | " ])\n", |
|
301 | 329 | "outputs": [], |
302 | 330 | "execution_count": null |
303 | 331 | }, |
| 332 | + { |
| 333 | + "metadata": {}, |
| 334 | + "source": [ |
| 335 | + "Example of how to add sub-classfication within an option" |
| 336 | + ], |
| 337 | + "cell_type": "markdown" |
| 338 | + }, |
| 339 | + { |
| 340 | + "metadata": {}, |
| 341 | + "source": [ |
| 342 | + "# We will use add_classification to add this classification to a previously built ontology_builder or you can create new ontology_builder = OntologyBuilder() \n", |
| 343 | + "radio_classification = lb.Classification(class_type=lb.Classification.Type.RADIO,\n", |
| 344 | + " name=\"Global classification\",\n", |
| 345 | + " options=[lb.Option(\"1st option\", options=[lb.Classification(class_type=lb.Classification.Type.CHECKLIST,\n", |
| 346 | + " name=\"Inside 1st option\",\n", |
| 347 | + " options=[lb.Option(\"Option A\"), lb.Option(\"Option B\")])]), lb.Option(\"2nd option\", options=[lb.Classification(class_type=lb.Classification.Type.CHECKLIST,\n", |
| 348 | + " name=\"Inside 2nd option\",\n", |
| 349 | + " options=[lb.Option(\"Option A\"), lb.Option(\"Option B\")])])])\n", |
| 350 | + "\n", |
| 351 | + "ontology_builder.add_classification(radio_classification) \n", |
| 352 | + "\n", |
| 353 | + "ontology = client.create_ontology(\"example of nested classification\",\n", |
| 354 | + " ontology_builder.asdict())\n", |
| 355 | + "print(json.dumps(ontology.normalized, indent=2))" |
| 356 | + ], |
| 357 | + "cell_type": "code", |
| 358 | + "outputs": [], |
| 359 | + "execution_count": null |
| 360 | + }, |
304 | 361 | { |
305 | 362 | "metadata": {}, |
306 | 363 | "source": [ |
|
335 | 392 | "metadata": {}, |
336 | 393 | "source": [ |
337 | 394 | "text_classification = lb.Classification(class_type=lb.Classification.Type.TEXT,\n", |
338 | | - " instructions=\"dog_name\")\n", |
| 395 | + " name=\"dog_name\")\n", |
339 | 396 | "radio_classification = lb.Classification(class_type=lb.Classification.Type.RADIO,\n", |
340 | | - " instructions=\"dog_breed\",\n", |
| 397 | + " name=\"dog_breed\",\n", |
341 | 398 | " options=[lb.Option(\"poodle\")])\n", |
342 | 399 | "checklist_classification = lb.Classification(\n", |
343 | 400 | " class_type=lb.Classification.Type.CHECKLIST,\n", |
344 | | - " instructions=\"background\",\n", |
| 401 | + " name=\"background\",\n", |
345 | 402 | " options=[lb.Option(\"at_park\"), lb.Option(\"has_leash\")])" |
346 | 403 | ], |
347 | 404 | "cell_type": "code", |
|
0 commit comments