Skip to content

Commit dbbe2d8

Browse files
authored
Merge pull request #172 from Labelbox/develop
2.6.0
2 parents 8c0c935 + 6983bfb commit dbbe2d8

File tree

14 files changed

+190
-73
lines changed

14 files changed

+190
-73
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
# Changelog
2+
3+
# Version 2.6.0 (2021-06-11)
4+
## Fix
5+
* Upated `create_mask_ndjson` helper function in `image_mal.ipynb` to use the color arg
6+
instead of a hardcoded color.
7+
8+
## Added
9+
* asset_metadata is now deprecated and has been replaced with asset_attachments
10+
* `AssetAttachment` replaces `AssetMetadata` ( see definition for updated attribute names )
11+
* Use `DataRow.attachments()` instead of `DataRow.metadata()`
12+
* Use `DataRow.create_attachment()` instead of `DataRow.create_metadata()`
13+
* Update pydantic version
14+
215
# Version 2.5.6 (2021-05-19)
316
## Fix
417
* MAL validation no longer raises exception when NER tool has same start and end location

examples/basics/data_rows.ipynb

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
{
2626
"cell_type": "code",
27-
"execution_count": 1,
27+
"execution_count": null,
2828
"id": "posted-nation",
2929
"metadata": {},
3030
"outputs": [],
@@ -34,7 +34,7 @@
3434
},
3535
{
3636
"cell_type": "code",
37-
"execution_count": 2,
37+
"execution_count": 1,
3838
"id": "beautiful-ready",
3939
"metadata": {},
4040
"outputs": [],
@@ -47,7 +47,7 @@
4747
},
4848
{
4949
"cell_type": "code",
50-
"execution_count": 3,
50+
"execution_count": 2,
5151
"id": "vertical-stockholm",
5252
"metadata": {},
5353
"outputs": [],
@@ -78,21 +78,21 @@
7878
},
7979
{
8080
"cell_type": "code",
81-
"execution_count": 4,
81+
"execution_count": 3,
8282
"id": "rural-fellow",
8383
"metadata": {},
8484
"outputs": [],
8585
"source": [
8686
"# Pick a project that has a dataset attached, data has external ids, and there are some labels\n",
8787
"# This will modify the project so just pick a dummy one that you don't care about\n",
88-
"PROJECT_ID = \"ckk4q1viuc0w20704eh69u28h\"\n",
88+
"PROJECT_ID = \"ckpnfquwy0kyg0y8t9rwb99cz\"\n",
8989
"# Only update this if you have an on-prem deployment\n",
9090
"ENDPOINT = \"https://api.labelbox.com/graphql\""
9191
]
9292
},
9393
{
9494
"cell_type": "code",
95-
"execution_count": 5,
95+
"execution_count": 4,
9696
"id": "proof-detective",
9797
"metadata": {},
9898
"outputs": [],
@@ -102,7 +102,7 @@
102102
},
103103
{
104104
"cell_type": "code",
105-
"execution_count": 6,
105+
"execution_count": 5,
106106
"id": "selective-reconstruction",
107107
"metadata": {},
108108
"outputs": [],
@@ -123,7 +123,7 @@
123123
},
124124
{
125125
"cell_type": "code",
126-
"execution_count": 7,
126+
"execution_count": 6,
127127
"id": "extra-paris",
128128
"metadata": {},
129129
"outputs": [],
@@ -134,17 +134,17 @@
134134
},
135135
{
136136
"cell_type": "code",
137-
"execution_count": 8,
137+
"execution_count": 7,
138138
"id": "packed-going",
139139
"metadata": {},
140140
"outputs": [
141141
{
142142
"name": "stdout",
143143
"output_type": "stream",
144144
"text": [
145-
"Associated dataset <Dataset {'created_at': datetime.datetime(2021, 3, 28, 23, 35, 34, tzinfo=datetime.timezone.utc), 'description': '', 'name': 'image_mal_dataset', 'uid': 'ckmtsvzps21f80y6205t304se', 'updated_at': datetime.datetime(2021, 3, 28, 23, 35, 34, tzinfo=datetime.timezone.utc)}>\n",
146-
"Associated label(s) <Label {'agreement': None, 'benchmark_agreement': None, 'created_at': datetime.datetime(2021, 3, 29, 17, 53, 36, tzinfo=datetime.timezone.utc), 'is_benchmark_reference': False, 'label': '{\"objects\":[{\"featureId\":\"ckmuw40nm00013g68kfua4i88\",\"schemaId\":\"ckk4q1vo80nhv0y92b7vgctgt\",\"title\":\"Frog\",\"value\":\"frog\",\"color\":\"#00D4FF\",\"bbox\":{\"top\":815,\"left\":847,\"height\":247,\"width\":512},\"instanceURI\":\"https://api.labelbox.com/masks/feature/ckmuw40nm00013g68kfua4i88\"}],\"classifications\":[]}', 'seconds_to_label': 0, 'uid': 'ckmuw42qy00033g68zdhpove7', 'updated_at': datetime.datetime(2021, 3, 29, 17, 54, 32, tzinfo=datetime.timezone.utc)}>\n",
147-
"External id dbb168f6-4f2c-46e0-a22a-abc837fda3f1\n"
145+
"Associated dataset <Dataset {'created_at': datetime.datetime(2021, 6, 8, 2, 40, 10, tzinfo=datetime.timezone.utc), 'description': '', 'name': 'image_mea_dataset', 'uid': 'ckpnfqv6g1rvb0ybt85hjephs', 'updated_at': datetime.datetime(2021, 6, 8, 2, 40, 10, tzinfo=datetime.timezone.utc)}>\n",
146+
"Associated label(s) <Label {'agreement': None, 'benchmark_agreement': None, 'created_at': datetime.datetime(2021, 6, 8, 2, 42, 11, tzinfo=datetime.timezone.utc), 'is_benchmark_reference': False, 'label': '{\"objects\":[{\"featureId\":\"ckpnftdgo00013h693jxji4wa\",\"schemaId\":\"ckpnfqw600kyt0y8tgwsb01xg\",\"title\":\"person\",\"value\":\"person\",\"color\":\"#ff0000\",\"bbox\":{\"top\":1044,\"left\":1460,\"height\":265,\"width\":118},\"instanceURI\":\"https://api.labelbox.com/masks/feature/ckpnftdgo00013h693jxji4wa\"},{\"featureId\":\"ckpo2bsq800013h69mi1w6xz1\",\"schemaId\":\"ckpnfqw610kyx0y8t4hotc6ld\",\"title\":\"car\",\"value\":\"car\",\"color\":\"#00ffff\",\"instanceURI\":\"https://api.labelbox.com/masks/feature/ckpo2bsq800013h69mi1w6xz1\"}],\"classifications\":[]}', 'seconds_to_label': 101.633, 'uid': 'ckpnftgpx00033h69z83erv92', 'updated_at': datetime.datetime(2021, 6, 9, 0, 51, 34, tzinfo=datetime.timezone.utc)}>\n",
147+
"External id 3b983504-bfbd-4c26-8719-8ef2d5a2c14f\n"
148148
]
149149
}
150150
],
@@ -157,15 +157,15 @@
157157
},
158158
{
159159
"cell_type": "code",
160-
"execution_count": 9,
160+
"execution_count": 8,
161161
"id": "above-vocabulary",
162162
"metadata": {},
163163
"outputs": [
164164
{
165165
"name": "stdout",
166166
"output_type": "stream",
167167
"text": [
168-
"<DataRow {'created_at': datetime.datetime(2021, 3, 28, 23, 35, 35, tzinfo=datetime.timezone.utc), 'external_id': 'dbb168f6-4f2c-46e0-a22a-abc837fda3f1', 'row_data': 'https://upload.wikimedia.org/wikipedia/commons/thumb/0/08/Kitano_Street_Kobe01s5s4110.jpg/2560px-Kitano_Street_Kobe01s5s4110.jpg', 'uid': 'ckmtsvzx421fb0y62bbsmbavz', 'updated_at': datetime.datetime(2021, 3, 29, 17, 54, 56, tzinfo=datetime.timezone.utc)}>\n"
168+
"<DataRow {'created_at': datetime.datetime(2021, 6, 8, 2, 40, 10, tzinfo=datetime.timezone.utc), 'external_id': '3b983504-bfbd-4c26-8719-8ef2d5a2c14f', 'media_attributes': {'width': 2560, 'height': 1707, 'mimeType': 'image/jpeg'}, 'row_data': 'https://upload.wikimedia.org/wikipedia/commons/thumb/0/08/Kitano_Street_Kobe01s5s4110.jpg/2560px-Kitano_Street_Kobe01s5s4110.jpg', 'uid': 'ckpnfqvcb0t2o0yane73d3whi', 'updated_at': datetime.datetime(2021, 6, 9, 0, 51, tzinfo=datetime.timezone.utc)}>\n"
169169
]
170170
}
171171
],
@@ -185,17 +185,17 @@
185185
},
186186
{
187187
"cell_type": "code",
188-
"execution_count": 10,
188+
"execution_count": 9,
189189
"id": "medical-portuguese",
190190
"metadata": {},
191191
"outputs": [
192192
{
193193
"data": {
194194
"text/plain": [
195-
"<DataRow ID: ckmuw60q700ur0y8wcu178hbi>"
195+
"<DataRow ID: ckporcoee1c7s0z7fha6l5x0d>"
196196
]
197197
},
198-
"execution_count": 14,
198+
"execution_count": 9,
199199
"metadata": {},
200200
"output_type": "execute_result"
201201
}
@@ -213,7 +213,7 @@
213213
},
214214
{
215215
"cell_type": "code",
216-
"execution_count": 11,
216+
"execution_count": 10,
217217
"id": "round-perfume",
218218
"metadata": {},
219219
"outputs": [],
@@ -228,7 +228,7 @@
228228
},
229229
{
230230
"cell_type": "code",
231-
"execution_count": 12,
231+
"execution_count": 11,
232232
"id": "breeding-brother",
233233
"metadata": {},
234234
"outputs": [],
@@ -243,7 +243,7 @@
243243
},
244244
{
245245
"cell_type": "code",
246-
"execution_count": 13,
246+
"execution_count": 12,
247247
"id": "thrown-designation",
248248
"metadata": {},
249249
"outputs": [],
@@ -256,7 +256,7 @@
256256
},
257257
{
258258
"cell_type": "code",
259-
"execution_count": 14,
259+
"execution_count": 13,
260260
"id": "japanese-jefferson",
261261
"metadata": {},
262262
"outputs": [],
@@ -272,7 +272,7 @@
272272
},
273273
{
274274
"cell_type": "code",
275-
"execution_count": 15,
275+
"execution_count": 14,
276276
"id": "accessible-effort",
277277
"metadata": {},
278278
"outputs": [
@@ -304,15 +304,15 @@
304304
},
305305
{
306306
"cell_type": "code",
307-
"execution_count": 16,
307+
"execution_count": 15,
308308
"id": "floral-elimination",
309309
"metadata": {},
310310
"outputs": [
311311
{
312312
"name": "stdout",
313313
"output_type": "stream",
314314
"text": [
315-
"18201a8d-34a5-41ea-8ea0-feede9776b4a 18201a8d-34a5-41ea-8ea0-feede9776b4a\n"
315+
"337e90de-c13c-48be-a87d-94d331b5e9a7 337e90de-c13c-48be-a87d-94d331b5e9a7\n"
316316
]
317317
}
318318
],
@@ -325,28 +325,28 @@
325325
},
326326
{
327327
"cell_type": "code",
328-
"execution_count": 17,
328+
"execution_count": 16,
329329
"id": "collect-cosmetic",
330330
"metadata": {},
331331
"outputs": [
332332
{
333333
"data": {
334334
"text/plain": [
335-
"<AssetMetadata ID: ckmuw6mme5mpr0y839dzheh7c>"
335+
"<AssetAttachment ID: ckporcvj61dni0y632e6cb217>"
336336
]
337337
},
338-
"execution_count": 21,
338+
"execution_count": 16,
339339
"metadata": {},
340340
"output_type": "execute_result"
341341
}
342342
],
343343
"source": [
344344
"# We can also create attachments\n",
345345
"# Attachments are visible for all projects connected to the data_row \n",
346-
"data_row.create_metadata(meta_type=\"TEXT\", meta_value=\"LABELERS WILL SEE THIS \")\n",
346+
"data_row.create_attachment(attachment_type=\"TEXT\", attachment_value=\"LABELERS WILL SEE THIS \")\n",
347347
"# See more information here:\n",
348348
"# https://docs.labelbox.com/data-model/en/index-en#attachments\n",
349-
"# Note that meta_value must always be a string (url to a video/image or a text value to display)"
349+
"# Note that attachment_value must always be a string (url to a video/image or a text value to display)"
350350
]
351351
},
352352
{
@@ -359,7 +359,7 @@
359359
},
360360
{
361361
"cell_type": "code",
362-
"execution_count": 18,
362+
"execution_count": 17,
363363
"id": "dental-banana",
364364
"metadata": {},
365365
"outputs": [],
@@ -370,7 +370,7 @@
370370
},
371371
{
372372
"cell_type": "code",
373-
"execution_count": 19,
373+
"execution_count": 18,
374374
"id": "binary-organic",
375375
"metadata": {},
376376
"outputs": [],

examples/model_assisted_labeling/image_mal.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@
346346
" },\n",
347347
" \"mask\": {\n",
348348
" \"instanceURI\": url,\n",
349-
" \"colorRGB\": [255, 0, 0]\n",
349+
" \"colorRGB\": color\n",
350350
" }\n",
351351
" }\n",
352352
" return result\n",
@@ -553,4 +553,4 @@
553553
},
554554
"nbformat": 4,
555555
"nbformat_minor": 5
556-
}
556+
}

