How to use the renku.core.commands.client.pass_local_client function in renku

To help you get started, we’ve selected a few renku examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SwissDataScienceCenter / renku-python / renku / cli / remove.py View on Github external
@pass_local_client(
    clean=True,
    commit=True,
)
@click.pass_context
def remove(ctx, client, sources):
    """Remove files and check repository for potential problems."""
    from renku.core.management.git import _expand_directories

    def fmt_path(path):
        """Format path as relative to the client path."""
        return str(Path(path).absolute().relative_to(client.path))

    files = {
        fmt_path(source): fmt_path(file_or_dir)
        for file_or_dir in sources
        for source in _expand_directories((file_or_dir, ))
github SwissDataScienceCenter / renku-python / renku / core / commands / dataset.py View on Github external
@pass_local_client(
    clean=False,
    commit=True,
    commit_only=COMMIT_DIFF_STRATEGY,
)
@contextmanager
def file_unlink(client, name, include, exclude, commit_message=None):
    """Remove matching files from a dataset."""
    dataset = client.load_dataset(name=name)

    if not dataset:
        raise ParameterError('Dataset does not exist.')

    records = _filter(
        client, names=[dataset.name], include=include, exclude=exclude
    )
    if not records:
github SwissDataScienceCenter / renku-python / renku / core / commands / dataset.py View on Github external
@pass_local_client(
    clean=False,
    commit=True,
    commit_only=COMMIT_DIFF_STRATEGY,
)
def tag_dataset_with_client(
    client, name, tag, description, force=False, commit_message=None
):
    """Creates a new tag for a dataset and injects a LocalClient."""
    tag_dataset(client, name, tag, description, force)
github SwissDataScienceCenter / renku-python / renku / cli / log.py View on Github external
@pass_local_client
def log(client, revision, format, no_output, strict, paths):
    """Show logs for a file."""
    graph = Graph(client)
    if not paths:
        start, is_range, stop = revision.partition('..')
        if not is_range:
            stop = start
        elif not stop:
            stop = 'HEAD'

        commit = client.repo.rev_parse(stop)
        paths = (
            str(client.path / item.a_path)
            for item in commit.diff(commit.parents or NULL_TREE)
            # if not item.deleted_file
        )
github SwissDataScienceCenter / renku-python / renku / cli / workflow.py View on Github external
@pass_local_client
def create(client, output_file, revision, paths):
    """Create a workflow description for a file."""
    graph = Graph(client)
    outputs = graph.build(paths=paths, revision=revision)

    output_file.write(
        yaml.dump(
            ascwl(
                graph.ascwl(outputs=outputs),
                filter=lambda _, x: x is not None and x != [],
                basedir=os.path.dirname(getattr(output_file, 'name', '.')) or
                '.',
            ),
            default_flow_style=False
        )
github SwissDataScienceCenter / renku-python / renku / cli / run.py View on Github external
@pass_local_client(
    clean=True,
    up_to_date=True,
    commit=True,
    ignore_std_streams=True,
)
def run(
    client, inputs, outputs, no_output, success_codes, isolation, command_line
):
    """Tracking work on a specific problem."""
    working_dir = client.repo.working_dir
    mapped_std = _mapped_std_streams(client.candidate_paths)
    factory = CommandLineToolFactory(
        command_line=command_line,
        explicit_inputs=inputs,
        explicit_outputs=outputs,
        directory=os.getcwd(),
github SwissDataScienceCenter / renku-python / renku / core / commands / dataset.py View on Github external
@pass_local_client(clean=False, commit=False)
def list_tags(client, name, format):
    """List all tags for a dataset."""
    dataset_ = client.load_dataset(name)

    if not dataset_:
        raise ParameterError('Dataset not found.')

    tags = sorted(dataset_.tags, key=lambda t: t.created)

    return DATASET_TAGS_FORMATS[format](client, tags)
github SwissDataScienceCenter / renku-python / renku / core / commands / clone.py View on Github external
@pass_local_client
def renku_clone(
    client,
    url,
    path=None,
    install_githooks=True,
    skip_smudge=True,
    progress=None
):
    """Clone Renku project repo, install Git hooks and LFS."""
    install_lfs = client.use_external_storage
    clone(
        url=url,
        path=path,
        install_githooks=install_githooks,
        install_lfs=install_lfs,
        skip_smudge=skip_smudge,
github SwissDataScienceCenter / renku-python / renku / core / commands / dataset.py View on Github external
@pass_local_client(clean=False, commit=False)
def list_files(client, names, creators, include, exclude, format):
    """List files in dataset."""
    records = _filter(
        client,
        names=names,
        creators=creators,
        include=include,
        exclude=exclude
    )

    return DATASET_FILES_FORMATS[format](client, records)
github SwissDataScienceCenter / renku-python / renku / core / commands / dataset.py View on Github external
@pass_local_client(
    clean=False,
    commit=True,
    commit_only=COMMIT_DIFF_STRATEGY,
    commit_empty=False,
    raise_if_empty=True
)
def add_file(
    client,
    urls,
    name,
    link=False,
    force=False,
    create=False,
    sources=(),
    destination='',
    ref=None,