Skip to content

Commit 0ec46be

Browse files
committed
doc(LAB-3532): update importing_assets_and_metadata.md recipe & tutorial
1 parent a72b5bb commit 0ec46be

3 files changed

Lines changed: 110 additions & 60 deletions

File tree

docs/sdk/tutorials/importing_assets_and_metadata.md

Lines changed: 53 additions & 25 deletions
Large diffs are not rendered by default.

recipes/img/json_metadata.png

763 KB
Loading

recipes/importing_assets_and_metadata.ipynb

Lines changed: 57 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"cell_type": "markdown",
5252
"metadata": {},
5353
"source": [
54-
"First, let's install and import the required modules."
54+
"First, let's install and import the required modules.\n"
5555
]
5656
},
5757
{
@@ -273,48 +273,58 @@
273273
"\n",
274274
"- `imageUrl`\n",
275275
"- `text`\n",
276-
"- `url`"
276+
"- `url`\n",
277+
"\n",
278+
"\n",
279+
"## Setting metadata properties"
277280
]
278281
},
279282
{
280283
"attachments": {},
281284
"cell_type": "markdown",
282285
"metadata": {},
283286
"source": [
284-
"As an optional step, you can set data types for each type of your metadata.\n",
285-
"The default data type is `string`, but setting some of your metadata as `number` can really help apply filters on your assets later on.\n",
287+
"As an optional step, you can define properties for each type of your metadata.\n",
288+
"These properties allow you to control:\n",
286289
"\n",
287-
"Note that we don't need to set data types for `imageUrl`, `text`, and `url`."
290+
"- The data type (`string` or `number`)\n",
291+
"- Whether the metadata is filterable in project queue\n",
292+
"- Visibility of each metadata to labelers and reviewers\n"
288293
]
289294
},
290295
{
291296
"cell_type": "code",
292297
"execution_count": null,
293298
"metadata": {},
294-
"outputs": [
295-
{
296-
"data": {
297-
"text/plain": [
298-
"{'id': 'cllamrwgl00670j393poh2t4j',\n",
299-
" 'metadataTypes': {'sensitiveData': 'string',\n",
300-
" 'customConsensus': 'number',\n",
301-
" 'uploadedFromCloud': 'string',\n",
302-
" 'modelLabelErrorScore': 'number'}}"
303-
]
304-
},
305-
"execution_count": null,
306-
"metadata": {},
307-
"output_type": "execute_result"
308-
}
309-
],
299+
"outputs": [],
310300
"source": [
311301
"kili.update_properties_in_project(\n",
312302
" project_id=project_id,\n",
313-
" metadata_types={\n",
314-
" \"customConsensus\": \"number\",\n",
315-
" \"sensitiveData\": \"string\",\n",
316-
" \"uploadedFromCloud\": \"string\",\n",
317-
" \"modelLabelErrorScore\": \"number\",\n",
303+
" metadata_properties={\n",
304+
" \"customConsensus\": {\n",
305+
" \"type\": \"number\",\n",
306+
" \"filterable\": True,\n",
307+
" \"visibleByLabeler\": True,\n",
308+
" \"visibleByReviewer\": True,\n",
309+
" },\n",
310+
" \"sensitiveData\": {\n",
311+
" \"type\": \"string\",\n",
312+
" \"filterable\": True,\n",
313+
" \"visibleByLabeler\": False, # Hide this from labelers\n",
314+
" \"visibleByReviewer\": True,\n",
315+
" },\n",
316+
" \"uploadedFromCloud\": {\n",
317+
" \"type\": \"string\",\n",
318+
" \"filterable\": True,\n",
319+
" \"visibleByLabeler\": True,\n",
320+
" \"visibleByReviewer\": True,\n",
321+
" },\n",
322+
" \"modelLabelErrorScore\": {\n",
323+
" \"type\": \"number\",\n",
324+
" \"filterable\": True,\n",
325+
" \"visibleByLabeler\": True,\n",
326+
" \"visibleByReviewer\": True,\n",
327+
" },\n",
318328
" },\n",
319329
")"
320330
]
@@ -324,6 +334,17 @@
324334
"cell_type": "markdown",
325335
"metadata": {},
326336
"source": [
337+
"> **Note**: The previous `metadata_types` parameter is deprecated. Please use metadata_properties instead. If you use metadata_types, it will still work but will be converted to metadata_properties internally with default visibility and filterability settings.\n",
338+
"\n",
339+
"If you don't specify all properties, default values will be used:\n",
340+
"\n",
341+
"```\n",
342+
"filterable: true\n",
343+
"type: 'string'\n",
344+
"visibleByLabeler: true\n",
345+
"visibleByReviewer: true\n",
346+
"```\n",
347+
"\n",
327348
"Now we can add metadata to our assets:"
328349
]
329350
},
@@ -355,19 +376,17 @@
355376
" \"sensitiveData\": \"yes\",\n",
356377
" \"uploadedFromCloud\": \"no\",\n",
357378
" \"modelLabelErrorScore\": 50,\n",
358-
" # Add metadata that will be visible to labelers in the labeling interface:\n",
359-
" \"imageUrl\": \"www.example.com/image_1.png\",\n",
360-
" \"text\": \"some text for asset 1\",\n",
379+
" \"imageUrl\": \"https://placehold.co/600x400/EEE/31343C\",\n",
380+
" \"text\": \"Some text for asset 1\",\n",
361381
" \"url\": \"www.example-website.com\",\n",
362382
" },\n",
363383
" {\n",
364384
" \"customConsensus\": 40,\n",
365385
" \"sensitiveData\": \"no\",\n",
366386
" \"uploadedFromCloud\": \"yes\",\n",
367387
" \"modelLabelErrorScore\": 30,\n",
368-
" # Add metadata that will be visible to labelers in the labeling interface:\n",
369-
" \"imageUrl\": \"www.example.com/image_2.png\",\n",
370-
" \"text\": \"some text for asset 2\",\n",
388+
" \"imageUrl\": \"https://placehold.co/600x400/EEE/31343C\",\n",
389+
" \"text\": \"Some text for asset 2\",\n",
371390
" \"url\": \"www.example-website.com\",\n",
372391
" },\n",
373392
" ],\n",
@@ -378,7 +397,10 @@
378397
"cell_type": "markdown",
379398
"metadata": {},
380399
"source": [
381-
"In the labeling interface, we can see that the assets have some metadata:"
400+
"> **Note** : alternatively, you can use `kili.set_metadata` or `kili.add_metadata` methods.\n",
401+
"\n",
402+
"\n",
403+
"In the labeling interface, we can see that the assets have some metadata (note that `sensitiveData` will be hidden from labelers based on our settings)."
382404
]
383405
},
384406
{
@@ -390,7 +412,7 @@
390412
"cell_type": "markdown",
391413
"metadata": {},
392414
"source": [
393-
"![image.png](attachment:0bea7811-9a67-461c-b716-319de1343ac8.png)"
415+
"![image.png](./img/json_metadata.png)"
394416
]
395417
},
396418
{
@@ -441,7 +463,7 @@
441463
"cell_type": "markdown",
442464
"metadata": {},
443465
"source": [
444-
"We've successfully set up a Kili project, imported assets to it, and finally added some metadata to our assets. Well done!"
466+
"We've successfully set up a Kili project, imported assets to it, and finally added some metadata to our assets with advanced property settings. Well done!"
445467
]
446468
}
447469
],

0 commit comments

Comments
 (0)