Repository: pola-rs/polars
File: py-polars/polars/lazyframe/frame.py (Python)

Code before:
        is_config_obj or engine in ("auto", "cpu", "in-memory", "streaming", "gpu")
    ):
        msg = f"Invalid engine argument {engine=}"
        raise ValueError(msg)
    if (streaming or background or new_streaming) and is_gpu:
        issue_warning(
            "GPU engine does not support streaming or background collection, "
            "disabling GPU engine.",
            category=UserWarning,
        )
        is_gpu = False
    if _eager:
        # Don't run on GPU in _eager mode (but don't warn)
        is_gpu = False

    if not is_gpu:
        return None
    cudf_polars = import_optional(
        "cudf_polars",
        err_prefix="GPU engine requested, but required package",
        install_message=(
            "Please install using the command "
            "`pip install cudf-polars-cu12` "
            "(CUDA 12 is required for RAPIDS cuDF v25.08 and later). "
            "If your system has a CUDA 11 driver, install with "
            "`pip install --extra-index-url=https://pypi.nvidia.com cudf-polars-cu11==25.06` "
        ),
    )
    if not is_config_obj:
        engine = GPUEngine()
    return partial(cudf_polars.execute_with_cudf, config=engine)


class LazyFrame:
    """
    Representation of a Lazy computation graph/query against a DataFrame.

    This allows for whole-query optimisation in addition to parallelism, and
    is the preferred (and highest-performance) mode of operation for polars.

    Parameters
    ----------
    data : dict, Sequence, ndarray, Series, or pandas.DataFrame
        Two-dimensional data in various forms; dict input must contain Sequences,
        Generators, or a `range`. Sequence may contain Series or other Sequences.
    schema : Sequence of str, (str,DataType) pairs, or a {str:DataType,} dict
        The LazyFrame schema may be declared in several ways:

        * As a dict of {name:type} pairs; if type is None, it will be auto-inferred.
        * As a list of column names; in this case types are automatically inferred.
        * As a list of (name,type) pairs; this is equivalent to the dictionary form.

Review comment (suggestion):
It's not technically in scope for this PR, but we may as well take this opportunity to update the Polars docs with the fact that we don't need our index anymore.
```suggestion
            "`pip install cudf-polars-cu11==25.06` "
```

Code after:
        is_config_obj or engine in ("auto", "cpu", "in-memory", "streaming", "gpu")
    ):
        msg = f"Invalid engine argument {engine=}"
        raise ValueError(msg)
    if (streaming or background or new_streaming) and is_gpu:
        issue_warning(
            "GPU engine does not support streaming or background collection, "
            "disabling GPU engine.",
            category=UserWarning,
        )
        is_gpu = False
    if _eager:
        # Don't run on GPU in _eager mode (but don't warn)
        is_gpu = False

    if not is_gpu:
        return None
    cudf_polars = import_optional(
        "cudf_polars",
        err_prefix="GPU engine requested, but required package",
        install_message=(
            "Please install using the command "
            "`pip install cudf-polars-cu12` "
            "(CUDA 12 is required for RAPIDS cuDF v25.08 and later). "
            "If your system has a CUDA 11 driver, install with "
            "`pip install cudf-polars-cu11==25.06` "
        ),
    )
    if not is_config_obj:
        engine = GPUEngine()
    return partial(cudf_polars.execute_with_cudf, config=engine)


class LazyFrame:
    """
    Representation of a Lazy computation graph/query against a DataFrame.

    This allows for whole-query optimisation in addition to parallelism, and
    is the preferred (and highest-performance) mode of operation for polars.

    Parameters
    ----------
    data : dict, Sequence, ndarray, Series, or pandas.DataFrame
        Two-dimensional data in various forms; dict input must contain Sequences,
        Generators, or a `range`. Sequence may contain Series or other Sequences.
    schema : Sequence of str, (str,DataType) pairs, or a {str:DataType,} dict
        The LazyFrame schema may be declared in several ways:

        * As a dict of {name:type} pairs; if type is None, it will be auto-inferred.
        * As a list of column names; in this case types are automatically inferred.
        * As a list of (name,type) pairs; this is equivalent to the dictionary form.