Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate sub-item temporary path class from default temporary path class. #1491

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ def _get_item_temporary_directory(
) -> atomicity_types.TemporaryPath:
temporary_path_class = (
self._temporary_path_class
or atomicity_defaults.get_default_temporary_path_class(directory)
or atomicity_defaults.get_item_default_temporary_path_class(directory)
)
tmp_item_dir = temporary_path_class.from_final(
self._get_item_directory(directory, item_name),
Expand Down
11 changes: 11 additions & 0 deletions checkpoint/orbax/checkpoint/_src/path/atomicity_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,20 @@
from orbax.checkpoint._src.path import step as step_lib


def get_item_default_temporary_path_class(
final_path: epath.Path,
) -> Type[atomicity_types.TemporaryPath]:
"""Returns the default temporary path class for a given sub-item path."""
if step_lib.is_gcs_path(final_path):
return atomicity.CommitFileTemporaryPath
else:
return atomicity.AtomicRenameTemporaryPath


def get_default_temporary_path_class(
final_path: epath.Path,
) -> Type[atomicity_types.TemporaryPath]:
"""Returns the default temporary path class for a given checkpoint path."""
if step_lib.is_gcs_path(final_path):
return atomicity.CommitFileTemporaryPath
else:
Expand Down
Loading