forked from huggingface/datasets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate config name and data_files in packaged modules (huggingface#…
…6915) * Make configs call super post_init in packaged modules * Update hash in test * Add tests * Add tests for BuilderConfig * Fix syntax * use old hash for 2.15 cache reload --------- Co-authored-by: Quentin Lhoest <lhoest.q@gmail.com>
- Loading branch information
1 parent
6548e0e
commit 5bbbf1b
Showing
26 changed files
with
226 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pytest | ||
|
||
from datasets.builder import InvalidConfigName | ||
from datasets.data_files import DataFilesList | ||
from datasets.packaged_modules.arrow.arrow import ArrowConfig | ||
|
||
|
||
def test_config_raises_when_invalid_name() -> None: | ||
with pytest.raises(InvalidConfigName, match="Bad characters"): | ||
_ = ArrowConfig(name="name-with-*-invalid-character") | ||
|
||
|
||
@pytest.mark.parametrize("data_files", ["str_path", ["str_path"], DataFilesList(["str_path"], [()])]) | ||
def test_config_raises_when_invalid_data_files(data_files) -> None: | ||
with pytest.raises(ValueError, match="Expected a DataFilesDict"): | ||
_ = ArrowConfig(name="name", data_files=data_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pytest | ||
|
||
from datasets.builder import InvalidConfigName | ||
from datasets.data_files import DataFilesList | ||
from datasets.packaged_modules.pandas.pandas import PandasConfig | ||
|
||
|
||
def test_config_raises_when_invalid_name() -> None: | ||
with pytest.raises(InvalidConfigName, match="Bad characters"): | ||
_ = PandasConfig(name="name-with-*-invalid-character") | ||
|
||
|
||
@pytest.mark.parametrize("data_files", ["str_path", ["str_path"], DataFilesList(["str_path"], [()])]) | ||
def test_config_raises_when_invalid_data_files(data_files) -> None: | ||
with pytest.raises(ValueError, match="Expected a DataFilesDict"): | ||
_ = PandasConfig(name="name", data_files=data_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pytest | ||
|
||
from datasets.builder import InvalidConfigName | ||
from datasets.data_files import DataFilesList | ||
from datasets.packaged_modules.parquet.parquet import ParquetConfig | ||
|
||
|
||
def test_config_raises_when_invalid_name() -> None: | ||
with pytest.raises(InvalidConfigName, match="Bad characters"): | ||
_ = ParquetConfig(name="name-with-*-invalid-character") | ||
|
||
|
||
@pytest.mark.parametrize("data_files", ["str_path", ["str_path"], DataFilesList(["str_path"], [()])]) | ||
def test_config_raises_when_invalid_data_files(data_files) -> None: | ||
with pytest.raises(ValueError, match="Expected a DataFilesDict"): | ||
_ = ParquetConfig(name="name", data_files=data_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pytest | ||
|
||
from datasets.builder import InvalidConfigName | ||
from datasets.data_files import DataFilesList | ||
from datasets.packaged_modules.sql.sql import SqlConfig | ||
|
||
|
||
def test_config_raises_when_invalid_name() -> None: | ||
with pytest.raises(InvalidConfigName, match="Bad characters"): | ||
_ = SqlConfig(name="name-with-*-invalid-character") | ||
|
||
|
||
@pytest.mark.parametrize("data_files", ["str_path", ["str_path"], DataFilesList(["str_path"], [()])]) | ||
def test_config_raises_when_invalid_data_files(data_files) -> None: | ||
with pytest.raises(ValueError, match="Expected a DataFilesDict"): | ||
_ = SqlConfig(name="name", data_files=data_files) |
Oops, something went wrong.