예제 #1
0
def main(args=None):
    """
    Script to retrieve relevant recomputations requests for a specific date

    :param args: Command line arguments
    """

    # default paths
    fn_ar_cfg = "/etc/ar-compute-engine.conf"
    arcomp_conf = "/etc/ar-compute"

    # Init configuration
    cfg = ArgoConfiguration(fn_ar_cfg)
    cfg.load_tenant_db_conf(os.path.join(arcomp_conf, args.tenant + "_db_conf.json"))
    db_name = cfg.get_mongo_database("ar")
    col_recomputations = "recomputations"

    # Init logging
    log = init_log(cfg.log_mode, cfg.log_file, cfg.log_level, 'argo.mongo_recompute')

    # Get mongo collection
    col = get_mongo_collection(cfg.mongo_host, cfg.mongo_port, db_name, col_recomputations, log)
    results = get_mongo_results(col, args.date, args.job)
    log.info("Date: %s, relevant recomputations found: %s", args.date, len(results))

    # Write results to file
    write_output(results, args.tenant, get_date_under(args.date), cfg.sync_path)
예제 #2
0
def main(tenant=None):
    """
    Checks if there are any pending recomputation requests and if the running
    requests do not exceed a threshold and queues another one to be recomputed
    :param tenant:
    :return:
    """
    # default paths
    fn_ar_cfg = "/etc/ar-compute-engine.conf"
    argo_exec = "/usr/libexec/ar-compute/bin"
    arcomp_conf = "/etc/ar-compute"
    # Init configuration
    cfg = ArgoConfiguration(fn_ar_cfg)
    cfg.load_tenant_db_conf(os.path.join(arcomp_conf, args.tenant + "_db_conf.json"))
    threshold = cfg.threshold

    # Init logging
    log = init_log(cfg.log_mode, cfg.log_file, cfg.log_level, 'argo.recompute')
    db_name = cfg.get_mongo_database("ar")

    col = get_mongo_collection(cfg.mongo_host, cfg.mongo_port, db_name)
    num_pen, num_run = get_pending_and_running(col)
    log.info("Running recomputations: %s (threshold: %s)", num_run, threshold)
    try:
        run_recomputation(col, tenant, num_run, num_pen, threshold)
        log.info("Below threshold recomputation sent for execution")
    except ValueError as ex:
        log.info(ex)
예제 #3
0
def recompute(recalculation_id=None, tenant=None):
    """
    Script to execute recomputation

    :param recalculation_id: The id of the job to be recomputed
    :param tenant: tenants name
    """
    # default paths
    fn_ar_cfg = "/etc/ar-compute-engine.conf"
    argo_exec = "/usr/libexec/ar-compute/bin"
    arcomp_conf = "/etc/ar-compute"
    # Init configuration
    cfg = ArgoConfiguration(fn_ar_cfg)
    cfg.load_tenant_db_conf(os.path.join(arcomp_conf, args.tenant + "_db_conf.json"))
    # Init logging
    log = init_log(cfg.log_mode, cfg.log_file, cfg.log_level, 'argo.recompute')

    # Check recomputation
    col = get_mongo_collection(
        cfg.mongo_host, cfg.mongo_port, cfg.get_mongo_database("ar"), "recomputations", log)
    recomputation = get_recomputation(col, recalculation_id, log)
    dates = get_time_period(recomputation)

    update_status(col, recalculation_id, "running", datetime.now(), log)
    loop_recompute(argo_exec, dates, tenant, recomputation["report"], log)
    update_status(col, recalculation_id, "done", datetime.now(), log)