@@ -118,35 +118,6 @@ def _fetch_remote_ndjson(self, url: str) -> List[Dict[str, Any]]:
118
118
response .raise_for_status ()
119
119
return ndjson .loads (response .text )
120
120
121
- @classmethod
122
- def _from_name (cls ,
123
- client : "labelbox.Client" ,
124
- parent_id : str ,
125
- name : str ,
126
- raw = False
127
- ) -> Union ["MEAPredictionImport" , "MALPredictionImport" ]:
128
- query_str = """query getImportPyApi($parent_id : ID!, $name: String!) {
129
- annotationImport(
130
- where: {%s: $parent_id, name: $name}){
131
- __typename
132
- ... on ModelAssistedLabelingPredictionImport {%s}
133
- ... on ModelErrorAnalysisPredictionImport {%s}
134
- }}""" % \
135
- (
136
- cls ._parent_id_field ,
137
- query .results_query_part (MALPredictionImport ),
138
- query .results_query_part (MEAPredictionImport )
139
- )
140
-
141
- response = client .execute (query_str , {
142
- 'name' : name ,
143
- 'parent_id' : parent_id
144
- })
145
- if raw :
146
- return response ['annotationImport' ]
147
-
148
- return cls (client , response ['annotationImport' ])
149
-
150
121
@staticmethod
151
122
def _make_file_name (parent_id : str , name : str ) -> str :
152
123
return f"{ parent_id } __{ name } .ndjson"
@@ -269,12 +240,26 @@ def create_from_url(cls, client: "labelbox.Client", model_run_id: str,
269
240
parent_id = model_run_id ,
270
241
name = name ,
271
242
url = url )
272
-
243
+
273
244
@classmethod
274
245
def from_name (
275
246
cls , client : "labelbox.Client" , model_run_id : str ,
276
- name : str ) -> Union ["MEAPredictionImport" , "MALPredictionImport" ]:
277
- return cls ._from_name (client , model_run_id , name )
247
+ name : str ) -> "MEAPredictionImport" :
248
+
249
+ query_str = """query getModelErrorAnalysisPredictionImportPyApi($modelRunId : ID!, $name: String!) {
250
+ modelErrorAnalysisPredictionImport(
251
+ where: {modelRunId: $modelRunId, name: $name}){
252
+ %s
253
+ }}""" % query .results_query_part (cls )
254
+ params = {
255
+ "modelRunId" : model_run_id ,
256
+ "name" : name ,
257
+ }
258
+ response = client .execute (query_str , params )
259
+ if response is None :
260
+ raise labelbox .exceptions .ResourceNotFoundError (MEAPredictionImport , params )
261
+
262
+ return response
278
263
279
264
280
265
class MALPredictionImport (AnnotationImport ):
@@ -310,5 +295,19 @@ def create_from_url(cls, client: "labelbox.Client", project_id: str,
310
295
@classmethod
311
296
def from_name (
312
297
cls , client : "labelbox.Client" , project_id : str ,
313
- name : str ) -> Union ["MEAPredictionImport" , "MALPredictionImport" ]:
314
- return cls ._from_name (client , project_id , name )
298
+ name : str ) -> "MALPredictionImport" :
299
+
300
+ query_str = """query getModelAssistedLabelingPredictionImportPyApi($projectId : ID!, $name: String!) {
301
+ modelAssistedLabelingPredictionImport(
302
+ where: {projectId: $projectId, name: $name}){
303
+ %s
304
+ }}""" % query .results_query_part (cls )
305
+ params = {
306
+ "projectId" : project_id ,
307
+ "name" : name ,
308
+ }
309
+ response = client .execute (query_str , params )
310
+ if response is None :
311
+ raise labelbox .exceptions .ResourceNotFoundError (MALPredictionImport , params )
312
+
313
+ return response
0 commit comments