MALPredictionImport.create_from_objects: ERROR = Ontology does not contain name

Hey.
I am having a silly problem with importing mask annotations to my project.
My code is setup as follows:

client = lb.Client(API_KEY)
dataset = client.get_dataset(DATASET_ID)
project = client.create_project(name="MAL-Segformer",
                                media_type=lb.MediaType.Image)

ontology = next(client.get_ontologies("Manometer"))
project.connect_ontology(ontology)

task = project.create_batches_from_dataset(
        name_prefix="MAL-Segformer-dataset",
        dataset_id = dataset.uid,
        priority=5)
print("Errors: ", task.errors())
print("Result: ", task.result())
data_rows = dataset.data_rows()
for data_row in data_rows:
    filename = data_row.external_id
    print(filename)
    uid = data_row.uid
    mask_url = MASK_URL + filename
    
    mask_data_1 = lb_types.MaskData(url=mask_url)
    
    cp_mask = []

    cp_mask.append(
        lb_types.ObjectAnnotation(
            name = 'Manometer',
            value = lb_types.Mask(mask=mask_data_1, color=color))
        )

    annotations = cp_mask

    label = [lb_types.Label(data={'uid':uid}, 
                            annotations=annotations)]
    

    upload_job = MALPredictionImport.create_from_objects(
        client = client,
        project_id = project.uid,
        name = "label_import_job"+str(uuid.uuid4()),
        predictions = label)

    upload_job.wait_till_done()

    print("Errors:", upload_job.errors)
  

And the output is:
`Errors: [{‘uuid’: ‘XXXXXX’, ‘dataRow’: {‘id’: None, ‘globalKey’: None}, ‘status’: ‘FAILURE’, ‘errors’: [{‘name’: ‘ValidationError’, ‘message’: ‘Ontology does not contain name: Manometer.’, ‘additionalInfo’: None}]}]´

The data rows are available in the dataset. The AWS-S3 connection is setup without errors. So i do not know how I can fix this. Does anyone have an idea?

Hey @m.m.rocha Not a silly problem at all. In fact, this might be on our side. The team is tracing the issue and will update you shortly.

Thanks for your patience,
John

1 Like

Sounds like it’s fixed. Can you retry your import now?

Hey @John
Thanks for the fast reply.
I ran it again, and I get this error now:

{
	"name": "ValueError",
	"message": "Import failed.",
	"stack": "---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[5], line 36
     28 # upload_job = MALPredictionImport.create_from_objects(
     29 #     client = client,
     30 #     project_id = PROJECT_ID,
     31 #     name = \"mal_job\"+str(uuid.uuid4()),
     32 #     predictions = label)
     34 upload_job.wait_till_done()
---> 36 print(\"Errors:\", upload_job.errors)
     37 break

File ~/miniconda3/envs/VFSSFramework/lib/python3.13/site-packages/labelbox/schema/annotation_import.py:75, in AnnotationImport.errors(self)
     66 \"\"\"
     67 Errors for each individual annotation uploaded. This is a subset of statuses
     68 
   (...)
     72 * This information will expire after 24 hours.
     73 \"\"\"
     74 self.wait_until_done()
---> 75 return self._fetch_remote_ndjson(self.error_file_url)

File ~/miniconda3/envs/VFSSFramework/lib/python3.13/site-packages/labelbox/schema/annotation_import.py:161, in AnnotationImport._fetch_remote_ndjson(self, url)
    153 \"\"\"
    154 Fetches the remote ndjson file and caches the results.
    155 Args:
   (...)
    158     ndjson as a list of dicts.
    159 \"\"\"
    160 if self.state == AnnotationImportState.FAILED:
--> 161     raise ValueError(\"Import failed.\")
    163 response = requests.get(url)
    164 response.raise_for_status()

ValueError: Import failed."
}

Hey, @m.m.rocha ,

I checked briefly your import, since you import masks are you sure they are accessible? (since the URL point to an S3 bucket).

1 Like

Another thing I remembered: I’ve also seen the import fail with a message like that if the masks aren’t the same resolution as the image in the data row.

Dear @John and @ptancre, thanks a lot for your crucial help.
The initial problem was fixed at the time that @John indicated. I thought I had the S3 connected properly but that was not the case. I had to make the annotations completely publicly available so that it could work. Now that I have done it, everything works.
Thanks for your help.

2 Likes