From 5927c1cc7315a9356ddda0aa6b94b0519df8ef14 Mon Sep 17 00:00:00 2001 From: ovalle15 Date: Fri, 5 Apr 2024 10:44:49 -0400 Subject: [PATCH 1/4] update composite mask notebook, and data row metadata notebook --- examples/basics/data_row_metadata.ipynb | 82 ++++++++++++++++---- examples/exports/composite_mask_export.ipynb | 3 +- 2 files changed, 68 insertions(+), 17 deletions(-) diff --git a/examples/basics/data_row_metadata.ipynb b/examples/basics/data_row_metadata.ipynb index 8e3dd5051..59f3f00c4 100644 --- a/examples/basics/data_row_metadata.ipynb +++ b/examples/basics/data_row_metadata.ipynb @@ -121,7 +121,7 @@ { "metadata": {}, "source": [ - "# list all your metadata ontology as a dictionary accessable by id \n", + "# list all your metadata ontology as a dictionary accessable by id\n", "metadata_ontologies = mdo.fields_by_id\n", "pprint(metadata_ontologies, indent=2)" ], @@ -166,6 +166,56 @@ "outputs": [], "execution_count": null }, + { + "metadata": {}, + "source": [ + "### Export metadata fields" + ], + "cell_type": "markdown" + }, + { + "metadata": {}, + "source": [ + "data_row_ids = ['']\n", + "global_keys = ['']\n", + "\n", + "# These methods provide validation for the ID being provided.\n", + "datarow_identifiers = lb.DataRowIds(data_row_ids)\n", + "global_key_identifiers = lb.GlobalKeys(global_keys)\n", + "\n", + "# Use one of the identifiers\n", + "mdo.bulk_export(data_row_ids=global_key_identifiers)\n", + "# mdo.bulk_export(data_row_ids=datarow_identifiers)" + ], + "cell_type": "code", + "outputs": [], + "execution_count": null + }, + { + "metadata": {}, + "source": [ + "### Delete metadata fields from a data row" + ], + "cell_type": "markdown" + }, + { + "metadata": {}, + "source": [ + "global_key = ''\n", + "schema_ids_to_delete =[\"\"]\n", + "data_row_id = ''\n", + "\n", + "deletions = [\n", + " lb.DeleteDataRowMetadata(data_row_id=lb.GlobalKey(global_key), fields=schema_ids_to_delete)\n", + " ]\n", + "\n", + "# Delete the specified metadata on the data row\n", + "mdo.bulk_delete(deletes=deletions)" + ], + "cell_type": "code", + "outputs": [], + "execution_count": null + }, { "metadata": {}, "source": [ @@ -190,19 +240,19 @@ "source": [ "# Construct a metadata field of string kind\n", "tag_metadata_field = lb.DataRowMetadataField(\n", - " name=\"tag\", \n", - " value=\"tag_string\", \n", + " name=\"tag\",\n", + " value=\"tag_string\",\n", ")\n", "\n", "# Construct an metadata field of datetime kind\n", "capture_datetime_field = lb.DataRowMetadataField(\n", - " name=\"captureDateTime\", \n", - " value=datetime.utcnow(), \n", + " name=\"captureDateTime\",\n", + " value=datetime.utcnow(),\n", ")\n", "\n", "# Construct a metadata field of Enums options\n", "split_metadata_field = lb.DataRowMetadataField(\n", - " name=\"split\", \n", + " name=\"split\",\n", " value=\"train\",\n", ")\n" ], @@ -253,12 +303,12 @@ { "metadata": {}, "source": [ - "# Final \n", + "# Final\n", "custom_metadata_fields = []\n", "\n", - "# Create the schema for the metadata \n", + "# Create the schema for the metadata\n", "number_schema = mdo.create_schema(\n", - " name=\"numberMetadataCustom\", \n", + " name=\"numberMetadataCustom\",\n", " kind=DataRowMetadataKind.number\n", ")\n", "\n", @@ -277,16 +327,16 @@ { "metadata": {}, "source": [ - "# Create the schema for an enum metadata \n", + "# Create the schema for an enum metadata\n", "custom_metadata_fields = []\n", "\n", "enum_schema = mdo.create_schema(\n", - " name=\"enumMetadata\", \n", + " name=\"enumMetadata\",\n", " kind=DataRowMetadataKind.enum,\n", " options=[\"option1\", \"option2\"]\n", ")\n", "\n", - "# Add fields to the metadata schema \n", + "# Add fields to the metadata schema\n", "data_row_metadata_fields_enum_1 = lb.DataRowMetadataField(\n", " name=enum_schema.name,\n", " value=\"option1\"\n", @@ -360,13 +410,13 @@ "\n", "# Update the metadata\n", "updated_metadata = lb.DataRowMetadataField(\n", - " schema_id=num_schema.uid, \n", + " schema_id=num_schema.uid,\n", " value=10.2\n", ")\n", "\n", "# Create data row payload\n", "data_row_payload = lb.DataRowMetadata(\n", - " global_key=global_key, \n", + " global_key=global_key,\n", " fields=[updated_metadata]\n", ")\n", "\n", @@ -387,12 +437,12 @@ { "metadata": {}, "source": [ - "# update a name \n", + "# update a name\n", "number_schema = mdo.update_schema(name=\"numberMetadataCustom\", new_name=\"numberMetadataCustomNew\")\n", "\n", "# update an Enum metadata schema option's name, this only applies to Enum metadata schema.\n", "enum_schema = mdo.update_enum_option(\n", - " name=\"enumMetadata\", \n", + " name=\"enumMetadata\",\n", " option=\"option1\",\n", " new_option=\"option3\"\n", ")" diff --git a/examples/exports/composite_mask_export.ipynb b/examples/exports/composite_mask_export.ipynb index dc46810fd..b24133141 100644 --- a/examples/exports/composite_mask_export.ipynb +++ b/examples/exports/composite_mask_export.ipynb @@ -30,7 +30,8 @@ { "metadata": {}, "source": [ - "# Export composite masks\n", + "# Export composite masks \n", + "##### **Composite masks are only available on raster segmentation projects**\n", "\n", "Composite masks are a combination of mask instances grouped in a single mask URL. \n", "\n", From 57e6a2d33a84467cdabf7c974e66a9470cbacc89 Mon Sep 17 00:00:00 2001 From: ovalle15 Date: Fri, 5 Apr 2024 10:48:50 -0400 Subject: [PATCH 2/4] latest updates --- examples/basics/data_row_metadata.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/basics/data_row_metadata.ipynb b/examples/basics/data_row_metadata.ipynb index 59f3f00c4..39b020c0d 100644 --- a/examples/basics/data_row_metadata.ipynb +++ b/examples/basics/data_row_metadata.ipynb @@ -202,7 +202,7 @@ "metadata": {}, "source": [ "global_key = ''\n", - "schema_ids_to_delete =[\"\"]\n", + "schema_ids_to_delete =['']\n", "data_row_id = ''\n", "\n", "deletions = [\n", From 650044d1f57a15a49203b2aa6799643266976a0a Mon Sep 17 00:00:00 2001 From: ovalle15 Date: Fri, 5 Apr 2024 11:15:21 -0400 Subject: [PATCH 3/4] latest updates --- examples/basics/data_row_metadata.ipynb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/basics/data_row_metadata.ipynb b/examples/basics/data_row_metadata.ipynb index 39b020c0d..63d83a950 100644 --- a/examples/basics/data_row_metadata.ipynb +++ b/examples/basics/data_row_metadata.ipynb @@ -179,7 +179,8 @@ "data_row_ids = ['']\n", "global_keys = ['']\n", "\n", - "# These methods provide validation for the ID being provided.\n", + "# These methods provide validation that the ID you are passing is a global key or data row id ,\n", + "# this method also assures that all IDs are unique\n", "datarow_identifiers = lb.DataRowIds(data_row_ids)\n", "global_key_identifiers = lb.GlobalKeys(global_keys)\n", "\n", From 4f644bde28fd7ef00b79ed1f673b6078265a115b Mon Sep 17 00:00:00 2001 From: ovalle15 Date: Fri, 5 Apr 2024 12:09:48 -0400 Subject: [PATCH 4/4] replaced single quotes with double quotes --- examples/basics/data_row_metadata.ipynb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/basics/data_row_metadata.ipynb b/examples/basics/data_row_metadata.ipynb index 63d83a950..e567a7380 100644 --- a/examples/basics/data_row_metadata.ipynb +++ b/examples/basics/data_row_metadata.ipynb @@ -176,8 +176,8 @@ { "metadata": {}, "source": [ - "data_row_ids = ['']\n", - "global_keys = ['']\n", + "data_row_ids = [\"\"]\n", + "global_keys = [\"\"]\n", "\n", "# These methods provide validation that the ID you are passing is a global key or data row id ,\n", "# this method also assures that all IDs are unique\n", @@ -202,9 +202,9 @@ { "metadata": {}, "source": [ - "global_key = ''\n", - "schema_ids_to_delete =['']\n", - "data_row_id = ''\n", + "global_key = \"\"\n", + "schema_ids_to_delete =[\"\"]\n", + "data_row_id = \"\"\n", "\n", "deletions = [\n", " lb.DeleteDataRowMetadata(data_row_id=lb.GlobalKey(global_key), fields=schema_ids_to_delete)\n", @@ -384,7 +384,7 @@ "global_key = \"s_basic.jpg\"\n", "data_row = {\"row_data\": \"https://storage.googleapis.com/labelbox-sample-datasets/Docs/basic.jpg\", \"global_key\": global_key}\n", "# This line works with dictionaries as well as schemas and fields created with DataRowMetadataField\n", - "data_row['metadata_fields'] = custom_metadata_fields + [ split_metadata_field , capture_datetime_field_dict, tag_metadata_field ]\n", + "data_row[\"metadata_fields\"] = custom_metadata_fields + [ split_metadata_field , capture_datetime_field_dict, tag_metadata_field ]\n", "\n", "\n", "task = dataset.create_data_rows([data_row])\n", @@ -466,7 +466,7 @@ "source": [ "data_row = next(dataset.data_rows())\n", "for metadata_field in data_row.metadata_fields:\n", - " print(metadata_field['name'], \":\", metadata_field['value'])" + " print(metadata_field[\"name\"], \":\", metadata_field[\"value\"])" ], "cell_type": "code", "outputs": [],