Skip to content

Commit 0b0b70b

Browse files
author
Val Brodsky
committed
Use _create_project(), not create_project() for create_offline_model_evaluation_project
Fixing a typo
1 parent dbb15f9 commit 0b0b70b

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

libs/labelbox/src/labelbox/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ def create_offline_model_evaluation_project(self, **kwargs) -> Project:
840840
kwargs.pop("append_to_existing_dataset", None)
841841
kwargs.pop("data_row_count", None)
842842

843-
return self.create_project(**kwargs)
843+
return self._create_project(**kwargs)
844844

845845
def _create_project(self, **kwargs) -> Project:
846846
auto_audit_percentage = kwargs.get("auto_audit_percentage")

libs/labelbox/src/labelbox/exceptions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ class ProcessingWaitTimeout(Exception):
153153

154154

155155
def _error_message_for_unparsed_graphql_error(error_string: str) -> str:
156+
"""
157+
Since our client only parses certain graphql errors, this function is used to
158+
extract the error message from the error string when the error is not
159+
parsed by the client.
160+
"""
156161
# Regex to find the message content
157162
pattern = r"'message': '([^']+)'"
158163
# Search for the pattern in the error string

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,8 +1272,6 @@ def add_model_config(self, model_config_id: str) -> str:
12721272
try:
12731273
result = self.client.execute(query, params)
12741274
except LabelboxError as e:
1275-
# unfortunately, this is the type of errors our client does not deal with and so the error message is not in the same format as the other errors
1276-
# needs custom parsing
12771275
error_content = _error_message_for_unparsed_graphql_error(e.message)
12781276
raise LabelboxError(message=error_content) from e
12791277

@@ -1305,12 +1303,16 @@ def delete_project_model_config(self, project_model_config_id: str) -> bool:
13051303
return result["deleteProjectModelConfig"]["success"]
13061304

13071305
def set_project_model_setup_complete(self) -> bool:
1308-
""" Checks if the model setup is complete for this project.
1306+
"""
1307+
Sets the model setup is complete for this project.
1308+
Once the project is marked as "setup complete", a user can not add / modify delete existing project model configs.
13091309
13101310
Returns:
13111311
bool, indicates if the model setup is complete.
13121312
13131313
NOTE: This method should only be used for live model evaluation projects.
1314+
It will throw exception for all other types of projects.
1315+
User Project is_chat_evaluation() method to check if the project is a live model evaluation project.
13141316
"""
13151317
query = """mutation SetProjectModelSetupCompletePyApi($projectId: ID!) {
13161318
setProjectModelSetupComplete(where: {id: $projectId}, data: {modelSetupComplete: true}) {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import pytest
2+
3+
from labelbox.exceptions import _error_message_for_unparsed_graphql_error
4+
5+
6+
@pytest.mark.parametrize('exception_message, expected_result', [
7+
("Unparsed errors on query execution: [{'message': 'Cannot create model config for project because model setup is complete'",
8+
"Cannot create model config for project because model setup is complete"),
9+
("blah blah blah", "Unknown error"),
10+
])
11+
def test_client_unparsed_exception_messages(exception_message, expected_result):
12+
assert _error_message_for_unparsed_graphql_error(
13+
exception_message) == expected_result

0 commit comments

Comments
 (0)