-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathcli_workflow.py
More file actions
56 lines (47 loc) · 2.41 KB
/
cli_workflow.py
File metadata and controls
56 lines (47 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright 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.
"""Renku CLI fixtures for workflow methods."""
import pytest
from renku.ui.cli import cli
@pytest.fixture
def workflow_graph(run_shell, project, cache_test_project):
"""Setup a project with a workflow graph."""
cache_test_project.set_name("workflow_graph_fixture")
if not cache_test_project.setup():
def _run_workflow(name, command, extra_args=""):
output = run_shell(f"renku run --name {name} {extra_args} -- {command}")
# Assert not allocated stderr.
assert output[1] is None
_run_workflow("r1", "echo 'test' > A")
_run_workflow("r2", "tee B C < A")
_run_workflow("r3", "cp A Z")
_run_workflow("r4", "cp B X")
_run_workflow("r5", "cat C Z > Y")
_run_workflow("r6", "bash -c 'cat X Y | tee R S'", extra_args="--input X --input Y --output R --output S")
_run_workflow("r7", "echo 'other' > H")
_run_workflow("r8", "tee I J < H")
cache_test_project.save()
@pytest.fixture
def project_with_dataset_and_workflows(runner, run_shell, project, directory_tree, cache_test_project):
"""Project with a dataset and some workflows."""
if not cache_test_project.setup():
assert 0 == runner.invoke(cli, ["dataset", "create", "my-data"]).exit_code
assert 0 == runner.invoke(cli, ["dataset", "add", "--copy", "my-data", str(directory_tree)]).exit_code
assert run_shell('renku run --name run1 echo "my input string" > my_output_file')[1] is None
assert run_shell("renku run --name run2 cp my_output_file my_output_file2")[1] is None
assert run_shell("renku workflow compose my-composite-plan run1 run2")[1] is None
cache_test_project.save()
yield project