Skip to content

Commit d5b7a3e

Browse files
author
Matt Sokoloff
committed
remove create_label
1 parent 7ab93ef commit d5b7a3e

File tree

4 files changed

+26
-35
lines changed

4 files changed

+26
-35
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test-staging: build
66
docker run -it -v ${PWD}:/usr/src -w /usr/src \
77
-e LABELBOX_TEST_ENVIRON="staging" \
88
-e LABELBOX_TEST_API_KEY_STAGING=${LABELBOX_TEST_API_KEY_STAGING} \
9-
local/labelbox-python:test pytest $(PATH_TO_TEST) -svvx
9+
local/labelbox-python:test pytest $(PATH_TO_TEST) -svv
1010

1111
test-prod: build
1212
docker run -it -v ${PWD}:/usr/src -w /usr/src \

labelbox/schema/project.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -96,38 +96,6 @@ def members(self):
9696
{id_param: str(self.uid)},
9797
["project", "members"], ProjectMember)
9898

99-
def create_label(self, **kwargs):
100-
""" Creates a label on a Legacy Editor project. Not supported in the new Editor.
101-
Args:
102-
**kwargs: Label attributes. At minimum, the label `DataRow`.
103-
"""
104-
# Copy-paste of Client._create code so we can inject
105-
# a connection to Type. Type objects are on their way to being
106-
# deprecated and we don't want the Py client lib user to know
107-
# about them. At the same time they're connected to a Label at
108-
# label creation in a non-standard way (connect via name).
109-
logger.warning(
110-
"`create_label` is deprecated and is not compatible with the new editor."
111-
)
112-
113-
Label = Entity.Label
114-
115-
kwargs[Label.project] = self
116-
kwargs[Label.seconds_to_label] = kwargs.get(Label.seconds_to_label.name,
117-
0.0)
118-
data = {
119-
Label.attribute(attr) if isinstance(attr, str) else attr:
120-
value.uid if isinstance(value, DbObject) else value
121-
for attr, value in kwargs.items()
122-
}
123-
124-
query_str, params = query.create(Label, data)
125-
# Inject connection to Type
126-
query_str = query_str.replace(
127-
"data: {", "data: {type: {connect: {name: \"Any\"}} ")
128-
res = self.client.execute(query_str, params)
129-
return Label(self.client, res["createLabel"])
130-
13199
def labels(self, datasets=None, order_by=None):
132100
""" Custom relationship expansion method to support limited filtering.
133101

tests/integration/conftest.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from collections import namedtuple
22
from enum import Enum
33
from datetime import datetime
4+
45
from random import randint
56
from string import ascii_letters
67
from types import SimpleNamespace
@@ -11,6 +12,9 @@
1112

1213
from labelbox.orm.query import results_query_part
1314
from labelbox.schema.invite import Invite
15+
from labelbox.orm.db_object import DbObject
16+
from labelbox.orm.model import Entity
17+
from labelbox.orm import query
1418
from labelbox.pagination import PaginatedCollection
1519
from labelbox.schema.user import User
1620
from labelbox import LabelingFrontend
@@ -143,6 +147,26 @@ def gen(field_type):
143147
@pytest.fixture
144148
def project(client, rand_gen):
145149
project = client.create_project(name=rand_gen(str))
150+
def create_label(**kwargs):
151+
""" Creates a label on a Legacy Editor project. Not supported in the new Editor.
152+
Args:
153+
**kwargs: Label attributes. At minimum, the label `DataRow`.
154+
"""
155+
Label = Entity.Label
156+
kwargs[Label.project] = project
157+
kwargs[Label.seconds_to_label] = kwargs.get(Label.seconds_to_label.name,
158+
0.0)
159+
data = {
160+
Label.attribute(attr) if isinstance(attr, str) else attr:
161+
value.uid if isinstance(value, DbObject) else value
162+
for attr, value in kwargs.items()
163+
}
164+
query_str, params = query.create(Label, data)
165+
query_str = query_str.replace(
166+
"data: {", "data: {type: {connect: {name: \"Any\"}} ")
167+
res = project.client.execute(query_str, params)
168+
return Label(project.client, res["createLabel"])
169+
project.create_label = create_label
146170
yield project
147171
project.delete()
148172

tests/integration/test_label.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ def test_label_update(label_pack):
5555
assert label.label == "something else"
5656

5757

58-
def test_label_filter_order(client, rand_gen):
59-
project = client.create_project(name=rand_gen(str))
58+
def test_label_filter_order(client,project, rand_gen):
6059
dataset_1 = client.create_dataset(name=rand_gen(str), projects=project)
6160
dataset_2 = client.create_dataset(name=rand_gen(str), projects=project)
6261
data_row_1 = dataset_1.create_data_row(row_data=IMG_URL)

0 commit comments

Comments
 (0)