def test_example_add_new_label_fields(self):
    dataset = foz.load_zoo_dataset('quickstart', max_samples=10).clone()
    view = dataset.take(1)
    anno_key = 'cvat_new_field'
    results = view.annotate(anno_key, label_field='new_classifications', label_type='classifications', classes=['dog', 'cat', 'person'])
    self.assertIsNotNone(dataset.get_annotation_info(anno_key))
    api = results.connect_to_api()
    task_id = results.task_ids[0]
    _create_annotation(api, task_id, tag='dog')
    dataset.load_annotations(anno_key, cleanup=True)
    tags = view.first().new_classifications.classifications
    num_tags = len(tags)
    self.assertEqual(num_tags, 1)
    self.assertEqual(tags[0].label, 'dog')
    anno_key = 'cvat_new_field_schema'
    label_schema = {'new_classifications_2': {'type': 'classifications', 'classes': ['dog', 'cat', 'person']}}
    results = view.annotate(anno_key, label_schema=label_schema)
    self.assertIsNotNone(dataset.get_annotation_info(anno_key))
    api.close()
    api = results.connect_to_api()
    task_id = results.task_ids[0]
    _create_annotation(api, task_id, tag='person')
    dataset.load_annotations(anno_key, cleanup=True)
    tags = view.first().new_classifications_2.classifications
    num_tags = len(tags)
    self.assertEqual(num_tags, 1)
    self.assertEqual(tags[0].label, 'person')
    dataset.load_annotations(anno_key, cleanup=True)
    api.close()
def test_example_add_new_label_fields(self):
    dataset = foz.load_zoo_dataset('quickstart', max_samples=10).clone()
    view = dataset.take(1)
    anno_key = 'cvat_new_field'
    results = view.annotate(anno_key, label_field='new_classifications', label_type='classifications', classes=['dog', 'cat', 'person'])
    self.assertIsNotNone(dataset.get_annotation_info(anno_key))
    api = results.connect_to_api()
    task_id = results.task_ids[0]
    _create_annotation(api, task_id, tag='dog')
    dataset.load_annotations(anno_key, cleanup=True)
    tags = view.first().new_classifications.classifications
    num_tags = len(tags)
    self.assertEqual(num_tags, 1)
    self.assertEqual(tags[0].label, 'dog')
    anno_key = 'cvat_new_field_schema'
    label_schema = {'new_classifications_2': {'type': 'classifications', 'classes': ['dog', 'cat', 'person']}}
    results = view.annotate(anno_key, label_schema=label_schema)
    self.assertIsNotNone(dataset.get_annotation_info(anno_key))
    api.close()
    api = results.connect_to_api()
    task_id = results.task_ids[0]
    _create_annotation(api, task_id, tag='person')
    dataset.load_annotations(anno_key, cleanup=True)
    tags = view.first().new_classifications_2.classifications
    num_tags = len(tags)
    self.assertEqual(num_tags, 1)
    self.assertEqual(tags[0].label, 'person')
    dataset.load_annotations(anno_key, cleanup=True)
    api.close()