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) experiment_builder = ExperimentBuilder() local_config = experiment_builder.fetch_full_config(args, use_db=False) local_config['protocol'] = {'type': 'legacy', 'setup': False} experiment_builder.setup_storage(local_config) storage = get_storage() upgrade_db_specifics(storage) print('Updating documents...') upgrade_documents(storage) print('Database upgrade completed successfully')
def main(args): """Fetch config and status experiments""" builder = ExperimentBuilder() local_config = builder.fetch_full_config(args, use_db=False) builder.setup_storage(local_config) 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(filter(lambda e: e.refers.get('parent_id') is None, experiments), **args)
def main(args): """List all experiments inside database.""" builder = ExperimentBuilder() config = builder.fetch_full_config(args, use_db=False) builder.setup_storage(config) 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'] ] for root_experiment in root_experiments: root = EVCBuilder().build_view_from({ 'name': root_experiment['name'], 'version': root_experiment.get('version') }).node print_tree(root, nameattr='tree_name')
def build_storage(): """Build storage from scratch""" null_db_instances() experiment_builder = ExperimentBuilder() local_config = experiment_builder.fetch_full_config({}, use_db=False) experiment_builder.setup_storage(local_config) return get_storage()