Exemplo n.º 1
0
def main(argv):
    parser = argparse.ArgumentParser(description="NGSpyeasy pipeline runner")
    parser.add_argument("playbook_path", metavar='/path/to/your_pipeline.yml', type=cmdargs.existed_file)
    parser.add_argument("--version", action="version", version="%(prog)s 3.0", help="print software version")
    parser.add_argument("--samples", metavar="/path/to/config.tsv", dest="samples_tsv", required=False,
                        type=cmdargs.existed_file, help="List of samples in TSV format")
    parser.add_argument("--vars", dest="var_files", metavar="/path/to/your/vars.yml", help="additional variables",
                        type=cmdargs.existed_file, action="append")
    parser.add_argument("--provider", dest="provider", choices=["local", "lsf"], default="local",
                        help="job scheduler")
    parser.add_argument("--log_dir", dest="log_dir", type=cmdargs.existed_directory)

    args = parser.parse_args(argv)

    if args.log_dir is not None:
        init_main_logger(args.log_dir)

    logger().debug("Command line arguments: %s" % args)

    playbook_path = os.path.abspath(args.playbook_path)
    samples_tsv = os.path.abspath(args.samples_tsv) if args.samples_tsv else None
    var_files = [os.path.abspath(f) for f in args.var_files]

    pb = playbook_yaml.parse(playbook_path, samples_tsv, var_files, args.log_dir)

    logger().info("Starting job executor: provider=%s" % args.provider)
    executor.start(provider=args.provider, log_dir=args.log_dir)

    try:
        for play in pb.plays():
            logger().info("Starting play: %s" % play.name())
            jobs = []
            for name, cmd in play.commands():
                logger().debug("cmd submit: name=%s\n %s\n" % (name, cmd))
                executor.submit(name, cmd)
                jobs.append(name)
            if not wait_for_results(jobs):
                break

    except Exception as e:
        logger().exception(e)
    finally:
        executor.stop()
Exemplo n.º 2
0
def signal_handler(signum, frame):
    logger().info("Got SIGINT(%s) signal" % str(signum))
    executor.stop()