Repository: huggingface/dataset-viewer

Issue:
Fail quickly when the dataset card contains `viewer: false`
The Hub shows a specific message, instead of the dataset viewer, when the dataset card contains the metadata `viewer: false`.

I think that we should take it into account when checking if a dataset is supported, and fail fast (adding this case in https://github.com/huggingface/datasets-server/blob/main/libs/libcommon/src/libcommon/dataset.py#L165, along to checking if the dataset is private) 


Discussion:
See https://huggingface.co/datasets/allenai/objaverse/discussions/25 for example
Note that when the dataset is private, we don't want to disclose its existence. But when the dataset viewer is disabled on purpose, as the information is public, we should return a specific error code and message (it would help to do statistics by the way).
Also: we should update the docs. Maybe in https://huggingface.co/docs/datasets-server/valid, or in a specific section where we make it clear that: the private datasets are not supported, the gated datasets require access token, and the dataset with `viewer: false` are disabled (with link to https://huggingface.co/docs/hub/datasets-viewer#disable-the-viewer)?

Resolving patch:
diff --git a/libs/libcommon/src/libcommon/dataset.py b/libs/libcommon/src/libcommon/dataset.py
--- a/libs/libcommon/src/libcommon/dataset.py
+++ b/libs/libcommon/src/libcommon/dataset.py
@@ -15,6 +15,7 @@
     "AskAccessHubRequestError",
     "DatasetInfoHubRequestError",
     "DatasetNotFoundError",
+    "DisabledViewerError",
     "GatedDisabledError",
     "GatedExtraFieldsError",
 ]
@@ -75,6 +76,19 @@ def __init__(self, message: str, cause: Optional[BaseException] = None):
         )
 
 
+class DisabledViewerError(DatasetError):
+    """Raised when the dataset viewer is disabled."""
+
+    def __init__(self, message: str, cause: Optional[BaseException] = None):
+        super().__init__(
+            message=message,
+            status_code=HTTPStatus.NOT_FOUND,
+            code="DisabledViewerError",
+            cause=cause,
+            disclose_cause=False,
+        )
+
+
 class GatedDisabledError(DatasetError):
     """Raised when the dataset is gated, but disabled."""
 
@@ -191,6 +205,7 @@ def get_dataset_info_for_supported_datasets(
         - [`~libcommon.dataset.GatedExtraFieldsError`]: if the dataset is gated, with extra fields.
             Programmatic access is not implemented for this type of dataset because there is no easy
             way to get the list of extra fields.
+        - [`~libcommon.dataset.DisabledViewerError`]: if the dataset viewer is disabled.
         - [`~libcommon.dataset.GatedDisabledError`]: if the dataset is gated, but disabled.
         - [`~libcommon.dataset.DatasetNotFoundError`]: if the dataset does not exist, or if the
             token does not give the sufficient access to the dataset, or if the dataset is private
@@ -229,6 +244,8 @@ def get_dataset_info_for_supported_datasets(
         ) from err
     if dataset_info.private:
         raise DatasetNotFoundError("The dataset is private and private datasets are not yet supported.")
+    if dataset_info.cardData and not dataset_info.cardData.get("viewer", True):
+        raise DisabledViewerError("The dataset viewer has been disabled on this dataset.")
     return dataset_info
 
 
@@ -261,6 +278,7 @@ def get_dataset_git_revision(
         - [`~libcommon.dataset.GatedExtraFieldsError`]: if the dataset is gated, with extra fields.
             Programmatic access is not implemented for this type of dataset because there is no easy
             way to get the list of extra fields.
+        - [`~libcommon.dataset.DisabledViewerError`]: if the dataset viewer is disabled.
         - [`~libcommon.dataset.GatedDisabledError`]: if the dataset is gated, but disabled.
         - [`~libcommon.dataset.DatasetNotFoundError`]: if the dataset does not exist, or if the
             token does not give the sufficient access to the dataset, or if the dataset is private
@@ -301,6 +319,7 @@ def check_support(
         - [`~libcommon.dataset.GatedExtraFieldsError`]: if the dataset is gated, with extra fields.
             Programmatic access is not implemented for this type of dataset because there is no easy
             way to get the list of extra fields.
+        - [`~libcommon.dataset.DisabledViewerError`]: if the dataset viewer is disabled.
         - [`~libcommon.dataset.GatedDisabledError`]: if the dataset is gated, but disabled.
         - [`~libcommon.dataset.DatasetNotFoundError`]: if the dataset does not exist, or if the
             token does not give the sufficient access to the dataset, or if the dataset is private


Test patch: