Skip to content

Commit

Permalink
Merge branch 'master' into 1819-renku-config-endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Panaetius committed Jan 14, 2021
2 parents a083e07 + ec5337a commit 2d97b91
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 24 deletions.
7 changes: 7 additions & 0 deletions docs/commands.rst
Expand Up @@ -27,6 +27,13 @@ Renku Command Line

.. automodule:: renku.cli.init

.. _cli-clone:

``renku clone``
---------------

.. automodule:: renku.cli.clone

.. _cli-config:

``renku config``
Expand Down
35 changes: 25 additions & 10 deletions renku/cli/clone.py
Expand Up @@ -20,14 +20,31 @@
Cloning a Renku project
~~~~~~~~~~~~~~~~~~~~~~~
To clone a Renku project and set up required Git hooks and Git LFS use
``renku clone`` command.
To clone a Renku project use ``renku clone`` command. This command is preferred
over using ``git clone`` because it sets up required Git hooks and enables
Git-LFS automatically.
.. code-block:: console
$ renku clone git+ssh://host.io/namespace/project.git
<destination-directory>
$ renku clone <repository-url> <destination-directory>
It creates a new directory with the same name as the project. You can change
the directory name by passing another name on the command line.
By default, ``renku clone`` pulls data from Git-LFS after cloning. If you don't
need the LFS data, pass ``--no-pull-data`` option to skip this step.
.. Note:: To move a project to another Renku deployment you need to create a
new empty project in the target deployment and push both the
repository and Git-LFS objects to the new remote. Refer to Git documentation
for more details.
.. code-block:: console
$ git lfs fetch --all
$ git remote remove origin
$ git remote add origin <new-repository-url>
$ git push --mirror origin
"""

import click
Expand All @@ -37,13 +54,11 @@


@click.command()
@click.option("--pull-data", is_flag=True, help="Pull data from Git-LFS.", default=False)
@click.option("--no-pull-data", is_flag=True, help="Do not pull data from Git-LFS.", default=False)
@click.argument("url")
@click.argument("path", required=False, default=None)
def clone(pull_data, url, path):
def clone(no_pull_data, url, path):
"""Clone a Renku repository."""
click.echo("Cloning {} ...".format(url))

skip_smudge = not pull_data
project_clone(url=url, path=path, skip_smudge=skip_smudge, progress=GitProgress())
click.echo(f"Cloning {url} ...")
project_clone(url=url, path=path, skip_smudge=no_pull_data, progress=GitProgress())
click.secho("OK", fg="green")
24 changes: 12 additions & 12 deletions renku/cli/dataset.py
Expand Up @@ -95,14 +95,13 @@
. code-block:: console
$ renku dataset show some-dataset
Some Dataset
---------------
Just some dataset
Name: some-dataset
Created: 2020-12-09 13:52:06.640778+00:00
Creator(s): John Doe<john.doe@example.com> [SDSC]
Keywords: Dataset, Data
Title: Some Dataset
Description:
Just some dataset
Deleting a dataset:
Expand Down Expand Up @@ -510,27 +509,28 @@ def show(name):
"""Handle datasets."""
result = show_dataset().build().execute(name=name)
ds = result.output
click.secho(ds["title"], bold=True)
click.echo("-" * min(len(ds["title"]), click.get_terminal_size()[0]))

Console().print(Markdown(ds["description"]))
click.echo()
click.echo(click.style("Name: ", bold=True, fg="magenta") + click.style(ds["name"], bold=True))
click.echo(click.style("Created: ", bold=True, fg="magenta") + ds["created_at"])
click.echo(click.style("Created: ", bold=True, fg="magenta") + (ds.get("created_at", "") or ""))

creators = []
for creator in ds["creators"]:
for creator in ds.get("creators", []):
if creator["affiliation"]:
creators.append(f"{creator['name']} <{creator['email']}> [{creator['affiliation']}]")
else:
creators.append(f"{creator['name']} <{creator['email']}>")

click.echo(click.style("Creator(s): ", bold=True, fg="magenta") + ", ".join(creators))
if ds["keywords"]:
click.echo(click.style("Keywords: ", bold=True, fg="magenta") + ", ".join(ds["keywords"]))
click.echo(click.style("Keywords: ", bold=True, fg="magenta") + ", ".join(ds.get("keywords", "")))

if ds["version"]:
click.echo(click.style("Version: ", bold=True, fg="magenta") + ds["version"])
click.echo(click.style("Version: ", bold=True, fg="magenta") + ds.get("version", ""))

click.echo(click.style("Title: ", bold=True, fg="magenta") + click.style(ds.get("title", ""), bold=True))

click.echo(click.style("Description: ", bold=True, fg="magenta"))
Console().print(Markdown(ds.get("description", "") or ""))


@dataset.command()
Expand Down
10 changes: 8 additions & 2 deletions renku/core/management/migrations/m_0005__2_cwl.py
Expand Up @@ -193,6 +193,9 @@ def _migrate_single_step(client, cmd_line_tool, path, commit=None, parent_commit
if listing.entry == '$({"listing": [], "class": "Directory"})':
created_outputs.append(listing.entryname)

# NOTE: multiple outputs might bind to the same input; we use this copy to find output bindings
all_inputs = inputs.copy()

for o in outputs:
prefix = None
position = None
Expand All @@ -203,8 +206,11 @@ def _migrate_single_step(client, cmd_line_tool, path, commit=None, parent_commit
if name.endswith(")"):
name = name[:-1]

matched_input = next(i for i in inputs if i.id == name)
inputs.remove(matched_input)
matched_input = next(i for i in all_inputs if i.id == name)
try:
inputs.remove(matched_input)
except ValueError:
pass

if isinstance(matched_input.default, dict):
path = client.workflow_path / Path(matched_input.default["path"])
Expand Down
9 changes: 9 additions & 0 deletions tests/cli/test_migrate.py
Expand Up @@ -48,6 +48,15 @@ def test_migrate_project(isolated_runner, old_project):
assert client.project.name


@pytest.mark.migration
@pytest.mark.parametrize("old_project", ["old-workflows-v0.10.0.git"], indirect=["old_project"])
def test_migrate_duplicated_input_binding(isolated_runner, old_project):
"""Check migrating CWLs with multiple outputs binding to the same input."""
result = isolated_runner.invoke(cli, ["migrate", "--no-commit"])

assert 0 == result.exit_code, result.output


@pytest.mark.migration
def test_migration_check(isolated_runner, project):
"""Test migrate on old repository."""
Expand Down
Binary file added tests/fixtures/old-workflows-v0.10.0.git.tar.gz
Binary file not shown.

0 comments on commit 2d97b91

Please sign in to comment.