class_docstr: Helper class for managing the run/training loop.
  
  The context will hide the implementation details of a basic run/training loop.
  It will set things up properly, tell if run should be stopped, and then cleans up.
  User should call update periodically and use should_stop to determine if run should be stopped.
  
  Args:
      submit_config: The SubmitConfig that is used for the current run.
      config_module: (deprecated) The whole config module that is used for the current run.
class_docstr_tok: ["Helper","class","for","managing","the","run\/training","loop",".","The","context","will","hide","the","implementation","details","of","a","basic","run\/training","loop",".","It","will","set","things","up","properly",",","tell","if","run","should","be","stopped",",","and","then","cleans","up",".","User","should","call","update","periodically","and","use","should_stop","to","determine","if","run","should","be","stopped",".","Args",":","submit_config",":","The","SubmitConfig","that","is","used","for","the","current","run",".","config_module",":","(","deprecated",")","The","whole","config","module","that","is","used","for","the","current","run","."]
code: def __init__(
      self,
      submit_config: submit.SubmitConfig,
      config_module: types.ModuleType = None,
  ):
      global _run_context
      # Only a single RunContext can be alive
      assert _run_context is None
      _run_context = self
      self.submit_config = submit_config
      self.should_stop_flag = False
      self.has_closed = False
      self.start_time = time.time()
      self.last_update_time = time.time()
      self.last_update_interval = 0.0
      self.progress_monitor_file_path = None
  
      # vestigial config_module support just prints a warning
      if config_module is not None:
          print(
              "RunContext.config_module parameter support has been removed."
          )
  
      # write out details about the run to a text file
      self.run_txt_data = {
          "task_name": submit_config.task_name,
          "host_name": submit_config.host_name,
          "start_time": datetime.datetime.now().isoformat(sep=" "),
      }
      with open(
          os.path.join(submit_config.run_dir, "run.txt"), "w"
      ) as f:
          pprint.pprint(
              self.run_txt_data,
              stream=f,
              indent=4,
              width=200,
              compact=False,
          )
  
file_path: insightface/reconstruction/ostec/external/stylegan2/dnnlib/submission/run_context.py
imports: import datetime
  import os
  import pprint
  import time
  import types
  from typing import Any
  from .None import submit
label_desc: Use image node_id 1 to create a new RunContext object from inherited base classes: object with example: obj = RunContext(submit_config, config_module)