code: def _process_command_requests(app, request: _CommandRequest):
      for command in app.commands:
          for command_name, method in command.items():
              command_name = command_name.replace(" ", "_")
              if request.method_name == command_name:
                  # 2.1: Evaluate the method associated to a specific command.
                  # Validation is done on the CLI side.
                  try:
                      response = _RequestResponse(
                          content=method(
                              *request.args, **request.kwargs
                          ),
                          status_code=200,
                      )
                  except HTTPException as ex:
                      logger.error(repr(ex))
                      response = _RequestResponse(
                          status_code=ex.status_code, content=ex.detail
                      )
                  except Exception:
                      logger.error(traceback.print_exc())
                      response = _RequestResponse(status_code=500)
                  return {"response": response, "id": request.id}
      return None
  
imports: import errno
  import inspect
  import os
  import os.path
  import shutil
  import sys
  import traceback
  from dataclasses import asdict
  from getpass import getuser
  from importlib.util import module_from_spec, spec_from_file_location
  from tempfile import gettempdir
  from typing import Any, Callable, Dict, List, Optional, Union
  import requests
  from fastapi import HTTPException
  from pydantic import BaseModel
  from lightning.app.api.http_methods import Post
  from lightning.app.api.request_types import _APIRequest, _CommandRequest, _RequestResponse
  from lightning.app.utilities import frontend
  from lightning.app.utilities.app_helpers import Logger, is_overridden
  from lightning.app.utilities.cloud import _get_project
  from lightning.app.utilities.network import LightningClient
  from lightning.app.utilities.state import AppState
label_desc: Use image node_id 8 for calling a global function with example usage: _process_command_requests(app, request) and returns: None, dict