-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure query-planning is disabled in dask #371
Merged
jperez999
merged 9 commits into
NVIDIA-Merlin:main
from
rjzamora:disable-query-planning
Jul 26, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9d474de
disable query-planning when merlin.core is imported
rjzamora 3c26f83
fix typo
rjzamora cdc7e6d
remove tests/__init__.py change
rjzamora dfedab7
disable string conversin
rjzamora 884dc26
move dask config settings/check to top level (only way to be sure we …
rjzamora fec8038
clarify error message
rjzamora 1bafba8
use new configs module tfor central config validation point
rjzamora 498e9b1
add missing config module
rjzamora 63433f9
Merge branch 'main' into disable-query-planning
rjzamora File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# | ||
# Copyright (c) 2024, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
_DASK_QUERY_PLANNING_ENABLED = False | ||
try: | ||
# Disable query-planning and string conversion | ||
import dask | ||
|
||
dask.config.set( | ||
{ | ||
"dataframe.query-planning": False, | ||
"dataframe.convert-string": False, | ||
} | ||
) | ||
except ImportError: | ||
dask = None | ||
else: | ||
import sys | ||
|
||
import dask.dataframe as dd | ||
from packaging.version import parse | ||
|
||
if parse(dask.__version__) > parse("2024.6.0"): | ||
# For newer versions of dask, we can just check | ||
# the official DASK_EXPR_ENABLED constant | ||
_DASK_QUERY_PLANNING_ENABLED = dd.DASK_EXPR_ENABLED | ||
else: | ||
# For older versions of dask, we must assume query | ||
# planning is enabled if dask_expr was imported | ||
# (because we can't know for sure) | ||
_DASK_QUERY_PLANNING_ENABLED = "dask_expr" in sys.modules | ||
|
||
|
||
def validate_dask_configs(): | ||
"""Central check for problematic config options in Dask""" | ||
if _DASK_QUERY_PLANNING_ENABLED: | ||
raise NotImplementedError( | ||
"Merlin does not support the query-planning API in " | ||
"Dask Dataframe yet. Please make sure query-planning is " | ||
"disabled before dask.dataframe is imported.\n\ne.g." | ||
"dask.config.set({'dataframe.query-planning': False})" | ||
"\n\nOr set the environment variable: " | ||
"export DASK_DATAFRAME__QUERY_PLANNING=False" | ||
) | ||
|
||
if dask is not None and dask.config.get("dataframe.convert-string"): | ||
raise NotImplementedError( | ||
"Merlin does not support automatic string conversion in " | ||
"Dask Dataframe yet. Please make sure this option is " | ||
"disabled.\n\ne.g." | ||
"dask.config.set({'dataframe.convert-string': False})" | ||
"\n\nOr set the environment variable: " | ||
"export DASK_DATAFRAME__CONVERT_STRING=False" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benfred @jperez999 - It doesn't seem like I can add a top-level
merlin/__init__.py
file to perform the dask-config validation without messing up the namespace for libraries likemerlin.dataloader
.What do you think about the new
merlin.config
module I added in this PR?As far as I can tell, we can be sure query-planning is disabled across merlin/nvt if we add this
validate_dask_configs()
call at the top ofmerlin/core/__init__.py
,merlin/io/__init__.py
, andmerlin/dag/__init__.py
. All internal merlin code using dask will need to import one of these modules first. Therefore, we only need to worry about the user importingdask.dataframe
before importing something from merlin, and I thinkvalidate_dask_configs
raises a suitable error message when this happens.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine. Is there a way for us to test this works, right now? Or do we need to wait until we start using 24.06+ cudf/dask packages?