Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@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, ))
@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:
@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)
@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
)
@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
)
@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(),
@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)
@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,
@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)
@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,