Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI #6780

Merged
merged 2 commits into from
Apr 4, 2024
Merged

Fix CI #6780

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions tests/test_arrow_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3980,7 +3980,7 @@ def _check_sql_dataset(dataset, expected_features):

@require_sqlalchemy
@pytest.mark.parametrize("con_type", ["string", "engine"])
def test_dataset_from_sql_con_type(con_type, sqlite_path, tmp_path, set_sqlalchemy_silence_uber_warning):
def test_dataset_from_sql_con_type(con_type, sqlite_path, tmp_path, set_sqlalchemy_silence_uber_warning, caplog):
cache_dir = tmp_path / "cache"
expected_features = {"col_1": "string", "col_2": "int64", "col_3": "float64"}
if con_type == "string":
Expand All @@ -3989,17 +3989,16 @@ def test_dataset_from_sql_con_type(con_type, sqlite_path, tmp_path, set_sqlalche
import sqlalchemy

con = sqlalchemy.create_engine("sqlite:///" + sqlite_path)
# # https://github.com/huggingface/datasets/issues/2832 needs to be fixed first for this to work
# with caplog.at_level(INFO):
# dataset = Dataset.from_sql(
# "dataset",
# con,
# cache_dir=cache_dir,
# )
# if con_type == "string":
# assert "couldn't be hashed properly" not in caplog.text
# elif con_type == "engine":
# assert "couldn't be hashed properly" in caplog.text
with caplog.at_level(INFO, logger=get_logger().name):
dataset = Dataset.from_sql(
"dataset",
con,
cache_dir=cache_dir,
)
if con_type == "string":
assert "couldn't be hashed properly" not in caplog.text
elif con_type == "engine":
assert "couldn't be hashed properly" in caplog.text
dataset = Dataset.from_sql(
"dataset",
con,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
pytestmark = pytest.mark.integration


@pytest.mark.parametrize("path", ["lhoestq/test", csv.__file__])
@pytest.mark.parametrize("path", ["hf-internal-testing/dataset_with_script", csv.__file__])
def test_inspect_dataset(path, tmp_path):
inspect_dataset(path, tmp_path)
script_name = Path(path).stem + ".py"
Expand Down
14 changes: 9 additions & 5 deletions tests/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,24 +418,28 @@ def setUp(self):
)

def test_HubDatasetModuleFactoryWithScript_dont_trust_remote_code(self):
# "lhoestq/test" has a dataset script
factory = HubDatasetModuleFactoryWithScript(
"lhoestq/test", download_config=self.download_config, dynamic_modules_path=self.dynamic_modules_path
"hf-internal-testing/dataset_with_script",
download_config=self.download_config,
dynamic_modules_path=self.dynamic_modules_path,
)
with patch.object(config, "HF_DATASETS_TRUST_REMOTE_CODE", None): # this will be the default soon
self.assertRaises(ValueError, factory.get_module)
factory = HubDatasetModuleFactoryWithScript(
"lhoestq/test",
"hf-internal-testing/dataset_with_script",
download_config=self.download_config,
dynamic_modules_path=self.dynamic_modules_path,
trust_remote_code=False,
)
self.assertRaises(ValueError, factory.get_module)

def test_HubDatasetModuleFactoryWithScript_with_github_dataset(self):
def test_HubDatasetModuleFactoryWithScript_with_hub_dataset(self):
# "wmt_t2t" has additional imports (internal)
factory = HubDatasetModuleFactoryWithScript(
"wmt_t2t", download_config=self.download_config, dynamic_modules_path=self.dynamic_modules_path
"wmt_t2t",
download_config=self.download_config,
dynamic_modules_path=self.dynamic_modules_path,
revision="861aac88b2c6247dd93ade8b1c189ce714627750",
)
module_factory_result = factory.get_module()
assert importlib.import_module(module_factory_result.module_path) is not None
Expand Down
Loading