code: def run_bash_command(workload: str, timeout: float):
      timeout = timeout if timeout > 0 else None
      cwd = Path.cwd()
      workload_path = cwd / "workload.sh"
      workload_path = workload_path.resolve()
      with open(workload_path, "w") as fp:
          fp.write(workload)
  
      command = ["bash", "-x", str(workload_path)]
      logger.info(f"Running command {workload}")
  
      # Pop job's runtime env to allow workload's runtime env to take precedence
      # TODO: Confirm this is safe
      os.environ.pop("RAY_JOB_CONFIG_JSON_ENV_VAR", None)
  
      # We use multiprocessing with 'spawn' context to avoid
      # forking (as happens when using subprocess directly).
      # Forking messes up Ray interactions and causes deadlocks.
      return_code = None
      try:
          ctx = multiprocessing.get_context("spawn")
          p = ctx.Process(
              target=_run_bash_command_subprocess,
              args=(command, timeout),
          )
          p.start()
          logger.info(f"Starting process {p.pid}.")
          # Add a little extra to the timeout as _run_bash_command_subprocess
          # also has a timeout internally and it's cleaner to use that
          p.join(timeout=timeout + 10)
      except multiprocessing.TimeoutError:
          return_code = TIMEOUT_RETURN_CODE
      except multiprocessing.ProcessError:
          pass
      finally:
          if p.is_alive():
              logger.warning(f"Terminating process {p.pid} forcefully.")
              p.terminate()
          if return_code is None:
              return_code = p.exitcode
          os.remove(str(workload_path))
      logger.info(
          f"Process {p.pid} exited with return code {return_code}."
      )
      assert return_code is not None
      return return_code
  
file_path: ray/release/ray_release/command_runner/_anyscale_job_wrapper.py
imports: import argparse
  import time
  import os
  from pathlib import Path
  import subprocess
  import multiprocessing
  import json
  import sys
  import logging
  from urllib.parse import urlparse
  from typing import Optional, List, Tuple
label_desc: Use image node_id 6 for calling a global function with example usage: run_bash_command(workload, timeout) and returns: return_code