|
17 | 17 | # limitations under the License. |
18 | 18 | """Renku workflow commands.""" |
19 | 19 |
|
20 | | - |
21 | 20 | import itertools |
22 | 21 | import re |
23 | 22 | from collections import defaultdict |
24 | 23 | from functools import reduce |
25 | 24 | from pathlib import Path |
26 | 25 | from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union, cast |
27 | 26 |
|
| 27 | +from renku.core.workflow.plan import remove_plan |
28 | 28 | from renku.domain_model.provenance.annotation import Annotation |
29 | 29 |
|
30 | 30 | if TYPE_CHECKING: |
|
45 | 45 | from renku.core.util import communication |
46 | 46 | from renku.core.util.datetime8601 import local_now |
47 | 47 | from renku.core.util.os import are_paths_related, get_relative_paths, safe_read_yaml |
48 | | -from renku.core.workflow.activity import create_activity_graph, get_activities_until_paths, sort_activities |
| 48 | +from renku.core.workflow.activity import ( |
| 49 | + create_activity_graph, |
| 50 | + get_activities_until_paths, |
| 51 | + revert_activity, |
| 52 | + sort_activities, |
| 53 | +) |
49 | 54 | from renku.core.workflow.concrete_execution_graph import ExecutionGraph |
50 | 55 | from renku.core.workflow.plan_factory import delete_indirect_files_list |
51 | 56 | from renku.core.workflow.value_resolution import CompositePlanValueResolver, ValueResolver |
@@ -110,35 +115,9 @@ def list_workflows_command(): |
110 | 115 | return Command().command(_list_workflows).require_migration().with_database(write=False) |
111 | 116 |
|
112 | 117 |
|
113 | | -@inject.autoparams() |
114 | | -def _remove_workflow(name: str, force: bool, plan_gateway: IPlanGateway): |
115 | | - """Remove the remote named <name>. |
116 | | -
|
117 | | - Args: |
118 | | - name (str): The name of the Plan to remove. |
119 | | - force (bool): Whether to force removal or not. |
120 | | - plan_gateway(IPlanGateway): The injected Plan gateway. |
121 | | - Raises: |
122 | | - errors.ParameterError: If the Plan doesn't exist or was already deleted. |
123 | | - """ |
124 | | - workflows = plan_gateway.get_newest_plans_by_names() |
125 | | - plan = None |
126 | | - if name.startswith("/plans/"): |
127 | | - plan = next(filter(lambda x: x.id == name, workflows.values()), None) |
128 | | - if not plan and name not in workflows: |
129 | | - raise errors.ParameterError(f'The specified workflow is "{name}" is not an active workflow.') |
130 | | - |
131 | | - if not force: |
132 | | - prompt_text = f'You are about to remove the following workflow "{name}".' + "\n" + "\nDo you wish to continue?" |
133 | | - communication.confirm(prompt_text, abort=True, warning=True) |
134 | | - |
135 | | - plan = plan or workflows[name] |
136 | | - plan.delete() |
137 | | - |
138 | | - |
139 | | -def remove_workflow_command(): |
| 118 | +def remove_plan_command(): |
140 | 119 | """Command that removes the workflow named <name>.""" |
141 | | - return Command().command(_remove_workflow).require_clean().with_database(write=True).with_commit() |
| 120 | + return Command().command(remove_plan).require_clean().with_database(write=True).with_commit() |
142 | 121 |
|
143 | 122 |
|
144 | 123 | def _show_workflow(name_or_id: str): |
@@ -954,3 +933,10 @@ def iterate_workflow_command(): |
954 | 933 | return ( |
955 | 934 | Command().command(_iterate_workflow).require_migration().require_clean().with_database(write=True).with_commit() |
956 | 935 | ) |
| 936 | + |
| 937 | + |
| 938 | +def revert_activity_command(): |
| 939 | + """Command that reverts an activity.""" |
| 940 | + return ( |
| 941 | + Command().command(revert_activity).require_migration().require_clean().with_database(write=True).with_commit() |
| 942 | + ) |
0 commit comments