class_docstr: LSF Utilities
class_docstr_tok: ["LSF","Utilities"]
docstr: Returns and sets the static CSM allocation info.
docstr_tok: ["Returns","and","sets","the","static","CSM","allocation","info","."]
code: def get_allocation_info():
      """Returns and sets the static CSM allocation info."""
      if not LSFUtils._csm_allocation_info:
          lsf_allocation_id = os.environ["CSM_ALLOCATION_ID"].strip()
          output = io.StringIO()
          exit_code = safe_shell_exec.execute(
              "{cmd} -a {allocation}".format(
                  cmd=LSFUtils._CSM_ALLOCATION_QUERY,
                  allocation=lsf_allocation_id,
              ),
              stdout=output,
              stderr=output,
          )
          if exit_code != 0:
              raise RuntimeError(
                  "{cmd} failed with exit code {exit_code}".format(
                      cmd=LSFUtils._CSM_ALLOCATION_QUERY,
                      exit_code=exit_code,
                  )
              )
          LSFUtils._csm_allocation_info = yaml.safe_load(
              output.getvalue()
          )
          # Fetch the total number of cores and gpus for the first host
          output = io.StringIO()
          exit_code = safe_shell_exec.execute(
              "{cmd} -n {node}".format(
                  cmd=LSFUtils._CSM_NODE_QUERY,
                  node=LSFUtils._csm_allocation_info["compute_nodes"][
                      0
                  ],
              ),
              stdout=output,
              stderr=output,
          )
          if exit_code != 0:
              raise RuntimeError(
                  "{cmd} failed with exit code {exit_code}".format(
                      cmd=LSFUtils._CSM_NODE_QUERY, exit_code=exit_code
                  )
              )
          node_output = yaml.safe_load(output.getvalue())
          total_core_count = (
              int(node_output["Record_1"]["discovered_cores"])
              - int(node_output["Record_1"]["discovered_sockets"])
              * LSFUtils._csm_allocation_info["isolated_cores"]
          )
          LSFUtils._csm_allocation_info[
              "compute_node_cores"
          ] = total_core_count
          LSFUtils._csm_allocation_info["compute_node_gpus"] = int(
              node_output["Record_1"]["discovered_gpus"]
          )
          # Sorting LSF hostnames
          LSFUtils._csm_allocation_info["compute_nodes"].sort()
      return LSFUtils._csm_allocation_info
  
file_path: horovod/horovod/runner/util/lsf.py
imports: import io
  import os
  import yaml
  from horovod.common.util import _cache
  from horovod.runner.common.util import safe_shell_exec
  from horovod.runner.util.remote import get_remote_command
label_desc: Use image node_id 2 for calling the LSFUtils obj's underlying member method code with example usage: obj.get_allocation_info() and returns: LSFUtils