code: def get_current_session() -> ReportSession:  # type: ignore
      # Hack to get the session object from Streamlit.
      ctx = ReportThread.get_report_ctx()
  
      this_session = None
  
      current_server = Server.get_current()
      if hasattr(current_server, "_session_infos"):
          # Streamlit < 0.56
          session_infos = Server.get_current()._session_infos.values()
      else:
          session_infos = (
              Server.get_current()._session_info_by_id.values()
          )
  
      for session_info in session_infos:
          s = session_info.session
          if (
              (
                  hasattr(s, "_main_dg") and s._main_dg == ctx.main_dg
              )  # Streamlit < 0.54.0
              or (
                  not hasattr(s, "_main_dg")
                  and s.enqueue == ctx.enqueue
              )  # Streamlit >= 0.54.0
              or (
                  not hasattr(s, "_main_dg")
                  and s._uploaded_file_mgr == ctx.uploaded_file_mgr
              )  # Streamlit >= 0.65.2
          ):
              this_session = s
      if this_session is None:
          raise RuntimeError(
              "Oh noes. Couldn't get your Streamlit Session object. "
              "Are you doing something fancy with threads?"
          )
      return this_session
  
file_path: opyrator/src/opyrator/ui/streamlit_utils.py
imports: from typing import Any, Dict
label_desc: Use image node_id 1 for calling a global function with example usage: get_current_session() and returns: this_session