Skip to content

Commit

Permalink
catch ValueError before ImportError (#2415)
Browse files Browse the repository at this point in the history
  • Loading branch information
severo authored Feb 7, 2024
1 parent f673502 commit dfbe31e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions services/worker/src/worker/job_runners/dataset/config_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,21 @@ def compute_config_names_response(
]
except _EmptyDatasetError as err:
raise EmptyDatasetError("The dataset is empty.", cause=err) from err
except ImportError as err:
raise DatasetModuleNotInstalledError(
"The dataset tries to import a module that is not installed.", cause=err
) from err
except Exception as err:
if isinstance(err, ValueError) and "trust_remote_code" in str(err):
except ValueError as err:
if "trust_remote_code" in str(err):
raise DatasetWithScriptNotSupportedError(
"The dataset viewer doesn't support this dataset because it runs "
"arbitrary python code. Please open a discussion in the discussion tab "
"if you think this is an error and tag @lhoestq and @severo."
) from err
raise ConfigNamesError("Cannot get the config names for the dataset.", cause=err) from err
except ImportError as err:
# this should only happen if the dataset is in the allow list, which should soon disappear
raise DatasetModuleNotInstalledError(
"The dataset tries to import a module that is not installed.", cause=err
) from err
except Exception as err:
raise ConfigNamesError("Cannot get the config names for the dataset.", cause=err) from err

number_of_configs = len(config_name_items)
if number_of_configs > max_number:
Expand Down

0 comments on commit dfbe31e

Please sign in to comment.