Skip to content

Commit

Permalink
Disable GCS loading by default
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 696820685
  • Loading branch information
Alfonso Castaño authored and The TensorFlow Datasets Authors committed Nov 15, 2024
1 parent 40cc288 commit 6bcafe4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tensorflow_datasets/core/utils/gcs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
GCS_DATASET_INFO_DIR = 'dataset_info'
GCS_DATASETS_DIR = 'datasets'

_is_gcs_disabled = False
_is_gcs_disabled = True


# Exception raised when GCS isn't available
Expand Down
7 changes: 5 additions & 2 deletions tensorflow_datasets/core/utils/gcs_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@
from tensorflow_datasets.core.utils import gcs_utils
from tensorflow_datasets.testing import test_utils


import os
import tempfile
import tensorflow_datasets as tfds
class GcsUtilsTest(testing.TestCase):
DO_NOT_APPLY_FIXTURES = [test_utils.disable_gcs_access]
def test_is_dataset_accessible(self):
gcs_utils._is_gcs_disabled = False
self.assertTrue(gcs_utils.is_dataset_on_gcs('mnist/1.0.0'))
self.assertFalse(gcs_utils.is_dataset_on_gcs('non_dataset/1.0.0'))
gcs_utils._is_gcs_disabled = True
def test_download_dataset(self):
gcs_utils._is_gcs_disabled = False
files = [
'gs://tfds-data/dataset_info/mnist/2.0.0/dataset_info.json',
'gs://tfds-data/dataset_info/mnist/2.0.0/image.image.json',
Expand All @@ -50,6 +52,7 @@ def test_download_dataset(self):
'image.image.json',
],
)
gcs_utils._is_gcs_disabled = True
def test_mnist(self):
mnist = tfds.image_classification.MNIST(
data_dir=gcs_utils.gcs_path('datasets')
Expand All @@ -65,7 +68,7 @@ class GcsUtilsDisabledTest(testing.TestCase):

def test_is_dataset_accessible(self):
is_ds_on_gcs = gcs_utils.is_dataset_on_gcs('mnist/1.0.0')
self.assertTrue(is_ds_on_gcs)
self.assertFalse(is_ds_on_gcs)


if __name__ == '__main__':
Expand Down
6 changes: 6 additions & 0 deletions tensorflow_datasets/testing/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ def disable_gcs_access() -> Iterator[None]:
), mock.patch(
'tensorflow_datasets.core.utils.gcs_utils.is_dataset_on_gcs',
_GCS_ACCESS_FNS['dummy_datasets'],
), mock.patch(
'tensorflow_datasets.core.utils.gcs_utils._is_gcs_disabled',
True,
):
yield

Expand All @@ -457,6 +460,9 @@ def enable_gcs_access() -> Iterator[None]:
), mock.patch(
'tensorflow_datasets.core.utils.gcs_utils.is_dataset_on_gcs',
_GCS_ACCESS_FNS['original_datasets'],
), mock.patch(
'tensorflow_datasets.core.utils.gcs_utils._is_gcs_disabled',
False,
):
yield

Expand Down

0 comments on commit 6bcafe4

Please sign in to comment.