Skip to content

Commit

Permalink
ignore select factory args if pool is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
jlewitt1 committed Feb 26, 2025
1 parent aab4be9 commit 0faa465
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions runhouse/resources/hardware/cluster_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,21 +310,34 @@ def ondemand_cluster(
>>> # Load cluster from above
>>> reloaded_cluster = rh.ondemand_cluster(name="rh-4-a100s")
"""
launcher = launcher.lower() if launcher else configs.launcher
if launcher not in LauncherType.strings():
raise ValueError(
f"Invalid launcher type '{launcher}'. Must be one of {LauncherType.strings()}."
)
cluster_args = locals().copy()
cluster_args = {k: v for k, v in cluster_args.items() if v is not None}

if vpc_name and launcher == "local":
if pool is not None:
cluster_args["launcher"] = "den"
if autostop_mins and autostop_mins != -1:
logger.warning("Cannot set autostop for a node in a cluster pool.")
cluster_args["autostop_mins"] = -1

ignored_fields = {"provider", "region", "vpc_name"}
for field in ignored_fields:
if cluster_args.get(field):
logger.warning(f"Ignoring '{field}' argument when pool is provided")
cluster_args.pop(field, None)
else:
launcher = launcher.lower() if launcher else configs.launcher
if launcher not in LauncherType.strings():
raise ValueError(
f"Invalid launcher type '{launcher}'. Must be one of {LauncherType.strings()}."
)

if vpc_name and launcher and launcher == "local":
raise ValueError(
"Custom VPCs are not supported with local launching. To use a custom VPC, please use the "
"Den launcher. For more information see "
"https://www.run.house/docs/installation-setup#den-launcher"
)

cluster_args = locals().copy()
cluster_args = {k: v for k, v in cluster_args.items() if v is not None}
if "accelerators" in cluster_args:
logger.warning(
"``accelerators`` argument has been deprecated. Please use ``gpus`` argument instead."
Expand Down

0 comments on commit 0faa465

Please sign in to comment.