class_docstr: ``CheckpointContext`` gives access to checkpoint-related features of a Determined cluster.
class_docstr_tok: ["``","CheckpointContext","``","gives","access","to","checkpoint-related","features","of","a","Determined","cluster","."]
docstr: Download the contents of a checkpoint from checkpoint storage into a directory specified by
  ``ckpt_dir``, which is created if it does not exist.
  
  .. note::
  
      This ``.download()`` method is similar to but less flexible than the ``.download()``
      method of the :class:`~determined.experiment.common.Checkpoint` class in the Determined
      Python SDK.  This ``.download()`` is here as a convenience.
docstr_tok: ["Download","the","contents","of","a","checkpoint","from","checkpoint","storage","into","a","directory","specified","by","``","ckpt_dir","``",",","which","is","created","if","it","does","not","exist",".","..","note",":",":","This","``",".download","(",")","``","method","is","similar","to","but","less","flexible","than","the","``",".download","(",")","``","method","of","the",":","class",":","`","~determined.experiment.common.Checkpoint","`","class","in","the","Determined","Python","SDK",".","This","``",".download","(",")","``","is","here","as","a","convenience","."]
code: def download(
      self,
      storage_id: str,
      ckpt_dir: Union[str, os.PathLike],
      download_mode: DownloadMode = DownloadMode.LocalWorkersShareDownload,
      *,
      selector: Optional[Callable[[str], bool]] = None,
  ) -> None:
      """
      Download the contents of a checkpoint from checkpoint storage into a directory specified by
      ``ckpt_dir``, which is created if it does not exist.
  
      .. note::
  
          This ``.download()`` method is similar to but less flexible than the ``.download()``
          method of the :class:`~determined.experiment.common.Checkpoint` class in the Determined
          Python SDK.  This ``.download()`` is here as a convenience.
      """
      ckpt_dir = os.fspath(ckpt_dir)
      download_mode = DownloadMode(download_mode)
  
      if download_mode == DownloadMode.NoSharedDownload:
          self._storage_manager.download(
              src=storage_id, dst=ckpt_dir, selector=selector
          )
          return
  
      want_filter = any(self._dist.allgather(selector is not None))
  
      # LocalWorkersShareDownload case.
      if self._dist.local_rank == 0:
  
          def _selector(path: str) -> bool:
              if not want_filter:
                  return True
              # If anyone has a selector, coordinate every filename across workers' filters.
              # Functions can't be reliably serialized, so instead we pass each filename between
              # all workers. But because this traffic is local (unix sockets by default) it
              # should be far faster than any download.
              _ = self._dist.broadcast_local(path)
              # If selector is None return True => all files will be downloaded.
              upload_path = self._dist.gather_local(
                  selector(path) if selector is not None else True
              )
              # Upload_path is not None when we are on the local chief.
              assert upload_path
              return any(upload_path)
  
          self._storage_manager.download(
              src=storage_id, dst=ckpt_dir, selector=_selector
          )
          # Tell local workers we finished.
          _ = self._dist.broadcast_local(None)
      else:
          while True:
              name = self._dist.broadcast_local(None)
              if name is None:
                  # Chief is done downloading files.
                  break
              assert (
                  want_filter
              ), "want_filter is not set but name was not None"
              _ = self._dist.gather_local(
                  selector(name) if selector is not None else True
              )
  
imports: import contextlib
  import datetime
  import enum
  import hashlib
  import json
  import logging
  import os
  import pathlib
  import uuid
  from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Union
  from determined import core, tensorboard
  from determined.common import api, storage
  from determined.common.api import bindings
label_desc: Use image node_id 7 for calling the CheckpointContext obj's underlying member method code with example usage: obj.download(storage_id, ckpt_dir, download_mode) and returns: any, True