Skip to content

Commit

Permalink
[tune] Make Trainable.save/restore developer APIs (#39391)
Browse files Browse the repository at this point in the history
Signed-off-by: Kai Fricke <kai@anyscale.com>
  • Loading branch information
krfricke committed Sep 7, 2023
1 parent 3e7c8af commit 3e8a1dc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/ray/tune/trainable/trainable.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
from ray.train._internal.syncer import SyncConfig, get_node_to_storage_syncer
from ray.tune.trainable.util import TrainableUtil
from ray.tune.utils.util import Tee, _get_checkpoint_from_remote_node
from ray.util.annotations import PublicAPI
from ray.util.annotations import Deprecated, DeveloperAPI, PublicAPI

if TYPE_CHECKING:
from ray.tune.logger import Logger
Expand Down Expand Up @@ -495,6 +495,7 @@ def _create_checkpoint_dir(
)
return checkpoint_dir

@DeveloperAPI
def save(
self, checkpoint_dir: Optional[str] = None, prevent_upload: bool = False
) -> str:
Expand Down Expand Up @@ -871,6 +872,7 @@ def _maybe_load_from_cloud(

return True

@Deprecated
def save_to_object(self):
raise DeprecationWarning(
"Trainable.save_to_object() has been removed. "
Expand All @@ -884,6 +886,7 @@ def _restore_from_checkpoint_obj(self, checkpoint: Checkpoint):
checkpoint_node_ip=None,
)

@DeveloperAPI
def restore(
self,
checkpoint_path: Union[str, Checkpoint],
Expand Down Expand Up @@ -1072,12 +1075,14 @@ def restore(
}
logger.info("Current state after restoring: %s", state)

@Deprecated
def restore_from_object(self, obj):
raise DeprecationWarning(
"Trainable.restore_from_object() has been removed. "
"Use Trainable.restore() instead."
)

@Deprecated
def delete_checkpoint(self, checkpoint_path: Union[str, Checkpoint]):
"""Deletes local copy of checkpoint.
Expand Down

0 comments on commit 3e8a1dc

Please sign in to comment.