Пример #1
0
    def __upload_cvat_images(self, images_paths: List[Path], dataset_name: str,
                             max_workers: int) -> Tuple[str, Dict[str, str]]:
        """
        This function does not create any image groups yet.
        Returns:
            * The created dataset_hash
            * A map from an image title to the image hash which is stored in the DB.
        """

        short_names = list(map(lambda x: x.name, images_paths))
        file_path_strings = list(map(lambda x: str(x), images_paths))
        dataset = self.create_dataset(dataset_name,
                                      StorageLocation.CORD_STORAGE)

        dataset_hash = dataset.dataset_hash

        dataset_api_key: DatasetAPIKey = self.create_dataset_api_key(
            dataset_hash, dataset_name + " - Full Access API Key",
            [DatasetScope.READ, DatasetScope.WRITE])

        client = EncordClient.initialise(
            dataset_hash,
            dataset_api_key.api_key,
            domain=self.user_config.domain,
        )

        signed_urls = client._querier.basic_getter(SignedImagesURL,
                                                   uid=short_names)
        upload_to_signed_url_list(file_path_strings, signed_urls,
                                  client._querier, Image, max_workers)

        image_title_to_image_hash_map = dict(
            map(lambda x: (x.title, x.data_hash), signed_urls))

        return dataset_hash, image_title_to_image_hash_map
Пример #2
0
 def get_dataset_client(
         self, dataset_hash: str,
         **kwargs) -> Union[EncordClientProject, EncordClientDataset]:
     dataset_api_key: DatasetAPIKey = self.get_or_create_dataset_api_key(
         dataset_hash)
     return EncordClient.initialise(dataset_hash, dataset_api_key.api_key,
                                    **kwargs)
 def test_2(self):
     with self.assertRaises(AuthenticationError) as excinfo:
         EncordClient.initialise(api_key=LABEL_READ_WRITE_KEY)
     self.assertEqual("Project ID or dataset ID not provided",
                      str(excinfo.exception))
 def test_1(self):
     with self.assertRaises(AuthenticationError) as excinfo:
         EncordClient.initialise(PROJECT_ID)
     self.assertEqual("API key not provided", str(excinfo.exception))
 def setUpClass(cls):
     super(UnitTests, cls).setUpClass()
     cls.read_c = EncordClient.initialise(PROJECT_ID, LABEL_READ_KEY)
     cls.write_c = EncordClient.initialise(PROJECT_ID, LABEL_WRITE_KEY)
     cls.rw_c = EncordClient.initialise(PROJECT_ID, LABEL_READ_WRITE_KEY)
     cls.dt_c = EncordClient.initialise(DATASET_ID, DATASET_KEY)
Пример #6
0
def test_get_label_with_write_key_throws_operation_not_allowed_exception(keys):
    client = EncordClient.initialise(keys[0], LABEL_WRITE_KEY)

    with pytest.raises(
            expected_exception=encord.exceptions.OperationNotAllowed):
        client.get_label_row(keys[2])
Пример #7
0
def test_invalid_resource_id(keys):
    with pytest.raises(
            expected_exception=encord.exceptions.AuthenticationError):
        EncordClient.initialise(uuid.uuid4(), keys[1])
Пример #8
0
def test_invalid_key(keys):
    with pytest.raises(
            expected_exception=encord.exceptions.AuthenticationError):
        EncordClient.initialise(keys[0], uuid.uuid4())
Пример #9
0
 def get_project_client(
         self, project_hash: str,
         **kwargs) -> Union[EncordClientProject, EncordClientDataset]:
     project_api_key: str = self.get_or_create_project_api_key(project_hash)
     return EncordClient.initialise(project_hash, project_api_key, **kwargs)
Пример #10
0
def test_missing_key(keys):
    with pytest.raises(expected_exception=encord.exceptions.AuthenticationError
                       ) as excinfo:
        EncordClient.initialise(resource_id=keys[0])

    assert excinfo.value.message == "API key not provided"
Пример #11
0
def test_initialise_with_config(keys):
    config = EncordConfig(resource_id=keys[0], api_key=keys[1])
    assert isinstance(EncordClient.initialise_with_config(config),
                      EncordClient)
Пример #12
0
def test_initialise(keys):
    assert isinstance(
        EncordClient.initialise(resource_id=keys[0], api_key=keys[1]),
        EncordClient)
Пример #13
0
def client(keys):
    return EncordClient.initialise(resource_id=keys[0], api_key=keys[1])
Пример #14
0
def test_object_interpolation_with_polygons(keys):
    client = EncordClient.initialise(keys[0], LABEL_READ_KEY)
    objects = client.object_interpolation(
        INTERPOLATION_TEST_BLURB, ["60f75ddb-aa68-4654-8c85-f6959dbb62eb"])
    assert isinstance(objects, dict)
Пример #15
0
def test_save_label_with_read_key_throws_operation_not_allowed_exception(keys):
    client = EncordClient.initialise(keys[0], LABEL_READ_KEY)

    with pytest.raises(
            expected_exception=encord.exceptions.OperationNotAllowed):
        client.save_label_row(keys[2], TEST_BLURB)
 def test_3(self):
     with self.assertRaises(AuthenticationError):
         client = EncordClient.initialise(PROJECT_ID, uuid.uuid4())
 def test_4(self):
     with self.assertRaises(AuthenticationError):
         client = EncordClient.initialise(uuid.uuid4(),
                                          LABEL_READ_WRITE_KEY)
Пример #18
0
def test_missing_resource_id(keys):
    with pytest.raises(expected_exception=encord.exceptions.AuthenticationError
                       ) as excinfo:
        EncordClient.initialise(api_key=keys[1])

    assert excinfo.value.message == "Project ID or dataset ID not provided"