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: ``store_path()`` is a context manager which chooses a random path and prepares a directory
  you should save your model to.  When the context manager exits, the model is automatically
  uploaded (at least, for cloud-backed checkpoint storage backends).
  
  .. note::
      metadata must include a 'steps_completed' key in the current implementation.
      Raises ValueError if the 'steps_completed' key is not present in the metadata
      dictionary.
  
  
  When ``shard=False``, only the chief worker (``distributed.rank==0``) may call
  ``store_path()``.
  
  When ``shard=True``, ``store_path()`` becomes a synchronization point between workers, so
  all workers must call store_path(), even workers which will not write any checkpoint files.
  
  Example:
  
  .. code::
  
     if core_context.distributed.rank == 0:
         with core_context.checkpoint.store_path(shard=False) as (path, storage_id):
             my_save_model(my_model, path)
             print(f"done saving checkpoint {storage_id}")
         print(f"done uploading checkpoint {storage_id}")
docstr_tok: ["``","store_path","(",")","``","is","a","context","manager","which","chooses","a","random","path","and","prepares","a","directory","you","should","save","your","model","to",".","When","the","context","manager","exits",",","the","model","is","automatically","uploaded","(","at","least",",","for","cloud-backed","checkpoint","storage","backends",")",".","..","note",":",":","metadata","must","include","a","'steps_completed","'","key","in","the","current","implementation",".","Raises","ValueError","if","the","'steps_completed","'","key","is","not","present","in","the","metadata","dictionary",".","When","``","shard=False","``",",","only","the","chief","worker","(","``","distributed.rank==0","``",")","may","call","``","store_path","(",")","``",".","When","``","shard=True","``",",","``","store_path","(",")","``","becomes","a","synchronization","point","between","workers",",","so","all","workers","must","call","store_path","(",")",",","even","workers","which","will","not","write","any","checkpoint","files",".","Example",":","..","code",":",":","if","core_context.distributed.rank","==","0",":","with","core_context.checkpoint.store_path","(","shard=False",")","as","(","path",",","storage_id",")",":","my_save_model","(","my_model",",","path",")","print","(","f","''","done","saving","checkpoint","{","storage_id","}","''",")","print","(","f","''","done","uploading","checkpoint","{","storage_id","}","''",")"]
code: def store_path(
      self,
      metadata: Optional[Dict[str, Any]] = None,
      *,
      shard: bool = False,
  ) -> Iterator[Tuple[pathlib.Path, str]]:
      """
      ``store_path()`` is a context manager which chooses a random path and prepares a directory
      you should save your model to.  When the context manager exits, the model is automatically
      uploaded (at least, for cloud-backed checkpoint storage backends).
  
      .. note::
          metadata must include a 'steps_completed' key in the current implementation.
          Raises ValueError if the 'steps_completed' key is not present in the metadata
          dictionary.
  
  
      When ``shard=False``, only the chief worker (``distributed.rank==0``) may call
      ``store_path()``.
  
      When ``shard=True``, ``store_path()`` becomes a synchronization point between workers, so
      all workers must call store_path(), even workers which will not write any checkpoint files.
  
      Example:
  
      .. code::
  
         if core_context.distributed.rank == 0:
             with core_context.checkpoint.store_path(shard=False) as (path, storage_id):
                 my_save_model(my_model, path)
                 print(f"done saving checkpoint {storage_id}")
             print(f"done uploading checkpoint {storage_id}")
      """
      if not shard:
          return self._store_path_single(metadata)
      else:
          return self._store_path_sharded(metadata)
  
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 9 for calling the CheckpointContext obj's underlying member method code with example usage: obj.store_path(metadata) and returns: self, self