Skip to content

Commit 6bcafe4

Browse files
Alfonso CastañoThe TensorFlow Datasets Authors
authored andcommitted
Disable GCS loading by default
PiperOrigin-RevId: 696820685
1 parent 40cc288 commit 6bcafe4

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

tensorflow_datasets/core/utils/gcs_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
GCS_DATASET_INFO_DIR = 'dataset_info'
3232
GCS_DATASETS_DIR = 'datasets'
3333

34-
_is_gcs_disabled = False
34+
_is_gcs_disabled = True
3535

3636

3737
# Exception raised when GCS isn't available

tensorflow_datasets/core/utils/gcs_utils_test.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,18 @@
1919
from tensorflow_datasets.core.utils import gcs_utils
2020
from tensorflow_datasets.testing import test_utils
2121

22-
2322
import os
2423
import tempfile
2524
import tensorflow_datasets as tfds
2625
class GcsUtilsTest(testing.TestCase):
2726
DO_NOT_APPLY_FIXTURES = [test_utils.disable_gcs_access]
2827
def test_is_dataset_accessible(self):
28+
gcs_utils._is_gcs_disabled = False
2929
self.assertTrue(gcs_utils.is_dataset_on_gcs('mnist/1.0.0'))
3030
self.assertFalse(gcs_utils.is_dataset_on_gcs('non_dataset/1.0.0'))
31+
gcs_utils._is_gcs_disabled = True
3132
def test_download_dataset(self):
33+
gcs_utils._is_gcs_disabled = False
3234
files = [
3335
'gs://tfds-data/dataset_info/mnist/2.0.0/dataset_info.json',
3436
'gs://tfds-data/dataset_info/mnist/2.0.0/image.image.json',
@@ -50,6 +52,7 @@ def test_download_dataset(self):
5052
'image.image.json',
5153
],
5254
)
55+
gcs_utils._is_gcs_disabled = True
5356
def test_mnist(self):
5457
mnist = tfds.image_classification.MNIST(
5558
data_dir=gcs_utils.gcs_path('datasets')
@@ -65,7 +68,7 @@ class GcsUtilsDisabledTest(testing.TestCase):
6568

6669
def test_is_dataset_accessible(self):
6770
is_ds_on_gcs = gcs_utils.is_dataset_on_gcs('mnist/1.0.0')
68-
self.assertTrue(is_ds_on_gcs)
71+
self.assertFalse(is_ds_on_gcs)
6972

7073

7174
if __name__ == '__main__':

tensorflow_datasets/testing/test_utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,9 @@ def disable_gcs_access() -> Iterator[None]:
444444
), mock.patch(
445445
'tensorflow_datasets.core.utils.gcs_utils.is_dataset_on_gcs',
446446
_GCS_ACCESS_FNS['dummy_datasets'],
447+
), mock.patch(
448+
'tensorflow_datasets.core.utils.gcs_utils._is_gcs_disabled',
449+
True,
447450
):
448451
yield
449452

@@ -457,6 +460,9 @@ def enable_gcs_access() -> Iterator[None]:
457460
), mock.patch(
458461
'tensorflow_datasets.core.utils.gcs_utils.is_dataset_on_gcs',
459462
_GCS_ACCESS_FNS['original_datasets'],
463+
), mock.patch(
464+
'tensorflow_datasets.core.utils.gcs_utils._is_gcs_disabled',
465+
False,
460466
):
461467
yield
462468

0 commit comments

Comments
 (0)