original_docstring: 
      Run Docker container by image hash with args set in command line.
      Function prints the output of run command in stdout.
      
docstring: Run Docker container by image hash with args set in command line.
  Function prints the output of run command in stdout.
docstring_tokens: Run Docker container by image hash with args set in command line . Function prints the output of run command in stdout .
code: def configure_and_run_docker_container(
          docker_client,
          docker_hash,
          service,
          instance,
          cluster,
          system_paasta_config,
          args,
          pull_image=False,
          dry_run=False,
  ):
      """
      Run Docker container by image hash with args set in command line.
      Function prints the output of run command in stdout.
      """
  
      if instance is None and args.healthcheck_only:
          paasta_print(
              "With --healthcheck-only, --instance MUST be provided!",
              file=sys.stderr,
          )
          return 1
      if instance is None and not sys.stdin.isatty():
          paasta_print(
              "--instance and --cluster must be specified when using paasta local-run without a tty!",
              file=sys.stderr,
          )
          return 1
  
      soa_dir = args.yelpsoa_config_root
      volumes = list()
      load_deployments = docker_hash is None or pull_image
      interactive = args.interactive
  
      try:
          if instance is None:
              instance_type = 'adhoc'
              instance = 'interactive'
              instance_config = get_default_interactive_config(
                  service=service,
                  cluster=cluster,
                  soa_dir=soa_dir,
                  load_deployments=load_deployments,
              )
              interactive = True
          else:
              instance_type = validate_service_instance(service, instance, cluster, soa_dir)
              instance_config = get_instance_config(
                  service=service,
                  instance=instance,
                  cluster=cluster,
                  load_deployments=load_deployments,
                  soa_dir=soa_dir,
              )
      except NoConfigurationForServiceError as e:
          paasta_print(str(e), file=sys.stderr)
          return 1
      except NoDeploymentsAvailable:
          paasta_print(
              PaastaColors.red(
                  "Error: No deployments.json found in %(soa_dir)s/%(service)s."
                  "You can generate this by running:"
                  "generate_deployments_for_service -d %(soa_dir)s -s %(service)s" % {
                      'soa_dir': soa_dir,
                      'service': service,
                  },
              ),
              sep='\n',
              file=sys.stderr,
          )
          return 1
  
      if docker_hash is None:
          try:
              docker_url = instance_config.get_docker_url()
          except NoDockerImageError:
              paasta_print(
                  PaastaColors.red(
                      "Error: No sha has been marked for deployment for the %s deploy group.\n"
                      "Please ensure this service has either run through a jenkins pipeline "
                      "or paasta mark-for-deployment has been run for %s\n" % (
                          instance_config.get_deploy_group(), service,
                      ),
                  ),
                  sep='',
                  file=sys.stderr,
              )
              return 1
          docker_hash = docker_url
  
      if pull_image:
          docker_pull_image(docker_url)
  
      for volume in instance_config.get_volumes(system_paasta_config.get_volumes()):
          if os.path.exists(volume['hostPath']):
              volumes.append('%s:%s:%s' % (volume['hostPath'], volume['containerPath'], volume['mode'].lower()))
          else:
              paasta_print(
                  PaastaColors.yellow(
                      "Warning: Path %s does not exist on this host. Skipping this binding." % volume['hostPath'],
                  ),
              )
  
      if interactive is True and args.cmd is None:
          command = 'bash'
      elif args.cmd:
          command = args.cmd
      else:
          command_from_config = instance_config.get_cmd()
          if command_from_config:
              command_modifier = command_function_for_framework(instance_type)
              command = command_modifier(command_from_config)
          else:
              command = instance_config.get_args()
  
      return run_docker_container(
          docker_client=docker_client,
          service=service,
          instance=instance,
          docker_hash=docker_hash,
          volumes=volumes,
          interactive=interactive,
          command=command,
          healthcheck=args.healthcheck,
          healthcheck_only=args.healthcheck_only,
          user_port=args.user_port,
          instance_config=instance_config,
          soa_dir=args.yelpsoa_config_root,
          dry_run=dry_run,
          json_dict=args.dry_run_json_dict,
          framework=instance_type,
      )
code_tokens: def configure_and_run_docker_container ( docker_client , docker_hash , service , instance , cluster , system_paasta_config , args , pull_image = False , dry_run = False , ) : if instance is None and args . healthcheck_only : paasta_print ( "With --healthcheck-only, --instance MUST be provided!" , file = sys . stderr , ) return 1 if instance is None and not sys . stdin . isatty ( ) : paasta_print ( "--instance and --cluster must be specified when using paasta local-run without a tty!" , file = sys . stderr , ) return 1 soa_dir = args . yelpsoa_config_root volumes = list ( ) load_deployments = docker_hash is None or pull_image interactive = args . interactive try : if instance is None : instance_type = 'adhoc' instance = 'interactive' instance_config = get_default_interactive_config ( service = service , cluster = cluster , soa_dir = soa_dir , load_deployments = load_deployments , ) interactive = True else : instance_type = validate_service_instance ( service , instance , cluster , soa_dir ) instance_config = get_instance_config ( service = service , instance = instance , cluster = cluster , load_deployments = load_deployments , soa_dir = soa_dir , ) except NoConfigurationForServiceError as e : paasta_print ( str ( e ) , file = sys . stderr ) return 1 except NoDeploymentsAvailable : paasta_print ( PaastaColors . red ( "Error: No deployments.json found in %(soa_dir)s/%(service)s." "You can generate this by running:" "generate_deployments_for_service -d %(soa_dir)s -s %(service)s" % { 'soa_dir' : soa_dir , 'service' : service , } , ) , sep = '\n' , file = sys . stderr , ) return 1 if docker_hash is None : try : docker_url = instance_config . get_docker_url ( ) except NoDockerImageError : paasta_print ( PaastaColors . red ( "Error: No sha has been marked for deployment for the %s deploy group.\n" "Please ensure this service has either run through a jenkins pipeline " "or paasta mark-for-deployment has been run for %s\n" % ( instance_config . get_deploy_group ( ) , service , ) , ) , sep = '' , file = sys . stderr , ) return 1 docker_hash = docker_url if pull_image : docker_pull_image ( docker_url ) for volume in instance_config . get_volumes ( system_paasta_config . get_volumes ( ) ) : if os . path . exists ( volume [ 'hostPath' ] ) : volumes . append ( '%s:%s:%s' % ( volume [ 'hostPath' ] , volume [ 'containerPath' ] , volume [ 'mode' ] . lower ( ) ) ) else : paasta_print ( PaastaColors . yellow ( "Warning: Path %s does not exist on this host. Skipping this binding." % volume [ 'hostPath' ] , ) , ) if interactive is True and args . cmd is None : command = 'bash' elif args . cmd : command = args . cmd else : command_from_config = instance_config . get_cmd ( ) if command_from_config : command_modifier = command_function_for_framework ( instance_type ) command = command_modifier ( command_from_config ) else : command = instance_config . get_args ( ) return run_docker_container ( docker_client = docker_client , service = service , instance = instance , docker_hash = docker_hash , volumes = volumes , interactive = interactive , command = command , healthcheck = args . healthcheck , healthcheck_only = args . healthcheck_only , user_port = args . user_port , instance_config = instance_config , soa_dir = args . yelpsoa_config_root , dry_run = dry_run , json_dict = args . dry_run_json_dict , framework = instance_type , )
short_docstring: Run Docker container by image hash with args set in command line.
short_docstring_tokens: Run Docker container by image hash with args set in command line .
comment: """
      Run Docker container by image hash with args set in command line.
      Function prints the output of run command in stdout.
      """