How to use the dsub.providers.provider_base function in dsub

To help you get started, we’ve selected a few dsub examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DataBiosphere / dsub / dsub / commands / dsub.py View on Github external
def run_main(args):
  """Execute job/task submission from command-line arguments."""

  if args.command and args.script:
    raise ValueError('Cannot supply both a --command and --script flag')

  provider_base.check_for_unsupported_flag(args)

  # Set up job parameters and job data from a tasks file or flags.
  input_file_param_util = param_util.InputFileParamUtil(
      DEFAULT_INPUT_LOCAL_PATH)
  output_file_param_util = param_util.OutputFileParamUtil(
      DEFAULT_OUTPUT_LOCAL_PATH)
  mount_param_util = param_util.MountParamUtil(DEFAULT_MOUNT_LOCAL_PATH)

  # Get job arguments from the command line
  job_params = param_util.args_to_job_params(
      args.env, args.label, args.input, args.input_recursive, args.output,
      args.output_recursive, args.mount, input_file_param_util,
      output_file_param_util, mount_param_util)
  # If --tasks is on the command-line, then get task-specific data
  if args.tasks:
    task_descriptors = param_util.tasks_file_to_task_descriptors(
github DataBiosphere / dsub / dsub / commands / ddel.py View on Github external
def main():
  # Parse args and validate
  args = _parse_arguments()

  # Compute the age filter (if any)
  create_time = param_util.age_to_create_time(args.age)

  # Set up the Genomics Pipelines service interface
  provider = provider_base.get_provider(args, resources)

  # Make sure users were provided, or try to fill from OS user. This cannot
  # be made into a default argument since some environments lack the ability
  # to provide a username automatically.
  user_ids = set(args.users) if args.users else {dsub_util.get_os_user()}

  # Process user labels.
  labels = param_util.parse_pair_args(args.label, job_model.LabelParam)

  # Let the user know which jobs we are going to look up
  with dsub_util.replace_print():
    provider_base.emit_provider_message(provider)

    _emit_search_criteria(user_ids, args.jobs, args.tasks, args.label)
    # Delete the requested jobs
    deleted_tasks = ddel_tasks(
github DataBiosphere / dsub / dsub / commands / dsub.py View on Github external
# Launch all the job tasks!
  job_descriptor = job_model.JobDescriptor(job_metadata, job_params,
                                           job_resources, task_descriptors)
  launched_job = provider.submit_job(job_descriptor, skip)

  if not dry_run:
    if launched_job['job-id'] == dsub_util.NO_JOB:
      print('Job output already present, skipping new job submission.')
      return {'job-id': dsub_util.NO_JOB}
    print('Launched job-id: %s' % launched_job['job-id'])
    if launched_job.get('task-id'):
      print('%s task(s)' % len(launched_job['task-id']))
    print('To check the status, run:')
    print("  dstat %s --jobs '%s' --users '%s' --status '*'" %
          (provider_base.get_dstat_provider_args(provider, project),
           launched_job['job-id'], launched_job['user-id']))
    print('To cancel the job, run:')
    print("  ddel %s --jobs '%s' --users '%s'" %
          (provider_base.get_ddel_provider_args(provider, project),
           launched_job['job-id'], launched_job['user-id']))

  # Poll for job completion
  if wait:
    print('Waiting for job to complete...')

    if retries:
      error_messages = _wait_and_retry(provider, job_metadata['job-id'],
                                       poll_interval, retries, job_descriptor)
    else:
      error_messages = _wait_after(provider, [job_metadata['job-id']],
                                   poll_interval, False)
github DataBiosphere / dsub / dsub / commands / dstat.py View on Github external
elif args.format == 'text':
    formatter = output_formatter.TextOutput(args.full)
  elif args.format == 'yaml':
    formatter = output_formatter.YamlOutput(args.full)
  elif args.format == 'provider-json':
    formatter = output_formatter.JsonOutput(args.full)
  else:
    # If --full is passed, then format defaults to yaml.
    # Else format defaults to text
    if args.full:
      formatter = output_formatter.YamlOutput(args.full)
    else:
      formatter = output_formatter.TextOutput(args.full)

  # Set up the Genomics Pipelines service interface
  provider = provider_base.get_provider(args, resources)
  with dsub_util.replace_print():
    provider_base.emit_provider_message(provider)

  # Set poll interval to zero if --wait is not set.
  poll_interval = args.poll_interval if args.wait else 0

  # Make sure users were provided, or try to fill from OS user. This cannot
  # be made into a default argument since some environments lack the ability
  # to provide a username automatically.
  user_ids = set(args.users) if args.users else {dsub_util.get_os_user()}
  labels = param_util.parse_pair_args(args.label, job_model.LabelParam)

  job_producer = dstat_job_producer(
      provider=provider,
      statuses=set(args.status) if args.status else None,
      user_ids=user_ids,
github DataBiosphere / dsub / dsub / commands / ddel.py View on Github external
create_time = param_util.age_to_create_time(args.age)

  # Set up the Genomics Pipelines service interface
  provider = provider_base.get_provider(args, resources)

  # Make sure users were provided, or try to fill from OS user. This cannot
  # be made into a default argument since some environments lack the ability
  # to provide a username automatically.
  user_ids = set(args.users) if args.users else {dsub_util.get_os_user()}

  # Process user labels.
  labels = param_util.parse_pair_args(args.label, job_model.LabelParam)

  # Let the user know which jobs we are going to look up
  with dsub_util.replace_print():
    provider_base.emit_provider_message(provider)

    _emit_search_criteria(user_ids, args.jobs, args.tasks, args.label)
    # Delete the requested jobs
    deleted_tasks = ddel_tasks(
        provider,
        user_ids=user_ids,
        job_ids=set(args.jobs) if args.jobs else None,
        task_ids=set(args.tasks) if args.tasks else None,
        labels=labels,
        create_time_min=create_time)
    # Emit the count of deleted jobs.
    # Only emit anything about tasks if any of the jobs contains a task-id.
    deleted_jobs = dsub_util.tasks_to_job_ids(deleted_tasks)
    job_count = len(deleted_jobs)

    deleted_tasks = [
github DataBiosphere / dsub / dsub / commands / dstat.py View on Github external
elif args.format == 'yaml':
    formatter = output_formatter.YamlOutput(args.full)
  elif args.format == 'provider-json':
    formatter = output_formatter.JsonOutput(args.full)
  else:
    # If --full is passed, then format defaults to yaml.
    # Else format defaults to text
    if args.full:
      formatter = output_formatter.YamlOutput(args.full)
    else:
      formatter = output_formatter.TextOutput(args.full)

  # Set up the Genomics Pipelines service interface
  provider = provider_base.get_provider(args, resources)
  with dsub_util.replace_print():
    provider_base.emit_provider_message(provider)

  # Set poll interval to zero if --wait is not set.
  poll_interval = args.poll_interval if args.wait else 0

  # Make sure users were provided, or try to fill from OS user. This cannot
  # be made into a default argument since some environments lack the ability
  # to provide a username automatically.
  user_ids = set(args.users) if args.users else {dsub_util.get_os_user()}
  labels = param_util.parse_pair_args(args.label, job_model.LabelParam)

  job_producer = dstat_job_producer(
      provider=provider,
      statuses=set(args.status) if args.status else None,
      user_ids=user_ids,
      job_ids=set(args.jobs) if args.jobs else None,
      job_names=set(args.names) if args.names else None,
github DataBiosphere / dsub / dsub / commands / dsub.py View on Github external
launched_job = provider.submit_job(job_descriptor, skip)

  if not dry_run:
    if launched_job['job-id'] == dsub_util.NO_JOB:
      print('Job output already present, skipping new job submission.')
      return {'job-id': dsub_util.NO_JOB}
    print('Launched job-id: %s' % launched_job['job-id'])
    if launched_job.get('task-id'):
      print('%s task(s)' % len(launched_job['task-id']))
    print('To check the status, run:')
    print("  dstat %s --jobs '%s' --users '%s' --status '*'" %
          (provider_base.get_dstat_provider_args(provider, project),
           launched_job['job-id'], launched_job['user-id']))
    print('To cancel the job, run:')
    print("  ddel %s --jobs '%s' --users '%s'" %
          (provider_base.get_ddel_provider_args(provider, project),
           launched_job['job-id'], launched_job['user-id']))

  # Poll for job completion
  if wait:
    print('Waiting for job to complete...')

    if retries:
      error_messages = _wait_and_retry(provider, job_metadata['job-id'],
                                       poll_interval, retries, job_descriptor)
    else:
      error_messages = _wait_after(provider, [job_metadata['job-id']],
                                   poll_interval, False)
    if error_messages:
      for msg in error_messages:
        print_error(msg)
      raise dsub_errors.JobExecutionError(