Skip to content

Commit

Permalink
Simplify Autostop More
Browse files Browse the repository at this point in the history
  • Loading branch information
dongreenberg committed Jun 14, 2024
1 parent 0943f0a commit b628123
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions runhouse/servers/autostop_servlet.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b628123

Please sign in to comment.