From b6281230cb1c4f23e1b605682fbc369011a6fd2e Mon Sep 17 00:00:00 2001 From: dongreenberg Date: Fri, 14 Jun 2024 17:46:26 -0400 Subject: [PATCH] Simplify Autostop More --- runhouse/servers/autostop_servlet.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/runhouse/servers/autostop_servlet.py b/runhouse/servers/autostop_servlet.py index 73ffdafc4..ab3ea5930 100644 --- a/runhouse/servers/autostop_servlet.py +++ b/runhouse/servers/autostop_servlet.py @@ -1,25 +1,15 @@ -import time - - class AutostopServlet: """A helper class strictly to run SkyPilot methods on OnDemandClusters inside SkyPilot's conda env.""" def __init__(self): - self._last_activity = time.time() - self._last_register = None + self._activity_registered = False def set_last_active_time_to_now(self): - self._last_activity = time.time() - - def set_autostop(self, value=None): - from sky.skylet import autostop_lib - - self.set_last_active_time_to_now() - autostop_lib.set_autostop(value, None, True) + self._activity_registered = True def update_autostop_in_sky_config(self): from sky.skylet.autostop_lib import set_last_active_time_to_now - if self._last_register is None or self._last_register < self._last_activity: + if self._activity_registered: set_last_active_time_to_now() - self._last_register = self._last_activity + self._activity_registered = False