labelbox/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = "labelbox"
2-
__version__ = "2.5.6"
2+
__version__ = "2.6.0"
33

44
from labelbox.client import Client
55
from labelbox.schema.bulk_import_request import BulkImportRequest

labelbox/orm/db_object.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ def __init__(self, source, relationship, value=None):
117117
def __call__(self, *args, **kwargs):
118118
""" Forwards the call to either `_to_many` or `_to_one` methods,
119119
depending on relationship type. """
120+
121+
if self.relationship.deprecation_warning:
122+
logger.warning(self.relationship.deprecation_warning)
123+
120124
if self.relationship.relationship_type == Relationship.Type.ToMany:
121125
return self._to_many(*args, **kwargs)
122126
else:
@@ -131,7 +135,6 @@ def _to_many(self, where=None, order_by=None):
131135
iterable over destination DbObject instances.
132136
"""
133137
rel = self.relationship
134-
135138
if where is not None and not self.supports_filtering:
136139
raise InvalidQueryError(
137140
"Relationship %s.%s doesn't support filtering" %

labelbox/orm/model.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ class Relationship:
186186
(not always) just a camelCase version of `name`.
187187
cache (bool) : Whether or not to cache the relationship values.
188188
Useful for objects that aren't directly queryable from the api (relationship query builder won't work)
189-
Also useful for expensive ToOne relationships
189+
Also useful for expensive ToOne relationships
190+
deprecation_warning (string) optional message to display when RelationshipManager is called
190191
191192
"""
192193

@@ -195,24 +196,26 @@ class Type(Enum):
195196
ToMany = auto()
196197

197198
@staticmethod
198-
def ToOne(*args, cache=False):
199-
return Relationship(Relationship.Type.ToOne, *args, cache=cache)
199+
def ToOne(*args, **kwargs):
200+
return Relationship(Relationship.Type.ToOne, *args, **kwargs)
200201

201202
@staticmethod
202-
def ToMany(*args):
203-
return Relationship(Relationship.Type.ToMany, *args)
203+
def ToMany(*args, **kwargs):
204+
return Relationship(Relationship.Type.ToMany, *args, **kwargs)
204205

205206
def __init__(self,
206207
relationship_type,
207208
destination_type_name,
208209
filter_deleted=True,
209210
name=None,
210211
graphql_name=None,
211-
cache=False):
212+
cache=False,
213+
deprecation_warning=None):
212214
self.relationship_type = relationship_type
213215
self.destination_type_name = destination_type_name
214216
self.filter_deleted = filter_deleted
215217
self.cache = cache
218+
self.deprecation_warning = deprecation_warning
216219

217220
if name is None:
218221
name = utils.snake_case(destination_type_name) + (
@@ -268,14 +271,14 @@ def cached_entities(entity_name: str):
268271

269272
def validate_cached_relationships(cls):
270273
"""
271-
Graphql doesn't allow for infinite nesting in queries.
274+
Graphql doesn't allow for infinite nesting in queries.
272275
This function checks that cached relationships result in valid queries.
273276
* It does this by making sure that a cached relationship do not
274277
reference any entity with its own cached relationships.
275278
276-
This check is performed by looking to see if this entity caches
277-
any entities that have their own cached fields. If this entity
278-
that we are checking has any cached fields then we also check
279+
This check is performed by looking to see if this entity caches
280+
any entities that have their own cached fields. If this entity
281+
that we are checking has any cached fields then we also check
279282
all currently defined entities to see if they cache this entity.
280283
281284
A two way check is necessary because checks are performed as classes are being defined.

labelbox/schema/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import labelbox.schema.asset_metadata
2+
import labelbox.schema.asset_attachment
23
import labelbox.schema.bulk_import_request
34
import labelbox.schema.benchmark
45
import labelbox.schema.data_row

labelbox/schema/asset_attachment.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from enum import Enum
2+
3+
from labelbox.orm.db_object import DbObject
4+
from labelbox.orm.model import Field
5+
6+
7+
class AssetAttachment(DbObject):
8+
""" Asset attachment provides extra context about an asset while labeling.
9+
10+
Attributes:
11+
attachment_type (str): IMAGE, VIDEO, TEXT, or IMAGE_OVERLAY
12+
attachment_value (str): URL to an external file or a string of text
13+
"""
14+
15+
class AttachmentType(Enum):
16+
VIDEO = "VIDEO"
17+
IMAGE = "IMAGE"
18+
TEXT = "TEXT"
19+
IMAGE_OVERLAY = "IMAGE_OVERLAY"
20+
21+
for topic in AttachmentType:
22+
vars()[topic.name] = topic.value
23+
24+
attachment_type = Field.String("attachment_type", "type")
25+
attachment_value = Field.String("attachment_value", "value")

0 commit comments

Comments
 (0)