Skip to content
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

FIX-#4450: Ensure Modin successfully initializes when Ray cluster has no resources #4451

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/release_notes/release_notes-0.15.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ Key Features and Updates
* FIX-#4461: Fix S3 CSV data path (#4462)
* FIX-#4467: `drop_duplicates` no longer removes items based on index values (#4468)
* FIX-#4449: Drain the call queue before waiting on result in benchmark mode (#4472)
* FIX-#4481: Allow clipping with a Modin Series of bounds (#4486)
* FIX-#4481: Allow clipping with a Modin Series of bounds (#4486)
* FIX-#4450: Ensure Modin successfully initializes when Ray cluster has no resources (#4451)
* Performance enhancements
* FEAT-#4320: Add connectorx as an alternative engine for read_sql (#4346)
* Benchmarking enhancements
Expand Down Expand Up @@ -74,3 +75,4 @@ Contributors
@jrsacher
@orcahmlee
@naren-ponder
@RehanSD
12 changes: 11 additions & 1 deletion modin/core/execution/ray/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,17 @@ def initialize_ray(
_move_stdlib_ahead_of_site_packages
)
ray.worker.global_worker.run_function_on_all_workers(_import_pandas)
num_cpus = int(ray.cluster_resources()["CPU"])
num_cpus = ray.cluster_resources().get("CPU", None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
num_cpus = ray.cluster_resources().get("CPU", None)
num_cpus = ray.cluster_resources().get("CPU", None) or 4

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The reason I did it like this is because I wanted to warn users that we were unable to determine how many CPUs there were and were relying on an internal heuristic - should we keep it this way, or change it to the more streamlined version you propose?

if num_cpus is None:
warnings.warn(
"The current Ray cluster does not have any CPU Resources.\nModin uses the number of "
+ "CPUs to determine how many partitions to create.\nNumber of partitions defaulting to"
+ " number of CPUs on head node. To update, run the following python code:\n\tfrom "

Choose a reason for hiding this comment

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

nit: could you instead instantiate num_cpus above this warning, and add the actual value of num_cpus to the warning message? such as, with an f-string.

+ "modin.config import NPartitions\n\tNPartitions.put(desired_num_cpus)"
)
num_cpus = CpuCount.get()
else:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
else:

num_cpus = int(num_cpus)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
num_cpus = int(num_cpus)
num_cpus = int(num_cpus)

num_gpus = int(ray.cluster_resources().get("GPU", 0))
if StorageFormat.get() == "Cudf":
NPartitions._put(num_gpus)
Expand Down