-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0943f0a
commit b628123
Showing
1 changed file
with
4 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |