Skip to content

Commit

Permalink
use the specific ValueResolver when the type of workflow is known
Browse files Browse the repository at this point in the history
add documentation for cwltool provider implementation
  • Loading branch information
Viktor Gal committed Sep 3, 2021
1 parent 0b46f54 commit 34d6f02
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
4 changes: 2 additions & 2 deletions renku/core/commands/workflow.py
Expand Up @@ -32,7 +32,7 @@
from renku.core.management.interface.plan_gateway import IPlanGateway
from renku.core.management.interface.project_gateway import IProjectGateway
from renku.core.management.workflow.concrete_execution_graph import ExecutionGraph
from renku.core.management.workflow.value_resolution import ValueResolver
from renku.core.management.workflow.value_resolution import CompositePlanValueResolver, ValueResolver
from renku.core.models.workflow.composite_plan import CompositePlan
from renku.core.models.workflow.plan import AbstractPlan, Plan
from renku.core.utils import communication
Expand Down Expand Up @@ -191,7 +191,7 @@ def _group_workflow(

if link_all:
# NOTE: propagate values to for linking to use
rv = ValueResolver.get(plan, None)
rv = CompositePlanValueResolver(plan, None)
plan = rv.apply()

graph = ExecutionGraph(plan, virtual_links=True)
Expand Down
23 changes: 22 additions & 1 deletion renku/core/management/workflow/providers/cwltool_provider.py
Expand Up @@ -15,7 +15,28 @@
# 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.
"""cwltool based provider."""
"""cwltool based provider.
This implementation provides a plugin for executing workflows using ``cwltool``,
by simply exporting the workflow into a CWL format and then using ``cwltool``
to run the exported CWL file.
.. code-block:: console
$ renku workflow execute --provider cwltool example_workflow
.. topic:: Specifying custom parameters for cwltool (``--config``)
You can specify custom configuration parameters for ``cwltool`` executer
by providing a YAML file for the ``--config`` option. The YAML file
should contain both the ``LoadingContext`` and ``RuntimeContext`` key-value
pairs.
.. code-block:: console
$ renku workflow execute --config config.yaml --provider cwltool example_workflow
"""

import os
import shutil
Expand Down
13 changes: 5 additions & 8 deletions tests/cli/test_workflow.py
Expand Up @@ -305,21 +305,18 @@ def _get_plan_id(output):
@pytest.mark.parametrize("provider", available_workflow_providers())
@pytest.mark.parametrize("yaml", [False, True])
@pytest.mark.parametrize(
"workflows, parameters, expected",
"workflows, parameters",
[
([("run", 'echo "a" > output1')], {}, []),
([("run", 'echo "a" > output1')], {"run": {"outputs": ["replaced"]}}, []),
([("run", 'echo "a" > output1')], {"run": {"parameters": ["foo"], "outputs": ["bar"]}}, []),
([("run", 'echo "a" > output1')], {}),
([("run", 'echo "a" > output1')], {"run": {"outputs": ["replaced"]}}),
([("run", 'echo "a" > output1')], {"run": {"parameters": ["foo"], "outputs": ["bar"]}}),
(
[("run1", "touch data.csv"), ("run2", "wc data.csv > output")],
{"run1": {"outputs": ["foo"]}, "run2": {"inputs": ["foo"], "outputs": ["bar"]}},
[],
),
],
)
def test_workflow_execute_command(
runner, run_shell, project, capsys, client, provider, yaml, workflows, parameters, expected
):
def test_workflow_execute_command(runner, run_shell, project, capsys, client, provider, yaml, workflows, parameters):
"""test workflow execute."""

for wf in workflows:
Expand Down
8 changes: 4 additions & 4 deletions tests/core/commands/test_workflow.py
Expand Up @@ -24,7 +24,7 @@

from renku.core import errors
from renku.core.management.workflow.concrete_execution_graph import ExecutionGraph
from renku.core.management.workflow.value_resolution import ValueResolver
from renku.core.management.workflow.value_resolution import CompositePlanValueResolver
from renku.core.models.workflow.composite_plan import CompositePlan


Expand Down Expand Up @@ -409,10 +409,10 @@ def test_composite_plan_actual_values(composite_plan, mappings, defaults, values

grouped.set_mappings_from_strings(mappings)
grouped.set_mapping_defaults(defaults)
rv = ValueResolver.get(grouped, values)
assert len(rv.missing_parameters) == 0
rv = CompositePlanValueResolver(grouped, values)

actual = _get_nested_actual_values(rv.apply())
assert len(rv.missing_parameters) == 0

assert actual == expected

Expand Down Expand Up @@ -497,7 +497,7 @@ def test_composite_plan_auto_links(composite_plan, mappings, defaults, links, ra
grouped.set_mappings_from_strings(mappings)
grouped.set_mapping_defaults(defaults)

rv = ValueResolver.get(grouped, None)
rv = CompositePlanValueResolver(grouped, None)
grouped = rv.apply()
assert len(rv.missing_parameters) == 0

Expand Down

0 comments on commit 34d6f02

Please sign in to comment.