def download(command_args, prog, description): """ Script to download all datasets and model weights for offline usage. """ parser = argparse.ArgumentParser(prog=prog, description=description) _debug(parser) parser.add_argument( metavar="<download data config file>", dest="download_config", type=str, action=DownloadConfig, help= f"Configuration for download of data. See {DEFAULT_SCENARIO}. Note: file must be under current working directory.", ) parser.add_argument( metavar="<scenario>", dest="scenario", type=str, default="all", help= "scenario for which to download data, 'list' for available scenarios, or blank to download all scenarios", nargs="?", ) _no_docker(parser) args = parser.parse_args(command_args) coloredlogs.install(level=args.log_level) if args.no_docker: logger.info( "Downloading requested datasets and model weights in host mode...") paths.set_mode("host") from armory.data import datasets from armory.data import model_weights datasets.download_all(args.download_config, args.scenario) model_weights.download_all(args.download_config, args.scenario) return if not armory.is_dev(): logger.info("Downloading all docker images....") _pull_docker_images() logger.info("Downloading requested datasets and model weights...") config = {"sysconfig": {"docker_image": images.TF1}} rig = Evaluator(config) cmd = "; ".join([ "import logging", "import coloredlogs", f"coloredlogs.install({args.log_level})", "from armory.data import datasets", "from armory.data import model_weights", f'datasets.download_all("{args.download_config}", "{args.scenario}")', f'model_weights.download_all("{args.download_config}", "{args.scenario}")', ]) exit_code = rig.run(command=f"python -c '{cmd}'") sys.exit(exit_code)
help="Skip attack generation and metric calculations", ) parser.add_argument( "--validate-config", action="store_true", help="Validate model configuration against several checks", ) args = parser.parse_args() coloredlogs.install(level=args.log_level) calling_version = os.getenv(environment.ARMORY_VERSION, "UNKNOWN") if calling_version != armory.__version__: logger.warning(f"armory calling version {calling_version} != " f"armory imported version {armory.__version__}") if args.no_docker: paths.set_mode("host") if args.check and args.num_eval_batches: logger.warning( "--num_eval_batches will be overwritten and set to 1 since --check was passed" ) if args.validate_config: run_validation( args.config, args.from_file, ) else: run_config( args.config, args.from_file,