Skip to content

Commit 2debd5f

Browse files
Debugging CI problems
1 parent ee61079 commit 2debd5f

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

pandas/tests/io/test_iceberg.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,41 @@
1919

2020
pytestmark = [pytest.mark.single_cpu]
2121

22+
# XXX Some tests fail in the CI because an empty .pyiceberg file is found.
23+
# Checking here before importing the pyiceberg module, to provide better
24+
# error message
25+
import os
26+
27+
def check_pyiceberg_yaml_file():
28+
import strictyaml
29+
30+
PYICEBERG_HOME = "PYICEBERG_HOME"
31+
search_dirs = [os.environ.get(PYICEBERG_HOME), os.path.expanduser("~"), os.getcwd()]
32+
for dir_ in search_dirs:
33+
path = None
34+
exists = False
35+
content = None
36+
if dir_:
37+
path = pathlib.Path(dir_) / ".pyiceberg.yaml"
38+
exists = path.exists()
39+
if exists:
40+
with open(path, encoding="utf-8") as f:
41+
yml_str = f.read()
42+
content = strictyaml.load(yml_str).data
43+
raise RuntimeError(
44+
".pyiceberg.yaml file already exists\n"
45+
f"Path: {path}\nContent:\n{content}"
46+
)
47+
48+
try:
49+
import strictyaml
50+
except ImportError:
51+
pass
52+
else:
53+
check_pyiceberg_yaml_file()
54+
# XXX End checks
55+
56+
2257
pyiceberg = pytest.importorskip("pyiceberg")
2358
pyiceberg_catalog = pytest.importorskip("pyiceberg.catalog")
2459
pq = pytest.importorskip("pyarrow.parquet")
@@ -47,7 +82,7 @@ def create_catalog(catalog_name_in_pyiceberg_config=None):
4782

4883
if catalog_name_in_pyiceberg_config is not None:
4984
config_path = pathlib.Path.home() / ".pyiceberg.yaml"
50-
with open(config_path, "w") as f:
85+
with open(config_path, "w", encoding="utf-8") as f:
5186
f.write(f"""\
5287
catalog:
5388
{catalog_name_in_pyiceberg_config}:

0 commit comments

Comments
 (0)