def test_requires_caching(self):
    self.assertFalse(dataset_providers.Task('nosupports_cache', output_features=self.DEFAULT_OUTPUT_FEATURES, source=self.function_source, preprocessors=[preprocessors.tokenize]).requires_caching)
    self.assertFalse(dataset_providers.Task('supports_cache', output_features=self.DEFAULT_OUTPUT_FEATURES, source=self.function_source, preprocessors=[preprocessors.tokenize, dataset_providers.CacheDatasetPlaceholder()]).requires_caching)
    task = dataset_providers.Task('requires_cache', output_features=self.DEFAULT_OUTPUT_FEATURES, source=self.function_source, preprocessors=[dataset_providers.CacheDatasetPlaceholder(required=True), preprocessors.tokenize])
    self.assertTrue(task.requires_caching)
    with self.assertRaisesWithLiteralMatch(ValueError, "Task 'requires_cache' requires caching, but was called with `use_cached=False`."):
        task.get_dataset({'inputs': 512, 'targets': 512}, use_cached=False)
    with self.assertRaisesWithLiteralMatch(AssertionError, "'requires_cache' does not exist in any of the task cache directories."):
        task.get_dataset({'inputs': 512, 'targets': 512}, use_cached=True)
def test_requires_caching(self):
    self.assertFalse(dataset_providers.Task('nosupports_cache', output_features=self.DEFAULT_OUTPUT_FEATURES, source=self.function_source, preprocessors=[preprocessors.tokenize]).requires_caching)
    self.assertFalse(dataset_providers.Task('supports_cache', output_features=self.DEFAULT_OUTPUT_FEATURES, source=self.function_source, preprocessors=[preprocessors.tokenize, dataset_providers.CacheDatasetPlaceholder()]).requires_caching)
    task = dataset_providers.Task('requires_cache', output_features=self.DEFAULT_OUTPUT_FEATURES, source=self.function_source, preprocessors=[dataset_providers.CacheDatasetPlaceholder(required=True), preprocessors.tokenize])
    self.assertTrue(task.requires_caching)
    with self.assertRaisesWithLiteralMatch(ValueError, "Task 'requires_cache' requires caching, but was called with `use_cached=False`."):
        task.get_dataset({'inputs': 512, 'targets': 512}, use_cached=False)
    with self.assertRaisesWithLiteralMatch(AssertionError, "'requires_cache' does not exist in any of the task cache directories."):
        task.get_dataset({'inputs': 512, 'targets': 512}, use_cached=True)