Atomicity Types#

Defines the types and Protocols for creating and finalizing temporary paths.

Chiefly defines the TemporaryPath Protocol for creating and finalizing temporary paths, which allow other implementations.

TemporaryPath#

class orbax.checkpoint.path.atomicity_types.TemporaryPath[source]#

Class that represents a temporary path.

Importantly, the temporary path always has a corresponding finalized path, and is primarily constructed from this path. The class contains logic to create the temporary path, and to finalize it into the final path.

from_final should be called from all hosts to construct the temporary path instance from the given final path. create and finalize must be called only on the primary host.

abstractmethod async classmethod validate(temporary_path)[source]#

Validates the temporary path or raises a ValidationError.

abstractmethod async classmethod validate_final(final_path)[source]#

Validates the final path or raises a ValidationError.

abstractmethod classmethod from_temporary(temporary_path, *, file_options=None, snapshot_type=None)[source]#

Creates a TemporaryPath from a temporary path.

Return type:

TemporaryPath

abstractmethod classmethod from_final(final_path, *, checkpoint_metadata_store=None, file_options=None, snapshot_type=None)[source]#

Creates a TemporaryPath from a final path.

Return type:

TemporaryPath

abstractmethod get()[source]#

Constructs the temporary path without actually creating it.

Return type:

Path

abstractmethod get_final()[source]#

Returns the final path without creating it.

Return type:

Path

abstractmethod async create()[source]#

Creates the temporary path on disk.

NOTE: This method should be only called on the primary host.

Return type:

Path

Returns:

The created temporary path.

abstractmethod async finalize()[source]#

Finalizes the temporary path into the final path.

NOTE: This method should be only called on the primary host.

This function is called from a background thread.

Return type:

None