code: def run_app_commands(file: str) -> None:
      """Extract all lines at the top of the file which contain commands & execute them.
  
      Commands to execute are comment lines whose first non-whitespace character begins with the "bang" symbol (`!`).
      After the first non comment line we stop parsing the rest of the file. Running environment is preserved in the
      subprocess shell.
  
      For example:
  
      # some file           <--- not a command # !echo "hello world" <--- a command # ! pip install foo   <--- a command #
      foo! bar            <--- not a command import lightning      <--- not a command, end parsing.
  
      where `echo "hello world" && pip install foo` would be executed in the current running environment.
  
      """
      cl = _extract_commands_from_file(file_name=file)
      if len(cl.commands) == 0:
          logger.debug("No in app commands to install.")
          return
      _execute_app_commands(cl=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 3 for calling a global function with example usage: run_app_commands(file) without return types