Esempio n. 1
0
def parse_arguments():
    """Parses command line arguments.

  Returns:
    A Namespace of parsed arguments.
  """
    parser = argparse.ArgumentParser(
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument(
        '--project',
        required=True,
        help='Cloud project ID in which to find and delete the job(s)')
    parser.add_argument('-j',
                        '--jobs',
                        required=True,
                        nargs='*',
                        help='List of job-ids to delete')
    parser.add_argument('-t',
                        '--tasks',
                        nargs='*',
                        help='List of tasks in an array job to delete.')
    parser.add_argument(
        '-u',
        '--users',
        default=[dsub_util.get_default_user()],
        help=
        """Deletes only those jobs which were submitted by the list of users.
          Use "*" to delete jobs of any user.""")
    return parser.parse_args()
Esempio n. 2
0
def parse_arguments():
    """Parses command line arguments.

  Returns:
    A Namespace of parsed arguments.
  """
    parser = argparse.ArgumentParser(
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument(
        '--project',
        required=True,
        help='Cloud project ID in which to query pipeline operations')
    parser.add_argument('-j',
                        '--jobs',
                        nargs='*',
                        help='A list of jobs on which to check status')
    parser.add_argument(
        '-u',
        '--users',
        nargs='*',
        default=[dsub_util.get_default_user()],
        help="""Lists only those jobs which were submitted by the list of users.
          Use "*" to list jobs of any user.""")
    parser.add_argument(
        '-s',
        '--status',
        nargs='*',
        default=['RUNNING'],
        choices=['RUNNING', 'SUCCESS', 'FAILURE', 'CANCELED', '*'],
        help="""Lists only those jobs which match the specified status(es).
          Use "*" to list jobs of any status.""")
    parser.add_argument(
        '--poll-interval',
        default=10,
        type=int,
        help='Polling interval (in seconds) for checking job status '
        'when --wait is set.')
    parser.add_argument('--wait',
                        action='store_true',
                        help='Wait until jobs have all completed.')
    parser.add_argument('-f',
                        '--full',
                        action='store_true',
                        help='Toggle output with full operation identifiers'
                        ' and input parameters.')
    return parser.parse_args()
Esempio n. 3
0
def get_job_metadata(args, script, provider):
  """Allow provider to extract job-specific metadata from command-line args.

  Args:
    args: parsed command-line arguments
    script: the script to run
    provider: job service provider

  Returns:
    A dictionary of job-specific metadata (such as job id, name, etc.)
  """

  job_metadata = provider.get_job_metadata(script.name, args.name,
                                           dsub_util.get_default_user(),
                                           args.table is not None)
  job_metadata['script'] = script

  return job_metadata