diff --git a/labelbox/schema/project.py b/labelbox/schema/project.py index 6fa1f5b10..e2a6927c3 100644 --- a/labelbox/schema/project.py +++ b/labelbox/schema/project.py @@ -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" + 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, @@ -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") diff --git a/tests/integration/test_toggle_mal.py b/tests/integration/test_toggle_mal.py new file mode 100644 index 000000000..7cf84614c --- /dev/null +++ b/tests/integration/test_toggle_mal.py @@ -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 \ No newline at end of file