Skip to content

Commit 785a680

Browse files
authored
SNOW-2389912: Ensure hybrid execution is actually enabled by default (#3841)
1 parent e15075d commit 785a680

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

.github/workflows/precommit.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,16 @@ jobs:
575575
run: uv pip install -U setuptools pip wheel --system
576576
- name: Install tox
577577
run: uv pip install tox --system
578+
- if: ${{ matrix.os == 'macos-latest' && matrix.cloud-provider == 'aws' }}
579+
name: Check AutoSwitchBackend default value
580+
# SNOW-2389912: Ensure hybrid is correctly enabled by default. We can't use pytest because
581+
# our test suite sets the AutoSwitchBackend variable explicitly.
582+
run: |
583+
python -m tox -e "py${PYTHON_VERSION}-snowparkpandashybridcheck_sessionfirst-modin-ci" \
584+
&& python -m tox -e "py${PYTHON_VERSION}-snowparkpandashybridcheck_pluginfirst-modin-ci"
585+
env:
586+
PYTHON_VERSION: ${{ matrix.python-version }}
587+
cloud_provider: ${{ matrix.cloud-provider }}
578588
# only run doctest for macos on aws
579589
- if: ${{ matrix.os == 'macos-latest' && matrix.cloud-provider == 'aws' }}
580590
name: Run Snowpark pandas API doctests

src/snowflake/snowpark/session.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -759,13 +759,16 @@ def __init__(
759759
try:
760760
from modin.config import AutoSwitchBackend
761761

762-
pandas_hybrid_execution_enabled: bool = (
763-
self._conn._get_client_side_session_parameter(
764-
_SNOWPARK_PANDAS_HYBRID_EXECUTION_ENABLED,
765-
AutoSwitchBackend().get(),
766-
)
762+
pandas_hybrid_execution_enabled: Union[
763+
bool, None
764+
] = self._conn._get_client_side_session_parameter(
765+
_SNOWPARK_PANDAS_HYBRID_EXECUTION_ENABLED, None
767766
)
768-
AutoSwitchBackend.put(pandas_hybrid_execution_enabled)
767+
# Only set AutoSwitchBackend if the session parameter was already set.
768+
# snowflake.snowpark.modin.plugin sets AutoSwitchBackend to True if it was
769+
# not already set, so we should not change the variable if it's in its default state.
770+
if pandas_hybrid_execution_enabled is not None:
771+
AutoSwitchBackend.put(pandas_hybrid_execution_enabled)
769772
except Exception:
770773
# Continue session initialization even if Modin configuration fails
771774
pass

tox.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ commands =
135135
# This one is only called by jenkins job and the only difference from `snowparkpandasnotdoctest` is that it uses
136136
# MODIN_PYTEST_NO_COV_CMD instead of MODIN_PYTEST_CMD
137137
snowparkpandasjenkins: {env:MODIN_PYTEST_NO_COV_CMD} --durations=20 -m "{env:SNOWFLAKE_TEST_TYPE}" {posargs:} {env:SNOW_1314507_WORKAROUND_RERUN_FLAGS} tests/unit/modin tests/integ/modin
138+
# These jobs run outside pytest since we manipulate AutoSwitchBackend during pytest setup and we want to test a fresh session.
139+
snowparkpandashybridcheck_sessionfirst: python -c "from tests.parameters import CONNECTION_PARAMETERS; from snowflake.snowpark.session import Session; Session.builder.configs(CONNECTION_PARAMETERS).create(); import snowflake.snowpark.modin.plugin; from modin.config import AutoSwitchBackend; assert AutoSwitchBackend.get() is True"
140+
snowparkpandashybridcheck_pluginfirst: python -c "from tests.parameters import CONNECTION_PARAMETERS; import snowflake.snowpark.modin.plugin; from snowflake.snowpark.session import Session; Session.builder.configs(CONNECTION_PARAMETERS).create(); from modin.config import AutoSwitchBackend; assert AutoSwitchBackend.get() is True"
138141
# Snowpark IR commands:
139142
ast: {env:SNOWFLAKE_PYTEST_DAILY_CMD} -m "{env:SNOWFLAKE_TEST_TYPE}" {posargs:} tests
140143

0 commit comments

Comments
 (0)