Skip to content

Commit c6e6420

Browse files
committed
fix ray local init
1 parent f43a4fb commit c6e6420

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ filterwarnings = [
163163
"ignore:You are using a Python version.*which Google will stop supporting:FutureWarning:google.api_core",
164164
# Python 3.13 sqlite3 module ResourceWarnings for unclosed database connections
165165
"ignore:unclosed database in <sqlite3.Connection object*:ResourceWarning",
166+
# Ignore Ray subprocess cleanup warnings
167+
"ignore:unclosed file:ResourceWarning",
168+
"ignore:subprocess.*is still running:ResourceWarning",
166169
]
167170

168171
[tool.black]

tests/conftest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,3 +2947,16 @@ def pyarrow_table_with_promoted_types(pyarrow_schema_with_promoted_types: "pa.Sc
29472947
},
29482948
schema=pyarrow_schema_with_promoted_types,
29492949
)
2950+
2951+
2952+
@pytest.fixture(scope="function")
2953+
def ray_session() -> Generator[Any, None, None]:
2954+
"""Fixture to manage Ray initialization and shutdown for tests."""
2955+
import ray
2956+
2957+
ray.init(
2958+
ignore_reinit_error=True,
2959+
runtime_env={"working_dir": None}, # Prevent Ray from serializing the working directory to workers
2960+
)
2961+
yield ray
2962+
ray.shutdown()

tests/integration/test_reads.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import uuid
2222
from datetime import datetime, timedelta
2323
from pathlib import PosixPath
24+
from typing import Any
2425
from urllib.parse import urlparse
2526

2627
import pyarrow as pa
@@ -357,7 +358,7 @@ def test_bodo_nan(catalog: Catalog, monkeypatch: pytest.MonkeyPatch) -> None:
357358
@pytest.mark.integration
358359
@pytest.mark.filterwarnings("ignore")
359360
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")])
360-
def test_ray_nan(catalog: Catalog) -> None:
361+
def test_ray_nan(catalog: Catalog, ray_session: Any) -> None:
361362
table_test_null_nan_rewritten = catalog.load_table("default.test_null_nan_rewritten")
362363
ray_dataset = table_test_null_nan_rewritten.scan().to_ray()
363364
assert ray_dataset.count() == 3
@@ -366,7 +367,7 @@ def test_ray_nan(catalog: Catalog) -> None:
366367

367368
@pytest.mark.integration
368369
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")])
369-
def test_ray_nan_rewritten(catalog: Catalog) -> None:
370+
def test_ray_nan_rewritten(catalog: Catalog, ray_session: Any) -> None:
370371
table_test_null_nan_rewritten = catalog.load_table("default.test_null_nan_rewritten")
371372
ray_dataset = table_test_null_nan_rewritten.scan(
372373
row_filter=IsNaN("col_numeric"), selected_fields=("idx", "col_numeric")
@@ -379,15 +380,15 @@ def test_ray_nan_rewritten(catalog: Catalog) -> None:
379380
@pytest.mark.integration
380381
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")])
381382
@pytest.mark.skip(reason="Fixing issues with NaN's: https://github.com/apache/arrow/issues/34162")
382-
def test_ray_not_nan_count(catalog: Catalog) -> None:
383+
def test_ray_not_nan_count(catalog: Catalog, ray_session: Any) -> None:
383384
table_test_null_nan_rewritten = catalog.load_table("default.test_null_nan_rewritten")
384385
ray_dataset = table_test_null_nan_rewritten.scan(row_filter=NotNaN("col_numeric"), selected_fields=("idx",)).to_ray()
385386
assert ray_dataset.count() == 2
386387

387388

388389
@pytest.mark.integration
389390
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")])
390-
def test_ray_all_types(catalog: Catalog) -> None:
391+
def test_ray_all_types(catalog: Catalog, ray_session: Any) -> None:
391392
table_test_all_types = catalog.load_table("default.test_all_types")
392393
ray_dataset = table_test_all_types.scan().to_ray()
393394
pandas_dataframe = table_test_all_types.scan().to_pandas()

0 commit comments

Comments
 (0)