[tune] Asynchronous saves (#6912)

* Support asynchronous saves

* Fix merge issues

* Add test, fix existing tests

* More informative warning

* Lint, remove print statements

* Address comments, add checkpoint.is_resolved fn

* Add more detailed comments
This commit is contained in:
Ujval Misra
2020-02-09 12:17:45 -08:00
committed by GitHub
parent 0648bd28ef
commit 98a07fe37e
10 changed files with 254 additions and 128 deletions
+14 -1
View File
@@ -13,7 +13,8 @@ class Checkpoint:
Attributes:
storage (str): Storage type.
value (str): If storage==MEMORY, it is a Python object.
If storage==PERSISTENT, it is a path to persistent storage.
If storage==PERSISTENT, it is a path to persistent storage,
or a future that will be resolved to such a path.
"""
MEMORY = "memory"
@@ -29,6 +30,18 @@ class Checkpoint:
"""Creates a checkpoint from a Python object."""
return Checkpoint(Checkpoint.MEMORY, value)
@property
def is_ready(self):
"""Returns whether the checkpoint is ready to be used for restoration.
A PERSISTENT checkpoint is considered ready once its value is resolved
to an actual path. MEMORY checkpoints are always considered ready since
they are transient.
"""
if self.storage == Checkpoint.PERSISTENT:
return isinstance(self.value, str)
return self.storage == Checkpoint.MEMORY
class QueueItem:
def __init__(self, priority, value):