Skip to content

Commit 1879740

Browse files
committed
ignore select factory args if pool is provided
1 parent 921ad2d commit 1879740

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

runhouse/resources/hardware/cluster_factory.py

+21-8
Original file line numberDiff line numberDiff line change
@@ -310,21 +310,34 @@ def ondemand_cluster(
310310
>>> # Load cluster from above
311311
>>> reloaded_cluster = rh.ondemand_cluster(name="rh-4-a100s")
312312
"""
313-
launcher = launcher.lower() if launcher else configs.launcher
314-
if launcher not in LauncherType.strings():
315-
raise ValueError(
316-
f"Invalid launcher type '{launcher}'. Must be one of {LauncherType.strings()}."
317-
)
313+
cluster_args = locals().copy()
314+
cluster_args = {k: v for k, v in cluster_args.items() if v is not None}
315+
316+
if pool is not None:
317+
cluster_args["launcher"] = "den"
318+
ignored_fields = {"provider", "region", "vpc_name"}
319+
for field in ignored_fields:
320+
if cluster_args.get(field):
321+
logger.warning(f"Ignoring '{field}' argument when pool is provided")
322+
cluster_args.pop(field, None)
323+
if autostop_mins != -1:
324+
logger.warning(
325+
"Setting autostop on compute launched in a pool is not recommended and will be deprecated."
326+
)
327+
else:
328+
launcher = launcher.lower() if launcher else configs.launcher
329+
if launcher not in LauncherType.strings():
330+
raise ValueError(
331+
f"Invalid launcher type '{launcher}'. Must be one of {LauncherType.strings()}."
332+
)
318333

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

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

0 commit comments

Comments
 (0)