Skip to content

Commit e04aed6

Browse files
committed
Discovery of the tests module is very strange. Proving that is the root cause and we can resolve. Will follow up by reverting this and removing multiprocessing specif test because not worth the complexity
1 parent 0c77277 commit e04aed6

2 files changed

Lines changed: 23 additions & 13 deletions

File tree

conftest.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,29 @@
1717

1818
"""Pytest configuration for doctest namespace injection."""
1919

20-
import datafusion as dfn
21-
import numpy as np
22-
import pyarrow as pa
23-
import pytest
24-
from datafusion import col, lit
25-
from datafusion import functions as F
20+
import sys
21+
from pathlib import Path
22+
23+
# Ensure ``python/`` is reachable by ``import``. The ``tests`` package lives at
24+
# ``python/tests`` and spawn-based multiprocessing tests need workers to be
25+
# able to resolve ``tests._pickle_multiprocessing_helpers`` by its real dotted
26+
# name when unpickling task args. Editable installs add this path via a .pth
27+
# file, but the wheel install used in CI does not, which led to spawn workers
28+
# dying with ``ModuleNotFoundError`` and ``Pool.map`` hanging.
29+
#
30+
# Append (don't prepend) so the wheel-installed ``datafusion`` in
31+
# site-packages still wins over the source tree at ``python/datafusion`` —
32+
# the source tree has no compiled ``_internal`` module on a fresh checkout.
33+
_python_dir = str(Path(__file__).parent / "python")
34+
if _python_dir not in sys.path:
35+
sys.path.append(_python_dir)
36+
37+
import datafusion as dfn # noqa: E402
38+
import numpy as np # noqa: E402
39+
import pyarrow as pa # noqa: E402
40+
import pytest # noqa: E402
41+
from datafusion import col, lit # noqa: E402
42+
from datafusion import functions as F # noqa: E402
2643

2744

2845
@pytest.fixture(autouse=True)

pyproject.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ asyncio_default_fixture_loop_scope = "function"
7474
addopts = "--doctest-modules"
7575
doctest_optionflags = ["NORMALIZE_WHITESPACE", "ELLIPSIS"]
7676
testpaths = ["python/tests", "python/datafusion"]
77-
# Ensure ``python/`` is on sys.path so the ``tests`` package is importable.
78-
# Required for spawn-based multiprocessing tests: workers need to resolve
79-
# ``tests._pickle_multiprocessing_helpers`` by its real dotted name. With
80-
# editable/develop installs a .pth file happens to add this path, but the
81-
# wheel install used in CI does not, which led to spawn workers dying with
82-
# ``ModuleNotFoundError: No module named 'tests'`` and ``Pool.map`` hanging.
83-
pythonpath = ["python"]
8477

8578
# Enable docstring linting using the google style guide
8679
[tool.ruff.lint]

0 commit comments

Comments
 (0)