Пример #1
0
    def test_exiting_context_manager_of_cloud_dataset_updates_cloud_metadata(
            self):
        """Test that cloud metadata for a cloud dataset is updated on exit of the dataset context manager."""
        dataset_path = self._create_nested_cloud_dataset()
        dataset = Dataset(path=dataset_path, recursive=True)

        with dataset:
            dataset.tags = {"cat": "dog"}
            dataset.labels = {"animals"}

        reloaded_dataset = Dataset(path=dataset_path)
        self.assertEqual(reloaded_dataset.id, dataset.id)
        self.assertEqual(reloaded_dataset.tags, {"cat": "dog"})
        self.assertEqual(reloaded_dataset.labels, {"animals"})
Пример #2
0
    def test_update_cloud_metadata(self):
        """Test that metadata for a cloud dataset can be stored in the cloud and used on re-instantiation of the same
        dataset.
        """
        dataset_path = self._create_nested_cloud_dataset()
        dataset = Dataset(path=dataset_path)
        self.assertEqual(dataset.tags, {})

        dataset.tags = {"some": "tags"}
        dataset.update_cloud_metadata()

        dataset_reloaded = Dataset(path=dataset_path)
        self.assertEqual(dataset.id, dataset_reloaded.id)
        self.assertEqual(dataset.tags, dataset_reloaded.tags)
        self.assertEqual(dataset.labels, dataset_reloaded.labels)
        self.assertEqual(dataset.hash_value, dataset_reloaded.hash_value)
Пример #3
0
    def test_exiting_context_manager_of_local_dataset_updates_local_metadata(
            self):
        """Test that local metadata for a local dataset is updated on exit of the dataset context manager."""
        with tempfile.TemporaryDirectory() as temporary_directory:
            self._create_files_and_nested_subdirectories(temporary_directory)

            dataset = Dataset(path=temporary_directory, recursive=True)

            with dataset:
                dataset.tags = {"cat": "dog"}
                dataset.labels = {"animals"}

            reloaded_dataset = Dataset(path=temporary_directory,
                                       recursive=True)
            self.assertEqual(reloaded_dataset.id, dataset.id)
            self.assertEqual(reloaded_dataset.tags, {"cat": "dog"})
            self.assertEqual(reloaded_dataset.labels, {"animals"})