class_docstr: A reference to data persisted as a directory in local or remote storage.
  
  Access the checkpoint contents locally using ``checkpoint.to_directory()``
  or ``checkpoint.as_directory``.
  
  Example creating a checkpoint using ``Checkpoint.from_directory``:
  
      >>> from ray.train import Checkpoint
      >>> checkpoint = Checkpoint.from_directory("/tmp/example_checkpoint_dir")
      >>> checkpoint.filesystem  # doctest: +ELLIPSIS
      <pyarrow._fs.LocalFileSystem object...
      >>> checkpoint.path
      '/tmp/example_checkpoint_dir'
  
  Example creating a checkpoint from a remote URI:
  
      >>> checkpoint = Checkpoint("s3://bucket/path/to/checkpoint")
      >>> checkpoint.filesystem  # doctest: +ELLIPSIS
      <pyarrow._s3fs.S3FileSystem object...
      >>> checkpoint.path
      'bucket/path/to/checkpoint'
  
  Example creating a checkpoint with a custom filesystem:
  
      >>> checkpoint = Checkpoint(
      ...     path="bucket/path/to/checkpoint",
      ...     filesystem=pyarrow.fs.S3FileSystem(),
      ... )
      >>> checkpoint.filesystem  # doctest: +ELLIPSIS
      <pyarrow._s3fs.S3FileSystem object...
      >>> checkpoint.path
      'bucket/path/to/checkpoint'
  
  Attributes:
      path: A path on the filesystem containing the checkpoint contents.
      filesystem: PyArrow FileSystem that can be used to access data at the `path`.
class_docstr_tok: ["A","reference","to","data","persisted","as","a","directory","in","local","or","remote","storage",".","Access","the","checkpoint","contents","locally","using","``","checkpoint.to_directory","(",")","``","or","``","checkpoint.as_directory","``",".","Example","creating","a","checkpoint","using","``","Checkpoint.from_directory","``",":",">",">",">","from","ray.train","import","Checkpoint",">",">",">","checkpoint","=","Checkpoint.from_directory","(","``","\/tmp\/example_checkpoint_dir","''",")",">",">",">","checkpoint.filesystem","#","doctest",":","+ELLIPSIS","<","pyarrow._fs.LocalFileSystem","object","...",">",">",">","checkpoint.path","'\/tmp\/example_checkpoint_dir'","Example","creating","a","checkpoint","from","a","remote","URI",":",">",">",">","checkpoint","=","Checkpoint","(","``","s3",":","\/\/bucket\/path\/to\/checkpoint","''",")",">",">",">","checkpoint.filesystem","#","doctest",":","+ELLIPSIS","<","pyarrow._s3fs.S3FileSystem","object","...",">",">",">","checkpoint.path","'bucket\/path\/to\/checkpoint'","Example","creating","a","checkpoint","with","a","custom","filesystem",":",">",">",">","checkpoint","=","Checkpoint","(","...","path=","''","bucket\/path\/to\/checkpoint","''",",","...","filesystem=pyarrow.fs.S3FileSystem","(",")",",","...",")",">",">",">","checkpoint.filesystem","#","doctest",":","+ELLIPSIS","<","pyarrow._s3fs.S3FileSystem","object","...",">",">",">","checkpoint.path","'bucket\/path\/to\/checkpoint'","Attributes",":","path",":","A","path","on","the","filesystem","containing","the","checkpoint","contents",".","filesystem",":","PyArrow","FileSystem","that","can","be","used","to","access","data","at","the","`","path","`","."]
docstr: Construct a Checkpoint.
  
  Args:
      path: A local path or remote URI containing the checkpoint data.
          If a filesystem is provided, then this path must NOT be a URI.
          It should be a path on the filesystem with the prefix already stripped.
      filesystem: PyArrow FileSystem to use to access data at the path.
          If not specified, this is inferred from the URI scheme.
docstr_tok: ["Construct","a","Checkpoint",".","Args",":","path",":","A","local","path","or","remote","URI","containing","the","checkpoint","data",".","If","a","filesystem","is","provided",",","then","this","path","must","NOT","be","a","URI",".","It","should","be","a","path","on","the","filesystem","with","the","prefix","already","stripped",".","filesystem",":","PyArrow","FileSystem","to","use","to","access","data","at","the","path",".","If","not","specified",",","this","is","inferred","from","the","URI","scheme","."]
code: def __init__(
      self,
      path: Union[str, os.PathLike],
      filesystem: Optional["pyarrow.fs.FileSystem"] = None,
  ):
      """Construct a Checkpoint.
  
      Args:
          path: A local path or remote URI containing the checkpoint data.
              If a filesystem is provided, then this path must NOT be a URI.
              It should be a path on the filesystem with the prefix already stripped.
          filesystem: PyArrow FileSystem to use to access data at the path.
              If not specified, this is inferred from the URI scheme.
      """
      self.path = str(path)
      self.filesystem = filesystem
  
      if path and not filesystem:
          self.filesystem, self.path = pyarrow.fs.FileSystem.from_uri(
              path
          )
  
      # This random UUID is used to create a temporary directory name on the
      # local filesystem, which will be used for downloading checkpoint data.
      # This ensures that if multiple processes download the same checkpoint object
      # only one process performs the actual download while the others wait.
      # This prevents duplicated download efforts and data.
      # NOTE: Calling `to_directory` from multiple `Checkpoint` objects
      # that point to the same (fs, path) will still download the data multiple times.
      # This only ensures a canonical temp directory name for a single `Checkpoint`.
      self._uuid = uuid.uuid4()
  
imports: import contextlib
  import glob
  import json
  import logging
  import os
  import platform
  import shutil
  import tempfile
  import traceback
  import uuid
  from typing import Any, Dict, Iterator, List, Optional, Union
  import pyarrow.fs
  from ray.air._internal.filelock import TempFileLock
  from ray.train._internal.storage import _download_from_fs_path, _exists_at_fs_path
  from ray.util.annotations import PublicAPI
label_desc: Use image node_id 1 to create a new Checkpoint object  with example: obj = Checkpoint(path, filesystem)