def main(): """Command entrypoint.""" try: # parse input parameters and config file args = _get_parser().parse_args() _validate_parameters(args) log = config_logger(args.log_level) log.info("Input parameters: %s" % args) config = AWSBatchCliConfig(log=log, cluster=args.cluster) boto3_factory = Boto3ClientFactory( region=config.region, proxy=config.proxy, aws_access_key_id=config.aws_access_key_id, aws_secret_access_key=config.aws_secret_access_key, ) AWSBoutCommand(log, boto3_factory).run(job_id=args.job_id, head=args.head, tail=args.tail, stream=args.stream, stream_period=args.stream_period) except KeyboardInterrupt: print("Exiting...") sys.exit(0) except Exception as e: fail("Unexpected error. Command failed with exception: %s" % e)
def main(argv=None): """Command entrypoint.""" try: # parse input parameters and config file args = _get_parser().parse_args(argv) log = config_logger(args.log_level) log.info("Input parameters: %s", args) config = AWSBatchCliConfig(log=log, cluster=args.cluster) boto3_factory = Boto3ClientFactory(region=config.region, proxy=config.proxy) job_status_set = OrderedDict((status.strip().upper(), "") for status in args.status.split(",")) if "ALL" in job_status_set: # add all the statuses in the list job_status_set = OrderedDict((status, "") for status in AWS_BATCH_JOB_STATUS) job_status = list(job_status_set) AWSBstatCommand(log, boto3_factory).run( job_status=job_status, expand_children=args.expand_children, job_ids=args.job_ids, job_queue=config.job_queue, show_details=args.details, ) except KeyboardInterrupt: print("Exiting...") sys.exit(0) except Exception as e: fail("Unexpected error. Command failed with exception: %s" % e)
def main(): """Command entrypoint.""" try: # parse input parameters and config file args = _get_parser().parse_args() log = config_logger(args.log_level) log.info("Input parameters: %s" % args) config = AWSBatchCliConfig(log=log, cluster=args.cluster) boto3_factory = Boto3ClientFactory( region=config.region, proxy=config.proxy, aws_access_key_id=config.aws_access_key_id, aws_secret_access_key=config.aws_secret_access_key, ) if args.job_queues: job_queues = args.job_queues show_details = True else: job_queues = [config.job_queue] show_details = args.details AWSBqueuesCommand(log, boto3_factory).run(job_queues=job_queues, show_details=show_details) except KeyboardInterrupt: print("Exiting...") sys.exit(0) except Exception as e: fail("Unexpected error. Command failed with exception: %s" % e)
def main(): """Command entrypoint.""" try: # parse input parameters and config file args = _get_parser().parse_args() log = config_logger(args.log_level) log.info("Input parameters: %s" % args) config = AWSBatchCliConfig(log, args.cluster) boto3_factory = Boto3ClientFactory( region=config.region, proxy=config.proxy, aws_access_key_id=config.aws_access_key_id, aws_secret_access_key=config.aws_secret_access_key, ) AWSBhostsCommand(log, boto3_factory).run( compute_environments=[config.compute_environment], instance_ids=args.instance_ids, show_details=args.details) except KeyboardInterrupt: print("Exiting...") sys.exit(0) except Exception as e: fail("Unexpected error. Command failed with exception: %s" % e)
def main(): try: # parse input parameters and config file args = _get_parser().parse_args() _validate_parameters(args) log = config_logger(args.log_level) log.info("Input parameters: %s" % args) config = AWSBatchCliConfig(log=log, cluster=args.cluster) boto3_factory = Boto3ClientFactory( region=config.region, proxy=config.proxy, aws_access_key_id=config.aws_access_key_id, aws_secret_access_key=config.aws_secret_access_key) # define job name if args.job_name: job_name = args.job_name else: # set a default job name if not specified if not sys.stdin.isatty(): # stdin job_name = 'STDIN' else: # normalize name job_name = re.sub('\W+', '_', os.path.basename(args.command)) log.info("Job name not specified, setting it to (%s)" % job_name) # upload script, if needed, and get related command command = _upload_and_get_command(boto3_factory, args, job_name, config.region, config.s3_bucket, log) # parse and validate depends_on parameter depends_on = _get_depends_on(args) job_definition = config.job_definition AWSBsubCommand(log, boto3_factory).run(job_definition=job_definition, job_name=job_name, job_queue=config.job_queue, command=command, vcpus=args.vcpus, memory=args.memory, array_size=args.array_size, dependencies=depends_on, retry_attempts=args.retry_attempts, timeout=args.timeout, master_ip=config.master_ip) except KeyboardInterrupt: print("Exiting...") sys.exit(0) except Exception as e: fail("Unexpected error. Command failed with exception: %s" % e)
def main(): """Command entrypoint.""" try: # parse input parameters and config file args = _get_parser().parse_args() log = config_logger(args.log_level) log.info("Input parameters: %s", args) config = AWSBatchCliConfig(log=log, cluster=args.cluster) boto3_factory = Boto3ClientFactory(region=config.region, proxy=config.proxy) AWSBkillCommand(log, boto3_factory).run(job_ids=args.job_ids, reason=args.reason) except KeyboardInterrupt: print("Exiting...") sys.exit(0) except Exception as e: fail("Unexpected error. Command failed with exception: %s" % e)
def main(): aws_batch_job_status = [ 'SUBMITTED', 'PENDING', 'RUNNABLE', 'STARTING', 'RUNNING', 'SUCCEEDED', 'FAILED' ] try: # parse input parameters and config file args = _get_parser().parse_args() log = config_logger(args.log_level) log.info("Input parameters: %s" % args) config = AWSBatchCliConfig(log=log, cluster=args.cluster) boto3_factory = Boto3ClientFactory( region=config.region, proxy=config.proxy, aws_access_key_id=config.aws_access_key_id, aws_secret_access_key=config.aws_secret_access_key) job_status_set = OrderedDict( (status.strip().upper(), '') for status in args.status.split(',')) if 'ALL' in job_status_set: # add all the statuses in the list job_status_set = OrderedDict( (status, '') for status in aws_batch_job_status) job_status = list(job_status_set) AWSBstatCommand(log, boto3_factory).run(job_status=job_status, expand_arrays=args.expand_arrays, job_ids=args.job_ids, job_queue=config.job_queue, show_details=args.details) except KeyboardInterrupt: print("Exiting...") sys.exit(0) except Exception as e: fail("Unexpected error. Command failed with exception: %s" % e)
def main(): """Command entrypoint.""" try: # parse input parameters and config file args = _get_parser().parse_args() _validate_parameters(args) log = config_logger(args.log_level) log.info("Input parameters: %s" % args) config = AWSBatchCliConfig(log=log, cluster=args.cluster) boto3_factory = Boto3ClientFactory( region=config.region, proxy=config.proxy, aws_access_key_id=config.aws_access_key_id, aws_secret_access_key=config.aws_secret_access_key, ) # define job name if args.job_name: job_name = args.job_name else: # set a default job name if not specified if not sys.stdin.isatty(): # stdin job_name = "STDIN" else: # normalize name job_name = re.sub(r"\W+", "_", os.path.basename(args.command)) log.info("Job name not specified, setting it to (%s)" % job_name) # generate an internal unique job-id job_key = _generate_unique_job_key(job_name) job_s3_folder = "batch/{0}/".format(job_key) # upload script, if needed, and get related command command = _upload_and_get_command(boto3_factory, args, job_s3_folder, job_name, config, log) # parse and validate depends_on parameter depends_on = _get_depends_on(args) # select submission (standard vs MNP) if args.nodes and args.nodes > 1: if not hasattr(config, "job_definition_mnp"): fail("Current cluster does not support MNP jobs submission") job_definition = config.job_definition_mnp nodes = args.nodes else: job_definition = config.job_definition nodes = None AWSBsubCommand(log, boto3_factory).run( job_definition=job_definition, job_name=job_name, job_queue=config.job_queue, command=command, nodes=nodes, vcpus=args.vcpus, memory=args.memory, array_size=args.array_size, dependencies=depends_on, retry_attempts=args.retry_attempts, timeout=args.timeout, env=[ ("MASTER_IP", config.master_ip), # TODO remove ("PCLUSTER_JOB_S3_URL", "s3://{0}/{1}".format(config.s3_bucket, job_s3_folder)), ], ) except KeyboardInterrupt: print("Exiting...") sys.exit(0) except Exception as e: fail("Unexpected error. Command failed with exception: %s" % e)