def wrapper(*args, **kwargs): ctx_obj = get_current_context().obj path = ctx_obj["cvc_local_path"] conservator = Conservator.create(ctx_obj["config_name"]) # raises InvalidLocalDatasetPath if the path does not point to a # valid LocalDataset (defined as a directory containing index.json). local_dataset = LocalDataset(conservator, path) return func(local_dataset, *args, **kwargs)
def upload(localpath, remote_collection, remote_name, create_collections): ctx_obj = click.get_current_context().obj conservator = Conservator.create(ctx_obj["config_name"]) if create_collections: collection = conservator.collections.from_remote_path( path=remote_collection, make_if_no_exist=True, fields="id") else: collection = conservator.collections.from_string( remote_collection, fields="id") conservator.media.upload(localpath, collection=collection, remote_name=remote_name) return True
def interactive(): global conservator ctx_obj = click.get_current_context().obj conservator = Conservator.create(ctx_obj["config_name"]) click.secho( """This is an interactive conservator "shell" that simulates the directory\n""" """structure of Conservator's collections. Type "help" to see available commands.""", fg="cyan", ) domain = conservator.get_domain() click.secho(f"Loading identity from {domain}...", fg="yellow") username = conservator.get_user().name get_root_collections() while True: user = click.style(f"{username}@{domain}:", fg="magenta", bold=True) path = click.style(f"{pwd}", fg="blue", bold=True) end = click.unstyle("$ ") command = input(user + path + end) run_shell_command(command)
def whoami(): ctx_obj = click.get_current_context().obj conservator = Conservator.create(ctx_obj["config_name"]) user = conservator.get_user() click.echo(to_clean_string(user))
def get_instance(): ctx_obj = click.get_current_context().obj conservator = Conservator.create(ctx_obj["config_name"]) return type_manager(conservator)
def clone(ctx, identifier, path, checkout): conservator = Conservator.create(ctx.obj["config_name"]) dataset = conservator.datasets.from_string(identifier) cloned = LocalDataset.clone(dataset, path) if checkout is not None: cloned.checkout(checkout)