def main(args): """List all experiments inside database.""" config = experiment_builder.get_cmd_config(args) experiment_builder.setup_storage(config.get("storage")) query = {} if args["name"]: query["name"] = args["name"] experiments = get_storage().fetch_experiments(query) if args["name"]: root_experiments = experiments else: root_experiments = [ exp for exp in experiments if exp["refers"].get("root_id", exp["_id"]) == exp["_id"] ] if not root_experiments: print("No experiment found") return for root_experiment in root_experiments: root = experiment_builder.load( name=root_experiment["name"], version=root_experiment.get("version")).node print_tree(root, nameattr="tree_name")
def main(args): """Upgrade the databases for current version""" print( "Upgrading your database may damage your data. Make sure to make a backup before the " "upgrade and stop any other process that may read/write the database during the upgrade." ) if not args.get("force"): action = "" while action not in ["y", "yes", "no", "n"]: action = ask_question("Do you wish to proceed? (y/N)", "N").lower() if action in ["no", "n"]: sys.exit(0) config = experiment_builder.get_cmd_config(args) storage_config = config.get("storage") if storage_config is None: storage_config = {"type": "legacy"} storage_config["setup"] = False experiment_builder.setup_storage(storage_config) storage = get_storage() upgrade_db_specifics(storage) print("Updating documents...") upgrade_documents(storage) print("Database upgrade completed successfully")
def main(args): """List all experiments inside database.""" config = experiment_builder.get_cmd_config(args) experiment_builder.setup_storage(config.get('storage')) query = {} if args['name']: query['name'] = args['name'] experiments = get_storage().fetch_experiments(query) if args['name']: root_experiments = experiments else: root_experiments = [ exp for exp in experiments if exp['refers'].get('root_id', exp['_id']) == exp['_id'] ] if not root_experiments: print("No experiment found") return for root_experiment in root_experiments: root = experiment_builder.build_view( name=root_experiment['name'], version=root_experiment.get('version')).node print_tree(root, nameattr='tree_name')
def main(args): """Remove the experiment(s) or trial(s).""" config = experiment_builder.get_cmd_config(args) experiment_builder.setup_storage(config.get("storage")) # Find root experiment root = experiment_builder.load( name=args["name"], version=args.get("version", None) ).node try: query = build_query(args["query"]) update = build_update(args["update"]) except ValueError as e: print(f"Error: {e}", file=sys.stderr) return 1 # List all experiments with children print_tree(root, nameattr="tree_name") confirmed = confirm_name( CONFIRM_MESSAGE.format(query=args["query"], update=args["update"]), args["name"], args["force"], ) if not confirmed: print("Confirmation failed, aborting operation.") return 1 storage = get_storage() process_updates(storage, root, query, update) return 0
def main(args): """Upgrade the databases for current version""" print( "Upgrading your database may damage your data. Make sure to make a backup before the " "upgrade and stop any other process that may read/write the database during the upgrade." ) if not args.get('force'): action = '' while action not in ['y', 'yes', 'no', 'n']: action = ask_question("Do you wish to proceed? (y/N)", "N").lower() if action in ['no', 'n']: sys.exit(0) config = experiment_builder.get_cmd_config(args) storage_config = config.get('storage') if storage_config is None: storage_config = {'type': 'legacy'} storage_config['setup'] = False experiment_builder.setup_storage(storage_config) storage = get_storage() upgrade_db_specifics(storage) print('Updating documents...') upgrade_documents(storage) print('Database upgrade completed successfully')
def main(args): """Remove the experiment(s) or trial(s).""" config = experiment_builder.get_cmd_config(args) experiment_builder.setup_storage(config.get("storage")) # Find root experiment root = experiment_builder.load(name=args["name"], version=args.get("version", None)).node # List all experiments with children print_tree(root, nameattr="tree_name") storage = get_storage() release_locks(storage, root, args["name"], args["force"])
def main(args): """Fetch config and status experiments""" config = experiment_builder.get_cmd_config(args) experiment_builder.setup_storage(config.get("storage")) args["all_trials"] = args.pop("all", False) experiments = get_experiments(args) if not experiments: print("No experiment found") return if args.get("name"): print_evc([experiments[0]], **args) return if args.get("version"): if args.get("collapse") or args.get("expand_versions"): raise RuntimeError( "Cannot fetch specific version of experiments with --collapse " "or --expand-versions.") print_evc(experiments, **args)
def build_storage(): """Build storage from scratch""" null_db_instances() experiment_builder.setup_storage() return get_storage()