Skip to content

Commit 708ba5f

Browse files
author
Matt Sokoloff
committed
wip
1 parent 9fca0f7 commit 708ba5f

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

labelbox/schema/annotation_import.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ def refresh(self) -> None:
130130
"""Synchronizes values of all fields with the database.
131131
"""
132132
cls = type(self)
133-
res = cls.from_name(self.client, self.parent_id, self.name)
133+
res = cls.from_name(self.client, self.parent_id, self.name, as_json = True)
134134
self._set_field_values(res)
135135

136136
@classmethod
137-
def from_name(cls, client: "labelbox.Client", parent_id: str, name: str):
137+
def from_name(cls, client: "labelbox.Client", parent_id: str, name: str, as_json: bool = False):
138138
raise NotImplementedError("Inheriting class must override")
139139

140140
@property
@@ -225,7 +225,7 @@ def create_from_url(cls, client: "labelbox.Client", model_run_id: str,
225225

226226
@classmethod
227227
def from_name(cls, client: "labelbox.Client", model_run_id: str,
228-
name: str) -> "MEAPredictionImport":
228+
name: str, as_json: bool = False) -> "MEAPredictionImport":
229229
"""
230230
Retrieves an MEA import job.
231231
@@ -249,7 +249,9 @@ def from_name(cls, client: "labelbox.Client", model_run_id: str,
249249
if response is None:
250250
raise labelbox.exceptions.ResourceNotFoundError(
251251
MEAPredictionImport, params)
252-
252+
response = response["modelErrorAnalysisPredictionImport"]
253+
if as_json:
254+
return response
253255
return cls(client, response["modelErrorAnalysisPredictionImport"])
254256

255257
@classmethod
@@ -264,7 +266,7 @@ def _get_url_mutation(cls) -> str:
264266

265267
@classmethod
266268
def _get_file_mutation(cls) -> str:
267-
return """mutation create%sPyApi($modelRunId : ID!, $name: String!, $file: Upload!, $contentLength: Int!) {
269+
return """mutation createMeaPredictionImportPyApi($modelRunId : ID!, $name: String!, $file: Upload!, $contentLength: Int!) {
268270
createModelErrorAnalysisPredictionImport(data: {
269271
modelRunId: $modelRunId name: $name filePayload: { file: $file, contentLength: $contentLength}
270272
}) {%s}
@@ -377,7 +379,7 @@ def create_from_url(cls, client: "labelbox.Client", project_id: str,
377379

378380
@classmethod
379381
def from_name(cls, client: "labelbox.Client", project_id: str,
380-
name: str) -> "MALPredictionImport":
382+
name: str, as_json: bool = False) -> "MALPredictionImport":
381383
"""
382384
Retrieves an MAL import job.
383385
@@ -401,12 +403,14 @@ def from_name(cls, client: "labelbox.Client", project_id: str,
401403
if response is None:
402404
raise labelbox.exceptions.ResourceNotFoundError(
403405
MALPredictionImport, params)
404-
406+
response = response["modelAssistedLabelingPredictionImport"]
407+
if as_json:
408+
return response
405409
return cls(client, response["modelAssistedLabelingPredictionImport"])
406410

407411
@classmethod
408412
def _get_url_mutation(cls) -> str:
409-
return """mutation createMeaPredictionImportPyApi($projectId : ID!, $name: String!, $fileUrl: String!) {
413+
return """mutation createMALPredictionImportPyApi($projectId : ID!, $name: String!, $fileUrl: String!) {
410414
createModelAssistedLabelingPredictionImport(data: {
411415
projectId: $projectId
412416
name: $name
@@ -416,7 +420,7 @@ def _get_url_mutation(cls) -> str:
416420

417421
@classmethod
418422
def _get_file_mutation(cls) -> str:
419-
return """mutation create%sPyApi($projectId : ID!, $name: String!, $file: Upload!, $contentLength: Int!) {
423+
return """mutation createMALPredictionImportPyApi($projectId : ID!, $name: String!, $file: Upload!, $contentLength: Int!) {
420424
createModelAssistedLabelingPredictionImport(data: {
421425
projectId: $projectId name: $name filePayload: { file: $file, contentLength: $contentLength}
422426
}) {%s}

tests/integration/bulk_import/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from labelbox.schema.bulk_import_request import BulkImportRequest
12
import uuid
23

34
import pytest
@@ -303,7 +304,7 @@ def model_run(client, rand_gen, configured_project, annotation_submit_fn,
303304
configured_project.enable_model_assisted_labeling()
304305
ontology = configured_project.ontology()
305306

306-
upload_task = MALPredictionImport.create_from_objects(
307+
upload_task = BulkImportRequest.create_from_objects(
307308
client, configured_project.uid, f'mal-import-{uuid.uuid4()}',
308309
model_run_predictions)
309310
upload_task.wait_until_done()

0 commit comments

Comments
 (0)