Skip to content

Commit

Permalink
feat(cli): add renku rollback command (#2426)
Browse files Browse the repository at this point in the history
  • Loading branch information
Panaetius committed Nov 26, 2021
1 parent 9cea4d1 commit 83fb842
Show file tree
Hide file tree
Showing 28 changed files with 549 additions and 73 deletions.
7 changes: 7 additions & 0 deletions docs/reference/commands.rst
Expand Up @@ -154,6 +154,13 @@ Renku Command Line

.. automodule:: renku.cli.migrate

.. _cli-rollback:

``renku rollback``
------------------

.. automodule:: renku.cli.rollback

.. _cli-service:

``renku service``
Expand Down
2 changes: 2 additions & 0 deletions renku/cli/__init__.py
Expand Up @@ -85,6 +85,7 @@
from renku.cli.project import project
from renku.cli.remove import remove
from renku.cli.rerun import rerun
from renku.cli.rollback import rollback
from renku.cli.run import run
from renku.cli.save import save
from renku.cli.service import service
Expand Down Expand Up @@ -233,6 +234,7 @@ def help(ctx):
cli.add_command(project)
cli.add_command(remove)
cli.add_command(rerun)
cli.add_command(rollback)
cli.add_command(run)
cli.add_command(save)
cli.add_command(status)
Expand Down
84 changes: 84 additions & 0 deletions renku/cli/rollback.py
@@ -0,0 +1,84 @@
# -*- coding: utf-8 -*-
#
# Copyright 2018-2021- Swiss Data Science Center (SDSC)
# A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and
# Eidgenössische Technische Hochschule Zürich (ETHZ).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Rollback project to a previous point in time.
If you want to undo actions taken using Renku in a project, you can use the
``renku rollback`` command to do so.
This command shows a list of all actions done by renku and lets you pick
one that you want to return to, discarding any changes done in the repo (by
Renku or manually) after that point. Once you pick a checkpoint to return to,
the commands shows all files and Renku objects that would be affected by the
rollback and how they would be affected. If you confirm, the project will be
reset to that point in time, with anything done after that point being
deleted/lost.
.. code-block:: console
$ renku rollback
Select a checkpoint to roll back to:
[0] 2021-10-20 09:50:04 renku workflow edit cp-blabla-asdasf-0b535 --name test
[1] 2021-10-20 09:49:19 renku rerun asdasf
[2] 2021-10-20 09:48:59 renku run cp blabla asdasf
[3] 2021-10-20 08:37:00 renku dataset add e blabla
[4] 2021-10-20 08:31:16 renku dataset create m
Checkpoint ([q] to quit) [q]: 4
The following changes would be done:
Metadata:
Modified ♻️:
Dataset: e
Removed 🔥:
Plan: cp-blabla-asdasf-0b535
Plan: test
Run: /activities/cc3ab70952fc499e93e7e4075a076bf5 (Plan name: cp-blabla-asdasf-0b535)
Run: /activities/48b89b22567d4282abe8a016fa91878f (Plan name: cp-blabla-asdasf-0b535)
Files:
Restored ↻:
blabla
Removed 🔥:
asdasf
Proceed? [y/N]: y
.. note:: This command was introduced in renku-python version 1.0.0. Commands
executed with previous versions of renku can't be rolled back to.
"""

import click

from renku.cli.utils.callback import ClickCallback


@click.command()
@click.pass_context
def rollback(ctx):
"""Rollback project to a previous point in time.
Only renku commands executed after the 1.0.0 release are supported,
previous commands won't show up.
"""
from renku.core.commands.rollback import rollback_command

communicator = ClickCallback()
rollback_command().with_communicator(communicator).build().execute()
1 change: 0 additions & 1 deletion renku/core/commands/move.py
Expand Up @@ -90,7 +90,6 @@ def _move(sources, destination, force, verbose, to_dataset, client_dispatcher: I

# NOTE: Force-add to include possible ignored files
client.repository.add(*files.values(), force=True)
client.repository.commit(f"renku mv: committing {len(files)} moved files")

client.move_files(files=files, to_dataset=to_dataset)

Expand Down

0 comments on commit 83fb842

Please sign in to comment.