Skip to content
3 changes: 1 addition & 2 deletions ci/run_cudf_polars_polars_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ DESELECTED_TESTS_STR=$(printf -- " --deselect %s" "${DESELECTED_TESTS[@]}")
# Don't quote the `DESELECTED_...` variable because `pytest` can't handle
# multiple quoted arguments inline
# shellcheck disable=SC2086
# Fail fast (-x) because failed tests pollute the state
# Fail fast (-x) rather than trying to continue because failed tests pollute the state
echo "Run polars tests with injected in-memory GPU engine"
python "${TIMEOUT_TOOL_PATH}" --enable-python 4800 \
python -m pytest \
Expand Down Expand Up @@ -90,7 +90,6 @@ python "${TIMEOUT_TOOL_PATH}" --enable-python 4800 \
--import-mode=importlib \
--cache-clear \
-x \
-v \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The verbose test log makes github actions unusable. With fail fast we get immediate information about a failing test.

-m "" \
-p cudf_polars.testing.inject_gpu_engine \
-W ignore::ResourceWarning \
Expand Down
5 changes: 3 additions & 2 deletions ci/test_python_other.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION.
# SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail
Expand Down Expand Up @@ -42,8 +42,9 @@ timeout 30m ./ci/run_custreamz_pytests.sh \
--cov-report=term

rapids-logger "pytest cudf-polars"
# Fail fast (-x) rather than trying to continue because failed tests pollute the state
./ci/run_cudf_polars_pytests.sh \
-vv \
-x \
--junitxml="${RAPIDS_TESTS_DIR}/junit-cudf-polars.xml" \
--numprocesses=4 \
--dist=worksteal \
Expand Down
1 change: 0 additions & 1 deletion ci/test_wheel_cudf_polars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ for version in "${VERSIONS[@]}"; do

# Fail fast (-x) rather than trying to continue because failed tests pollute the state
./ci/run_cudf_polars_pytests.sh \
-vv \
"${COVERAGE_ARGS[@]}" \
--numprocesses=4 \
--dist=worksteal \
Expand Down
27 changes: 24 additions & 3 deletions python/cudf_polars/cudf_polars/dsl/traversal.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES.
# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

"""Traversal and visitor utilities for nodes."""

from __future__ import annotations

from collections import deque
from collections import Counter, deque
from typing import TYPE_CHECKING, Generic

from cudf_polars.typing import (
Expand All @@ -15,19 +15,40 @@
)

if TYPE_CHECKING:
from collections.abc import Callable, Generator, MutableMapping, Sequence
from collections.abc import Callable, Generator, Mapping, MutableMapping, Sequence

from cudf_polars.typing import GenericTransformer, NodeT


__all__: list[str] = [
"CachingVisitor",
"collect_refcount",
"make_recursive",
"post_traversal",
"reuse_if_unchanged",
"traversal",
]


def collect_refcount(nodes: Sequence[NodeT]) -> Mapping[NodeT, int]:
"""
Determine reference counts of all nodes in a DAG.

Parameters
----------
nodes
Sequence of root nodes

Returns
-------
Mapping from nodes to frequency of occurrence in the DAG.
"""
refcount = Counter(nodes)
for node in traversal(nodes):
refcount.update(node.children)
return refcount


def traversal(nodes: Sequence[NodeT]) -> Generator[NodeT, None, None]:
"""
Pre-order traversal of nodes in an expression.
Expand Down
Loading
Loading