def test_upload(self):
    dataset = foz.load_zoo_dataset('quickstart', max_samples=1).clone()
    prev_ids = dataset.values('ground_truth.detections.id', unwind=True)
    anno_key = 'anno_key'
    results = dataset.annotate(anno_key, backend='cvat', label_field='ground_truth')
    api = results.connect_to_api()
    task_id = results.task_ids[0]
    shape_id = dataset.first().ground_truth.detections[0].id
    self.assertIsNotNone(_get_shape(api, task_id, shape_id))
    sample_id = list(list(results.frame_id_map.values())[0].values())[0]['sample_id']
    self.assertEqual(sample_id, dataset.first().id)
    api.close()
    dataset.load_annotations(anno_key, cleanup=True)
    self.assertListEqual(prev_ids, dataset.values('ground_truth.detections.id', unwind=True))
    dataset = foz.load_zoo_dataset('quickstart-video', max_samples=1).clone()
    prev_ids = dataset.values('frames.detections.detections.id', unwind=True)
    anno_key = 'anno_key'
    results = dataset.annotate(anno_key, backend='cvat', label_field='frames.detections')
    api = results.connect_to_api()
    task_id = results.task_ids[0]
    shape_id = dataset.first().frames[1].detections.detections[0].id
    self.assertIsNotNone(_get_shape(api, task_id, shape_id))
    sample_id = list(list(results.frame_id_map.values())[0].values())[0]['sample_id']
    self.assertEqual(sample_id, dataset.first().id)
    api.close()
    dataset.load_annotations(anno_key, cleanup=True)
    self.assertListEqual(prev_ids, dataset.values('frames.detections.detections.id', unwind=True))
def test_upload(self):
    dataset = foz.load_zoo_dataset('quickstart', max_samples=1).clone()
    prev_ids = dataset.values('ground_truth.detections.id', unwind=True)
    anno_key = 'anno_key'
    results = dataset.annotate(anno_key, backend='cvat', label_field='ground_truth')
    api = results.connect_to_api()
    task_id = results.task_ids[0]
    shape_id = dataset.first().ground_truth.detections[0].id
    self.assertIsNotNone(_get_shape(api, task_id, shape_id))
    sample_id = list(list(results.frame_id_map.values())[0].values())[0]['sample_id']
    self.assertEqual(sample_id, dataset.first().id)
    api.close()
    dataset.load_annotations(anno_key, cleanup=True)
    self.assertListEqual(prev_ids, dataset.values('ground_truth.detections.id', unwind=True))
    dataset = foz.load_zoo_dataset('quickstart-video', max_samples=1).clone()
    prev_ids = dataset.values('frames.detections.detections.id', unwind=True)
    anno_key = 'anno_key'
    results = dataset.annotate(anno_key, backend='cvat', label_field='frames.detections')
    api = results.connect_to_api()
    task_id = results.task_ids[0]
    shape_id = dataset.first().frames[1].detections.detections[0].id
    self.assertIsNotNone(_get_shape(api, task_id, shape_id))
    sample_id = list(list(results.frame_id_map.values())[0].values())[0]['sample_id']
    self.assertEqual(sample_id, dataset.first().id)
    api.close()
    dataset.load_annotations(anno_key, cleanup=True)
    self.assertListEqual(prev_ids, dataset.values('frames.detections.detections.id', unwind=True))