mirror of
https://github.com/wassname/ray.git
synced 2026-07-20 12:40:20 +08:00
[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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user