code: def run_app(arg_input):
      """Main function to run the Caliban app. Accepts a Namespace-type output of an
      argparse argument parser.
  
      """
      args = vars(arg_input)
      script_args = c.extract_script_args(args)
  
      command = args["command"]
  
      if command == "cluster":
          return gke.cli.run_cli_command(args)
  
      job_mode = cli.resolve_job_mode(args)
      docker_args = cli.generate_docker_args(job_mode, args)
      docker_run_args = args.get("docker_run_args", [])
  
      if command == "shell":
          mount_home = not args["bare"]
          image_id = args.get("image_id")
          shell = args["shell"]
          ps.run_interactive(
              job_mode,
              image_id=image_id,
              run_args=docker_run_args,
              mount_home=mount_home,
              shell=shell,
              **docker_args,
          )
  
      elif command == "notebook":
          port = args.get("port")
          lab = args.get("lab")
          version = args.get("jupyter_version")
          mount_home = not args["bare"]
          pn.run_notebook(
              job_mode,
              port=port,
              lab=lab,
              version=version,
              run_args=docker_run_args,
              mount_home=mount_home,
              **docker_args,
          )
  
      elif command == "build":
          package = args["module"]
          b.build_image(job_mode, package=package, **docker_args)
  
      elif command == "status":
          caliban.history.cli.get_status(args)
  
      elif command == "stop":
          caliban.history.cli.stop(args)
  
      elif command == "resubmit":
          caliban.history.cli.resubmit(args)
  
      elif command == "run":
          dry_run = args["dry_run"]
          package = args["module"]
          image_id = args.get("image_id")
          exp_config = args.get("experiment_config")
          xgroup = args.get("xgroup")
  
          pr.run_experiments(
              job_mode,
              run_args=docker_run_args,
              script_args=script_args,
              image_id=image_id,
              experiment_config=exp_config,
              dry_run=dry_run,
              package=package,
              xgroup=xgroup,
              **docker_args,
          )
  
      elif command == "cloud":
          project_id = c.extract_project_id(args)
          region = c.extract_region(args)
          cloud_key = c.extract_cloud_key(args)
  
          dry_run = args["dry_run"]
          package = args["module"]
          job_name = args.get("name")
          gpu_spec = args.get("gpu_spec")
          tpu_spec = args.get("tpu_spec")
          image_tag = args.get("image_tag")
          machine_type = args.get("machine_type")
          exp_config = args.get("experiment_config")
          labels = cu.sanitize_labels(args.get("label") or [])
          xgroup = args.get("xgroup")
  
          # Arguments to internally build the image required to submit to Cloud.
          docker_m = {
              "job_mode": job_mode,
              "package": package,
              **docker_args,
          }
  
          cloud.submit_ml_job(
              job_mode=job_mode,
              docker_args=docker_m,
              region=region,
              project_id=project_id,
              credentials_path=cloud_key,
              dry_run=dry_run,
              job_name=job_name,
              machine_type=machine_type,
              gpu_spec=gpu_spec,
              tpu_spec=tpu_spec,
              image_tag=image_tag,
              labels=labels,
              script_args=script_args,
              experiment_config=exp_config,
              xgroup=xgroup,
          )
      else:
          logging.info("Unknown command: {}".format(command))
          sys.exit(1)
  
file_path: caliban/caliban/main.py
imports: from __future__ import absolute_import, division, print_function
  import logging
  import sys
  from absl import app, logging
  from blessings import Terminal
  import caliban.cli
  import caliban.config
  import caliban.docker.build
  import caliban.history.cli
  import caliban.platform.cloud.core
  import caliban.platform.cloud.util
  import caliban.platform.gke
  import caliban.platform.gke.cli
  import caliban.platform.notebook
  import caliban.platform.run
  import caliban.platform.shell
  import caliban.util.schema
label_desc: Use image node_id 1 for calling a global function with example usage: run_app(arg_input) and returns: gke