From 6e73be4ff7482161667d4dcab7a4d90c6cd8c80c Mon Sep 17 00:00:00 2001 From: Caroline Date: Wed, 11 Dec 2024 14:50:44 -0500 Subject: [PATCH] Properly override allowed cluster factory arguments --- runhouse/resources/hardware/cluster_factory.py | 9 +++++++++ runhouse/resources/hardware/on_demand_cluster.py | 3 +++ 2 files changed, 12 insertions(+) diff --git a/runhouse/resources/hardware/cluster_factory.py b/runhouse/resources/hardware/cluster_factory.py index 520a3d76e..46af4772d 100644 --- a/runhouse/resources/hardware/cluster_factory.py +++ b/runhouse/resources/hardware/cluster_factory.py @@ -123,6 +123,12 @@ def cluster( # If the the user changed the image and wants to restart the server to apply the new # changes, we need to update the image in the cluster object c.image = image or c.image + if kwargs.get("autostop_mins") and c.autostop_mins != kwargs.get( + "autostop_mins" + ): + c.autostop_mins = kwargs.get("autostop_mins") + if launcher: + c.launcher = launcher if den_auth: c.save() return c @@ -443,6 +449,9 @@ def ondemand_cluster( # If the the user changed the image and wants to restart the server to apply the new # changes, we need to update the image in the cluster object c.image = image or c.image + if autostop_mins and autostop_mins != c.autostop_mins: + c.autostop_mins = autostop_mins + c.launcher = launcher or c.launcher if den_auth: c.save() return c diff --git a/runhouse/resources/hardware/on_demand_cluster.py b/runhouse/resources/hardware/on_demand_cluster.py index 9c0edc9c6..fefbe896b 100644 --- a/runhouse/resources/hardware/on_demand_cluster.py +++ b/runhouse/resources/hardware/on_demand_cluster.py @@ -177,6 +177,9 @@ def autostop_mins(self): @autostop_mins.setter def autostop_mins(self, mins): self._autostop_mins = mins + if not self.is_up(): + return + if self.on_this_cluster(): obj_store.set_cluster_config_value("autostop_mins", mins) else: