class_docstr: An implementation of the data store using S3 for storing policy checkpoints when using Coach in distributed mode.
  The policy checkpoints are written by the trainer and read by the rollout worker.
class_docstr_tok: ["An","implementation","of","the","data","store","using","S3","for","storing","policy","checkpoints","when","using","Coach","in","distributed","mode",".","The","policy","checkpoints","are","written","by","the","trainer","and","read","by","the","rollout","worker","."]
docstr: load_from_store() downloads a new checkpoint from the S3 data store when it is not available locally. It is used
  by the rollout workers when using Coach in distributed mode.
docstr_tok: ["load_from_store","(",")","downloads","a","new","checkpoint","from","the","S3","data","store","when","it","is","not","available","locally",".","It","is","used","by","the","rollout","workers","when","using","Coach","in","distributed","mode","."]
code: def load_from_store(self):
      """
      load_from_store() downloads a new checkpoint from the S3 data store when it is not available locally. It is used
      by the rollout workers when using Coach in distributed mode.
      """
      try:
          state_file = CheckpointStateFile(
              os.path.abspath(self.params.checkpoint_dir)
          )
  
          # wait until lock is removed
          while True:
              objects = self.mc.list_objects_v2(
                  self.params.bucket_name, SyncFiles.LOCKFILE.value
              )
  
              if next(objects, None) is None:
                  try:
                      # fetch checkpoint state file from S3
                      self.mc.fget_object(
                          self.params.bucket_name,
                          state_file.filename,
                          state_file.path,
                      )
                  except Exception as e:
                      continue
                  break
              time.sleep(10)
  
          # Check if there's a finished file
          objects = self.mc.list_objects_v2(
              self.params.bucket_name, SyncFiles.FINISHED.value
          )
  
          if next(objects, None) is not None:
              try:
                  self.mc.fget_object(
                      self.params.bucket_name,
                      SyncFiles.FINISHED.value,
                      os.path.abspath(
                          os.path.join(
                              self.params.checkpoint_dir,
                              SyncFiles.FINISHED.value,
                          )
                      ),
                  )
              except Exception as e:
                  pass
  
          # Check if there's a ready file
          objects = self.mc.list_objects_v2(
              self.params.bucket_name, SyncFiles.TRAINER_READY.value
          )
  
          if next(objects, None) is not None:
              try:
                  self.mc.fget_object(
                      self.params.bucket_name,
                      SyncFiles.TRAINER_READY.value,
                      os.path.abspath(
                          os.path.join(
                              self.params.checkpoint_dir,
                              SyncFiles.TRAINER_READY.value,
                          )
                      ),
                  )
              except Exception as e:
                  pass
  
          checkpoint_state = state_file.read()
          if checkpoint_state is not None:
              objects = self.mc.list_objects_v2(
                  self.params.bucket_name,
                  prefix=checkpoint_state.name,
                  recursive=True,
              )
              for obj in objects:
                  filename = os.path.abspath(
                      os.path.join(
                          self.params.checkpoint_dir, obj.object_name
                      )
                  )
                  if not os.path.exists(filename):
                      self.mc.fget_object(
                          obj.bucket_name, obj.object_name, filename
                      )
  
      except S3Error as e:
          screen.print("Got exception: %s\n while loading from S3", e)
  
imports: from rl_coach.data_stores.data_store import DataStoreParameters
  from rl_coach.data_stores.checkpoint_data_store import CheckpointDataStore
  from minio import Minio
  from minio.error import S3Error
  from configparser import ConfigParser, Error
  from rl_coach.checkpoint import CheckpointStateFile
  from rl_coach.data_stores.data_store import SyncFiles
  from rl_coach.logger import screen
  import os
  import time
  import io
label_desc: Use image node_id 7 for calling the S3DataStore obj's underlying member method code with example usage: obj.load_from_store() without return types