Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion labelbox/schema/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,34 @@ def create_prediction(self, label, data_row, prediction_model=None):
res = self.client.execute(query_str, params)
return Prediction(self.client, res["createPrediction"])

def enable_model_assisted_labeling(self, toggle: bool=True) -> bool:
""" Turns model assisted labeling either on or off based on input

Args:
toggle (Boolean): True or False boolean
Returns:
True if toggled on or False if toggled off
"""

project_param = "project_id"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think these can just go into params rather than being pulled out up here

show_param = "show"

query_str = """mutation toggle_model_assisted_labelingPyApi($%s: ID!, $%s: Boolean!) {
project(where: {id: $%s }) {
showPredictionsToLabelers(show: $%s) {
id, showingPredictionsToLabelers
}
}
}""" % (project_param, show_param,project_param, show_param)

params = {
project_param: self.uid,
show_param: toggle
}

res = self.client.execute(query_str, params)
return res["project"]["showPredictionsToLabelers"]["showingPredictionsToLabelers"]

def upload_annotations(
self,
name: str,
Expand Down Expand Up @@ -432,7 +460,6 @@ def _is_url_valid(url: Union[str, Path]) -> bool:
raise ValueError(
f'Invalid annotations given of type: {type(annotations)}')


class LabelingParameterOverride(DbObject):
priority = Field.Int("priority")
number_of_labels = Field.Int("number_of_labels")
Expand Down
13 changes: 13 additions & 0 deletions tests/integration/test_toggle_mal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from labelbox import Client
from labelbox import Project
import pytest

def test_enable_model_assisted_labeling(project):
response = project.enable_model_assisted_labeling()
assert response == True

response = project.enable_model_assisted_labeling(True)
assert response == True

response = project.enable_model_assisted_labeling(False)
assert response == False