Skip to content

Commit

Permalink
Add builders defined in packages only when TFDS PUBLIC is visible
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 713279260
  • Loading branch information
tomvdw authored and The TensorFlow Datasets Authors committed Jan 8, 2025
1 parent 606754a commit bcb0f72
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion tensorflow_datasets/core/registered.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,11 @@ def list_imported_builders() -> list[str]:
builder_name
for builder_name, builder_cls in _DATASET_REGISTRY.items()
if _is_builder_available(builder_cls)
] + list(_get_existing_dataset_packages(constants.DATASETS_TFDS_SRC_DIR))
]
if visibility.DatasetType.TFDS_PUBLIC.is_available():
all_builders += list(
_get_existing_dataset_packages(constants.DATASETS_TFDS_SRC_DIR)
)
return sorted(all_builders)


Expand Down
8 changes: 6 additions & 2 deletions tensorflow_datasets/core/visibility_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for tensorflow_datasets.core.visibility."""

import tensorflow_datasets as tfds
from tensorflow_datasets.core import visibility

Expand All @@ -28,3 +26,9 @@ def test_visibility():
# `absl.app` should detect the TFDS script and restrict the visibility
# to TFDS public by default.
assert visibility._current_available == {visibility.DatasetType.TFDS_PUBLIC}
assert 'mnist' in tfds.list_builders()
assert 'abstract_reasoning' in tfds.list_builders()
# Remove all visibility and check that the datasets are not available.
with visibility.set_availables_tmp([]):
assert 'mnist' not in tfds.list_builders()
assert 'abstract_reasoning' not in tfds.list_builders()

0 comments on commit bcb0f72

Please sign in to comment.