File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
libs/labelbox/src/labelbox/schema Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change
1
+ import re
1
2
import json
2
3
import logging
3
4
from string import Template
@@ -1268,7 +1269,22 @@ def add_model_config(self, model_config_id: str) -> str:
1268
1269
"projectId" : self .uid ,
1269
1270
"modelConfigId" : model_config_id ,
1270
1271
}
1271
- result = self .client .execute (query , params )
1272
+ try :
1273
+ result = self .client .execute (query , params )
1274
+ 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
1277
+ error_string = e .message
1278
+ # Regex to find the message content
1279
+ pattern = r"'message': '([^']+)'"
1280
+ # Search for the pattern in the error string
1281
+ match = re .search (pattern , error_string )
1282
+ if match :
1283
+ error_content = match .group (1 )
1284
+ else :
1285
+ error_content = "Unknown error"
1286
+ raise LabelboxError (message = error_content ) from e
1287
+
1272
1288
if not result :
1273
1289
raise ResourceNotFoundError (ModelConfig , params )
1274
1290
return result ["createProjectModelConfig" ]["projectModelConfigId" ]
You can’t perform that action at this time.
0 commit comments