Example #1
0
        CONFIG: Dict[str, Any] = loader.load_config(ARGS.config)
    except FileNotFoundError:
        print(f"Config file: {ARGS.config} was not found. Aborting...",
              file=sys.stderr)
        sys.exit(1)
    else:
        if not ARGS.quiet:
            print("\nStarting Magpie Prophet Model Traffic Validation\n")
            print(f"Loading configuration from file: {ARGS.config}")

    if not os.path.exists(CONFIG["log.file.dir"]):
        os.makedirs(CONFIG["log.file.dir"])

    LOG_FILE: str = CONFIG["log.file.dir"] + "/validation_heron_prophet.log"

    logs.setup(console=(not ARGS.quiet), logfile=LOG_FILE, debug=ARGS.debug)

    # HERON METRICS CLIENT
    METRICS_CLIENT: HeronMetricsClient = loader.get_class(
        CONFIG["heron.metrics.client"])(CONFIG["heron.metrics.client.config"])

    if not os.path.exists(ARGS.output_dir):
        LOG.info("Creating output directory: %s", ARGS.output_dir)
        os.makedirs(ARGS.output_dir)
    else:
        LOG.info("Saving results to existing directory: %s", ARGS.output_dir)

    RESULTS: pd.DataFrame = run(
        CONFIG["heron.traffic.models.config"],
        METRICS_CLIENT,
        ARGS.source_hours,
Example #2
0

def _check_tracker(tracker_str: str) -> str:

    if "http://" in tracker_str:
        return tracker_str

    return "http://" + tracker_str


if __name__ == "__main__":

    ARGS: argparse.Namespace = _create_parser().parse_args()

    if not ARGS.quiet:
        logs.setup(debug=ARGS.debug)

    NO_CACHE_DIR: bool = False
    if not os.path.exists(ARGS.cache_dir):
        LOG.info("No cached tracker information present")
        NO_CACHE_DIR = True
        os.makedirs(ARGS.cache_dir)
        LOG.info("Created cache directory at: %s", ARGS.cache_dir)
    elif len(os.listdir(ARGS.cache_dir)) < 1:
        LOG.info("No cached tracker information present")
        # If the directory exists but there is nothing in it then we need to
        # load the tracker data
        NO_CACHE_DIR = True

    CREATE_TIME_FILE: str = os.path.join(ARGS.cache_dir, "created.pkl")
    TOPO_FILE: str = os.path.join(ARGS.cache_dir, "topo.pkl")