Skip to content

Commit b9ab590

Browse files
author
Val Brodsky
committed
Raise exception to not allow project to disconnect labeling front end
1 parent e5de933 commit b9ab590

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

libs/labelbox/src/labelbox/orm/db_object.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ def connect(self, other):
192192
self.source.client.execute(query_string, params)
193193

194194
def disconnect(self, other):
195+
""" Disconnects source object of this manager from the `other` object. """
195196
if not self.config.disconnect_supported:
196197
raise OperationNotSupportedException(
197198
"Disconnect is not supported for this relationship")
198-
""" Disconnects source object of this manager from the `other` object. """
199199

200200
query_string, params = query.update_relationship(
201201
self.source, other, self.relationship, "disconnect")

libs/labelbox/src/labelbox/schema/project.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ class Project(DbObject, Updateable, Deletable):
132132
# Relationships
133133
created_by = Relationship.ToOne("User", False, "created_by")
134134
organization = Relationship.ToOne("Organization", False)
135-
labeling_frontend = Relationship.ToOne("LabelingFrontend")
135+
labeling_frontend = Relationship.ToOne(
136+
"LabelingFrontend",
137+
config=Relationship.Config(disconnect_supported=False))
136138
labeling_frontend_options = Relationship.ToMany(
137139
"LabelingFrontendOptions", False, "labeling_frontend_options")
138140
labeling_parameter_overrides = Relationship.ToMany(

libs/labelbox/tests/integration/test_labeling_frontend.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
from labelbox import LabelingFrontend
21
import pytest
32

3+
from labelbox import LabelingFrontend
4+
from labelbox.exceptions import OperationNotSupportedException
5+
46

57
def test_get_labeling_frontends(client):
68
filtered_frontends = list(
@@ -18,5 +20,5 @@ def test_labeling_frontend_connecting_to_project(project):
1820
project.labeling_frontend.connect(default_labeling_frontend)
1921
assert project.labeling_frontend() == default_labeling_frontend
2022

21-
project.labeling_frontend.disconnect(default_labeling_frontend)
22-
assert project.labeling_frontend() == None
23+
with pytest.raises(OperationNotSupportedException):
24+
project.labeling_frontend.disconnect(default_labeling_frontend)

0 commit comments

Comments
 (0)