class_docstr: A handler for check-ins for a given run.
  
  Uses filesystem to store the check-ins. Handles resumed `Run`s.
  Background thread is used to adjust the rate of check-ins written
  to the filesystem in order to avoid overloading.
  
  Calling `report_successful_finish()` is required to mark the run as
  finished, otherwise the run will be marked as failed.
class_docstr_tok: ["A","handler","for","check-ins","for","a","given","run",".","Uses","filesystem","to","store","the","check-ins",".","Handles","resumed","`","Run","`","s",".","Background","thread","is","used","to","adjust","the","rate","of","check-ins","written","to","the","filesystem","in","order","to","avoid","overloading",".","Calling","`","report_successful_finish","(",")","`","is","required","to","mark","the","run","as","finished",",","otherwise","the","run","will","be","marked","as","failed","."]
code: def __init__(
      self,
      run_hash: str,
      file_mgr: FileManager,
  ) -> None:
      logger.info(f"creating RunStatusReporter for {run_hash}")
      self.run_hash = run_hash
  
      self.file_manager = file_mgr
      logger.debug(f"polling for check-ins in {self.file_manager}")
  
      # Detect if the run was resumed. If so, we need to find the last
      # check-in index and continue counting from there.
      leftover = CheckIn.poll(
          file_mgr=self.file_manager,
          run_hash=self.run_hash,
      )
      if leftover:
          logger.debug(f"leftover check-in: {leftover}")
      else:
          logger.debug("no leftover check-in found. starting from zero")
  
      self.refresh_condition = threading.Condition()
      self.flush_condition = threading.Condition()
      self.stop_signal = threading.Event()
  
      # A single lock is used to syncronize all the check-ins API calls.
      # (calls are non-blocking so no need to worry about the performance)
      self.reporter_lock = threading.RLock()
      self.counter = leftover.idx
  
      # A shared queue for all flags and check-ins is used to avoid having a
      # separate thread for each flag. The queue is sorted by the time when
      # the check-in is expected to be expired.
      #
      # The `last_check_ins` is used to store the last check-in for each flag
      # while `physical_check_ins` is used to store the check-ins that are
      # already written to the filesystem. These are designed to be eventually
      # consistent.
      #
      # The Priority Queue implementation does not allow to update the priority
      # of the existing items, so we need to remove the item and re-insert it
      # with the new priority. This is done by setting `overwritten` flag to
      # `True` and inserting the new item with the same `flag_name`.
      # The `timed_tasks` is used to find the older items to set `overwritten`
      self.queue = queue.PriorityQueue()
      self.last_check_ins: Dict[str, CheckIn] = dict()
      self.physical_check_ins: Dict[str, CheckIn] = dict()
      self.timed_tasks: Dict[str, TimedTask] = dict()
  
      # We always set the first check-in `starting`.
      logger.info(f"starting from: {self.last_check_ins}")
      self._increment(flag_name="starting")
      # Initialize the background thread and flush all the initial flags
      logger.info(f"starting writer thread for {self}")
      self.thread = threading.Thread(target=self._writer, daemon=True)
      self.thread.start()
      self.flush(block=True)
  
      # The code below is a workaround to make it accessible from the class
      # interface. This can be especially useful for reporting progress from
      # anywhere in the code.
      self.instances.add(self)
      # We need to patch certain methods to make them
      # available both as instance and class methods.
      self.check_in = self._check_in
      self.report_successful_finish = self._report_successful_finish
  
imports: import math
  import time
  import queue
  import threading
  from collections import defaultdict
  from dataclasses import dataclass, field
  from pathlib import Path
  from typing import ClassVar, Dict, Optional, Tuple, Set, Union, TYPE_CHECKING
  from cachetools import LRUCache
  from aim.sdk.reporter.file_manager import FileManager
  import logging
label_desc: Use image node_id 1 to create a new RunStatusReporter object  with example: obj = RunStatusReporter(run_hash, file_mgr)