Skip to content

Commit 8ad4756

Browse files
authored
Latest updates
1. Remove unnecessary imports 2. updated methods for fetching projects/datasets.
1 parent 260db43 commit 8ad4756

File tree

1 file changed

+39
-43
lines changed

1 file changed

+39
-43
lines changed

examples/basics/basics.ipynb

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,14 @@
5757
},
5858
{
5959
"cell_type": "code",
60-
"execution_count": 2,
60+
"execution_count": 9,
6161
"id": "everyday-street",
6262
"metadata": {
6363
"id": "everyday-street"
6464
},
6565
"outputs": [],
6666
"source": [
6767
"from labelbox import Project, Dataset, Client, DataRow\n",
68-
"from labelbox.schema.queue_mode import QueueMode\n",
69-
"from labelbox.schema.media_type import MediaType\n",
7068
"import random\n",
7169
"import uuid\n",
7270
"import os"
@@ -85,7 +83,7 @@
8583
},
8684
{
8785
"cell_type": "code",
88-
"execution_count": 3,
86+
"execution_count": 10,
8987
"id": "thick-gasoline",
9088
"metadata": {
9189
"id": "thick-gasoline"
@@ -104,51 +102,49 @@
104102
"# For the purpose of this demo get a single project/dataset id from your organization\n",
105103
"\n",
106104
"# Get a single Project id\n",
107-
"projects = client.get_projects()\n",
108-
"project_id=list(projects)[0].uid\n",
109-
"project_name=list(projects)[0].name\n",
105+
"# get_projects returns a PaginatedCollection object, which is iterable. \n",
106+
"project = next(client.get_projects())\n",
107+
"project_id=project.uid\n",
108+
"project_name=project.name\n",
110109
"print(\"Project ID: \", project_id)\n",
111110
"print(\"Project Name:\", project_name)\n",
112-
"print(\"Number of projects in your org:\", len(list(projects)))\n",
113111
"\n",
114112
"print(\"-\" * 40)\n",
115113
"\n",
116114
"# Get a single dataset id\n",
117-
"datasets = client.get_datasets()\n",
118-
"dataset_id = list(datasets)[0].uid\n",
119-
"dataset_name = list(datasets)[0].name\n",
115+
"# get_datasets returns a PaginatedCollection object, which is iterable. \n",
116+
"dataset = next(client.get_datasets())\n",
117+
"dataset_id = dataset.uid\n",
118+
"dataset_name = dataset.name\n",
120119
"print(\"Dataset ID: \", dataset_id)\n",
121-
"print(\"Dataset Name:\" , dataset_name)\n",
122-
"print(\"Number of datasets in your org:\", len(list(datasets)))"
120+
"print(\"Dataset Name:\" , dataset_name)"
123121
],
124122
"metadata": {
125123
"colab": {
126124
"base_uri": "https://localhost:8080/"
127125
},
128126
"id": "F_payZKCiX56",
129-
"outputId": "45123f80-6d04-4c83-8390-ec1d2f82ff3f"
127+
"outputId": "d8334a02-a62f-4b8b-a63c-5f43512fede4"
130128
},
131129
"id": "F_payZKCiX56",
132-
"execution_count": 4,
130+
"execution_count": 13,
133131
"outputs": [
134132
{
135133
"output_type": "stream",
136134
"name": "stdout",
137135
"text": [
138-
"Project ID: cl9rmkr5a4hiy07v5ey34ahtk\n",
139-
"Project Name: label_import_project_demo\n",
140-
"Number of projects in your org: 88\n",
136+
"Project ID: cl9smiqo23hk307y27k42cajv\n",
137+
"Project Name: html-editor\n",
141138
"----------------------------------------\n",
142-
"Dataset ID: cl9rmksvo3wv207y6h158giqo\n",
143-
"Dataset Name: annotation_import_demo_dataset\n",
144-
"Number of datasets in your org: 78\n"
139+
"Dataset ID: cl9sywtkj2gsv07vk2isaeadj\n",
140+
"Dataset Name: text_test.json\n"
145141
]
146142
}
147143
]
148144
},
149145
{
150146
"cell_type": "code",
151-
"execution_count": 5,
147+
"execution_count": 14,
152148
"id": "victorian-consumer",
153149
"metadata": {
154150
"id": "victorian-consumer"
@@ -162,11 +158,11 @@
162158
},
163159
{
164160
"cell_type": "code",
165-
"execution_count": 6,
161+
"execution_count": 15,
166162
"id": "industrial-onion",
167163
"metadata": {
168164
"id": "industrial-onion",
169-
"outputId": "340c857a-8aba-428c-ae0e-04d5565ccb8f",
165+
"outputId": "965cb071-45bf-458e-edd4-e82781c58e7a",
170166
"colab": {
171167
"base_uri": "https://localhost:8080/"
172168
}
@@ -176,8 +172,8 @@
176172
"output_type": "stream",
177173
"name": "stdout",
178174
"text": [
179-
"Project: <Project {'auto_audit_number_of_labels': 1, 'auto_audit_percentage': 1, 'created_at': datetime.datetime(2022, 10, 27, 22, 16, 33, tzinfo=datetime.timezone.utc), 'description': '', 'last_activity_time': datetime.datetime(2022, 10, 27, 22, 16, 46, tzinfo=datetime.timezone.utc), 'media_type': <MediaType.Image: 'IMAGE'>, 'name': 'label_import_project_demo', 'queue_mode': <QueueMode.Batch: 'BATCH'>, 'setup_complete': datetime.datetime(2022, 10, 27, 22, 16, 45, tzinfo=datetime.timezone.utc), 'uid': 'cl9rmkr5a4hiy07v5ey34ahtk', 'updated_at': datetime.datetime(2022, 10, 27, 22, 16, 46, tzinfo=datetime.timezone.utc)}>\n",
180-
"Dataset: <Dataset {'created_at': datetime.datetime(2022, 10, 27, 22, 16, 36, tzinfo=datetime.timezone.utc), 'description': '', 'name': 'annotation_import_demo_dataset', 'row_count': 5, 'uid': 'cl9rmksvo3wv207y6h158giqo', 'updated_at': datetime.datetime(2022, 10, 27, 22, 16, 37, tzinfo=datetime.timezone.utc)}>\n"
175+
"Project: <Project {'auto_audit_number_of_labels': 1, 'auto_audit_percentage': 1, 'created_at': datetime.datetime(2022, 10, 28, 15, 2, 45, tzinfo=datetime.timezone.utc), 'description': '', 'last_activity_time': datetime.datetime(2022, 10, 28, 15, 47, 41, tzinfo=datetime.timezone.utc), 'media_type': <MediaType.Image: 'IMAGE'>, 'name': 'html-editor', 'queue_mode': <QueueMode.Batch: 'BATCH'>, 'setup_complete': None, 'uid': 'cl9smiqo23hk307y27k42cajv', 'updated_at': datetime.datetime(2022, 10, 28, 15, 47, 41, tzinfo=datetime.timezone.utc)}>\n",
176+
"Dataset: <Dataset {'created_at': datetime.datetime(2022, 10, 28, 20, 49, 38, tzinfo=datetime.timezone.utc), 'description': '', 'name': 'text_test.json', 'row_count': 3, 'uid': 'cl9sywtkj2gsv07vk2isaeadj', 'updated_at': datetime.datetime(2022, 10, 28, 20, 49, 40, tzinfo=datetime.timezone.utc)}>\n"
181177
]
182178
}
183179
],
@@ -200,11 +196,11 @@
200196
},
201197
{
202198
"cell_type": "code",
203-
"execution_count": 7,
199+
"execution_count": 16,
204200
"id": "guided-institute",
205201
"metadata": {
206202
"id": "guided-institute",
207-
"outputId": "9fe66adc-8336-431a-cea1-91942e4939bc",
203+
"outputId": "7805c5e3-ba99-4c91-98f8-fc69575f64fc",
208204
"colab": {
209205
"base_uri": "https://localhost:8080/"
210206
}
@@ -214,8 +210,8 @@
214210
"output_type": "stream",
215211
"name": "stdout",
216212
"text": [
217-
"label_import_project_demo\n",
218-
"annotation_import_demo_dataset\n"
213+
"html-editor\n",
214+
"text_test.json\n"
219215
]
220216
}
221217
],
@@ -236,14 +232,14 @@
236232
},
237233
{
238234
"cell_type": "code",
239-
"execution_count": 8,
235+
"execution_count": 17,
240236
"id": "according-subdivision",
241237
"metadata": {
242238
"id": "according-subdivision",
243239
"colab": {
244240
"base_uri": "https://localhost:8080/"
245241
},
246-
"outputId": "9bc9e80d-3bce-43f5-a18d-554174fb8a7a"
242+
"outputId": "18faa683-fbd5-48ce-abb5-6a6c93464b23"
247243
},
248244
"outputs": [
249245
{
@@ -273,11 +269,11 @@
273269
},
274270
{
275271
"cell_type": "code",
276-
"execution_count": 9,
272+
"execution_count": 18,
277273
"id": "ideal-processing",
278274
"metadata": {
279275
"id": "ideal-processing",
280-
"outputId": "c1d7ac49-31d4-4949-896d-8765f5954436",
276+
"outputId": "ea10e564-fe27-47f1-8993-1d03d2be26a7",
281277
"colab": {
282278
"base_uri": "https://localhost:8080/"
283279
}
@@ -303,14 +299,14 @@
303299
},
304300
{
305301
"cell_type": "code",
306-
"execution_count": 10,
302+
"execution_count": 19,
307303
"id": "convinced-force",
308304
"metadata": {
309305
"id": "convinced-force",
310306
"colab": {
311307
"base_uri": "https://localhost:8080/"
312308
},
313-
"outputId": "3aff953b-efc4-4f1e-f2cd-575c3e78c01a"
309+
"outputId": "b6afc495-fd71-4ac1-9e42-3fcaa6fa1802"
314310
},
315311
"outputs": [
316312
{
@@ -345,11 +341,11 @@
345341
},
346342
{
347343
"cell_type": "code",
348-
"execution_count": 11,
344+
"execution_count": 20,
349345
"id": "cubic-joint",
350346
"metadata": {
351347
"id": "cubic-joint",
352-
"outputId": "f02e5758-6db7-44a3-cf2b-937164e18bda",
348+
"outputId": "b4ac9639-a362-4f6e-cbef-7c0a032b3b1f",
353349
"colab": {
354350
"base_uri": "https://localhost:8080/"
355351
}
@@ -359,8 +355,8 @@
359355
"output_type": "stream",
360356
"name": "stdout",
361357
"text": [
362-
"<labelbox.pagination.PaginatedCollection object at 0x7f463f4e70d0>\n",
363-
"<Project {'auto_audit_number_of_labels': 1, 'auto_audit_percentage': 1, 'created_at': datetime.datetime(2022, 10, 27, 22, 16, 33, tzinfo=datetime.timezone.utc), 'description': 'new description field', 'last_activity_time': datetime.datetime(2022, 10, 28, 13, 20, 59, tzinfo=datetime.timezone.utc), 'media_type': <MediaType.Image: 'IMAGE'>, 'name': 'label_import_project_demo', 'queue_mode': <QueueMode.Batch: 'BATCH'>, 'setup_complete': datetime.datetime(2022, 10, 27, 22, 16, 45, tzinfo=datetime.timezone.utc), 'uid': 'cl9rmkr5a4hiy07v5ey34ahtk', 'updated_at': datetime.datetime(2022, 10, 28, 13, 20, 59, tzinfo=datetime.timezone.utc)}>\n",
358+
"<labelbox.pagination.PaginatedCollection object at 0x7fe3c7a49e90>\n",
359+
"<Project {'auto_audit_number_of_labels': 1, 'auto_audit_percentage': 1, 'created_at': datetime.datetime(2022, 10, 28, 15, 2, 45, tzinfo=datetime.timezone.utc), 'description': 'new description field', 'last_activity_time': datetime.datetime(2022, 11, 1, 19, 18, 21, tzinfo=datetime.timezone.utc), 'media_type': <MediaType.Image: 'IMAGE'>, 'name': 'html-editor', 'queue_mode': <QueueMode.Batch: 'BATCH'>, 'setup_complete': None, 'uid': 'cl9smiqo23hk307y27k42cajv', 'updated_at': datetime.datetime(2022, 11, 1, 19, 18, 21, tzinfo=datetime.timezone.utc)}>\n",
364360
"None\n",
365361
"None\n"
366362
]
@@ -412,7 +408,7 @@
412408
"id": "future-bargain",
413409
"metadata": {
414410
"id": "future-bargain",
415-
"outputId": "f4c2980b-9b06-41c9-be36-7dfb5b4429bf",
411+
"outputId": "a2e32b99-8bd7-4b24-ce5a-171b3a2c6441",
416412
"colab": {
417413
"base_uri": "https://localhost:8080/"
418414
}
@@ -422,8 +418,8 @@
422418
"output_type": "stream",
423419
"name": "stdout",
424420
"text": [
425-
" Name of project : label_import_project_demo\n",
426-
" Name of batches in project: first-batch-LI-demo\n"
421+
" Name of project : html-editor\n",
422+
" Name of batches in project: testsss\n"
427423
]
428424
}
429425
],

0 commit comments

Comments
 (0)