code: def stop(args: Dict[str, Any]) -> None:
      """executes the `caliban stop` cli command"""
  
      user = current_user()
      xgroup = args.get("xgroup")
      dry_run = args.get("dry_run", False)
  
      # querying and stopping jobs can take a long time, especially on CAIP,
      # so we check with the user up-front rather than waiting for our full
      # query to return
      if not dry_run and not user_verify(
          f"Warning: this will potentially stop many jobs, do you wish to continue?",
          False,
      ):
          return
  
      with session_scope(get_sql_engine()) as session:
          running_jobs = (
              session.query(Job)
              .join(Experiment)
              .join(ExperimentGroup)
              .filter(
                  or_(
                      Job.status == JobStatus.SUBMITTED,
                      Job.status == JobStatus.RUNNING,
                  )
              )
          )
  
          if xgroup is not None:
              running_jobs = running_jobs.filter(
                  ExperimentGroup.name == xgroup
              )
  
          running_jobs = running_jobs.all()
  
          if len(running_jobs) == 0:
              logging.info(f"no running jobs found")
              return
  
          logging.info(f"the following jobs will be stopped:")
          for j in running_jobs:
              logging.info(_experiment_command_str(j.experiment))
              logging.info(f"    job {_job_str(j)}")
  
          if dry_run:
              logging.info(
                  f"to actually stop these jobs, re-run the command without "
                  f"the --dry_run flag"
              )
              return
  
          for j in running_jobs:
              logging.info(f"stopping job: {_job_str(j)}")
              stop_job(j)
  
          logging.info(
              f"requested job cancellation, please be patient as it may take "
              f"a short while for this status change to be reflected in the "
              f"gcp dashboard or from the `caliban status` command."
          )
  
imports: import logging
  import os
  from typing import Any, Dict, Iterable, List, Optional
  from sqlalchemy import or_
  from sqlalchemy.orm import Session
  from caliban.docker.build import build_image
  from caliban.docker.push import push_uuid_tag
  from caliban.history.submit import submit_job_specs
  from caliban.history.types import ContainerSpec, Experiment, ExperimentGroup, Job, JobStatus, Platform
  from caliban.history.util import get_gke_job_name, get_sql_engine, replace_job_spec_image, session_scope, stop_job, update_job_status
  from caliban.platform.gke.util import credentials, user_verify
  from caliban.util import Package, current_user
label_desc: Use image node_id 8 for calling a global function with example usage: stop(args) without return types