code: def _extract_commands_from_file(file_name: str) -> CommandLines:
      """Extract all lines at the top of the file which contain commands to execute.
  
      The return struct contains a list of commands to execute with the corresponding line number the command executed on.
  
      """
      cl = CommandLines(
          file=file_name,
      )
      with open(file_name) as f:
          file_lines = f.readlines()
  
      for line_number, line in enumerate(file_lines):
          line = line.strip()
          if line in APP_COMMAND_LINES_TO_IGNORE:
              continue
  
          # stop parsing at first non-comment line at top of file
          if not line.startswith("#"):
              continue
  
          # remove comment marker and any leading / trailing whitespaces
          line = line.lstrip("#").strip()
          if len(line) == 0:
              # do not stop parsing on empty on comment lines
              continue
  
          # only run commands starting with a bang (!) & strip the bang from the executed command.
          if line[0] != "!":
              continue
          line = line[1:].strip()
  
          cl.commands.append(line)
          # add 1 to line number because enumerate returns indexes starting at 0, while
          # text exitors list lines beginning at index 1.
          cl.line_numbers.append(line_number + 1)
  
      return cl
  
file_path: pytorch-lightning/src/lightning/app/utilities/app_commands.py
imports: import logging
  import os
  import subprocess
  from dataclasses import dataclass, field
  from typing import List
  from lightning.app.utilities.exceptions import MisconfigurationException
label_desc: Use image node_id 1 for calling a global function with example usage: _extract_commands_from_file(file_name) and returns: cl