Skip to content

Commit

Permalink
remove underscore
Browse files Browse the repository at this point in the history
  • Loading branch information
rjzamora committed Jun 17, 2024
1 parent d81ea4c commit 0a8a6e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions dask/dataframe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@
from packaging.version import Version

# The "dataframe.query-planning" config can only be processed once
_DASK_EXPR_ENABLED: bool | None = None
DASK_EXPR_ENABLED: bool | None = None


def _dask_expr_enabled() -> bool:
import pandas as pd

import dask

global _DASK_EXPR_ENABLED
global DASK_EXPR_ENABLED

use_dask_expr = dask.config.get("dataframe.query-planning")
if _DASK_EXPR_ENABLED is not None:
if (use_dask_expr is True and _DASK_EXPR_ENABLED is False) or (
use_dask_expr is False and _DASK_EXPR_ENABLED is True
if DASK_EXPR_ENABLED is not None:
if (use_dask_expr is True and DASK_EXPR_ENABLED is False) or (
use_dask_expr is False and DASK_EXPR_ENABLED is True
):
warnings.warn(
"The 'dataframe.query-planning' config is now set to "
f"{use_dask_expr}, but query planning is already "
f"{'enabled' if _DASK_EXPR_ENABLED else 'disabled'}. "
f"{'enabled' if DASK_EXPR_ENABLED else 'disabled'}. "
"The query-planning config can only be changed before "
"`dask.dataframe` is first imported!"
)
return _DASK_EXPR_ENABLED
return DASK_EXPR_ENABLED

if (
use_dask_expr is False
or use_dask_expr is None
and Version(pd.__version__).major < 2
):
return (_DASK_EXPR_ENABLED := False)
return (DASK_EXPR_ENABLED := False)
try:
import dask_expr # noqa: F401
except ImportError:
Expand All @@ -47,10 +47,10 @@ def _dask_expr_enabled() -> bool:
"""
if use_dask_expr is None:
warnings.warn(msg, FutureWarning)
return (_DASK_EXPR_ENABLED := False)
return (DASK_EXPR_ENABLED := False)
else:
raise ImportError(msg)
return (_DASK_EXPR_ENABLED := True)
return (DASK_EXPR_ENABLED := True)


try:
Expand Down
4 changes: 2 additions & 2 deletions dask/dataframe/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -6481,8 +6481,8 @@ def test_enforce_runtime_divisions():
def test_query_planning_config_warns():
# Make sure dd._dask_expr_enabled() warns if the current
# "dataframe.query-planning" config conflicts with the
# global dd._DASK_EXPR_ENABLED setting.
# global dd.DASK_EXPR_ENABLED setting.
with dask.config.set({"dataframe.query-planning": not DASK_EXPR_ENABLED}):
expect = "enabled" if dd._DASK_EXPR_ENABLED else "disabled"
expect = "enabled" if dd.DASK_EXPR_ENABLED else "disabled"
with pytest.warns(match=f"query planning is already {expect}"):
dd._dask_expr_enabled()

0 comments on commit 0a8a6e1

Please sign in to comment.