Skip to content

Commit fbea7c7

Browse files
authored
Merge branch 'master' into 000-add-spellcheck
2 parents 584e53b + 4bb0f08 commit fbea7c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1171
-349
lines changed

.github/workflows/acceptance-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
renku-notebooks: ${{ steps.deploy-comment.outputs.renku-notebooks}}
2828
renku-ui: ${{ steps.deploy-comment.outputs.renku-ui}}
2929
test-enabled: ${{ steps.deploy-comment.outputs.test-enabled}}
30+
extra-values: ${{ steps.deploy-comment.outputs.extra-values}}
3031
steps:
3132
- id: deploy-comment
3233
uses: SwissDataScienceCenter/renku-actions/[email protected]
@@ -64,6 +65,7 @@ jobs:
6465
renku_graph: "${{ needs.check-deploy.outputs.renku-graph }}"
6566
renku_notebooks: "${{ needs.check-deploy.outputs.renku-notebooks }}"
6667
renku_ui: "${{ needs.check-deploy.outputs.renku-ui }}"
68+
extra_values: "${{ needs.check-deploy.outputs.extra-values }}"
6769
- name: Check existing renkubot comment
6870
uses: peter-evans/find-comment@v1
6971
id: findcomment

design/001-new-workflow-commands/001-new-workflow-commands.md

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,14 @@ renku workflow execute [<options>] <name or uuid>
146146
147147
```
148148

149-
#### renku workflow loop
149+
#### renku workflow iterate
150150

151151
Has similar semantics to `renku workflow execute`, but allows doing multiple executions in a single go with variable inputs/outputs/parameters.
152152

153153
Syntax example:
154154

155155
```
156-
renku workflow loop <workflow name> --mapping <mapping>
156+
renku workflow iterate <workflow name> --mapping <mapping>
157157
```
158158

159159
Where mapping is a list of mappings for input parameters/files that gets iterated over. This can contain values that are the same for all executions and then a list of parameters that vary.
@@ -163,7 +163,7 @@ Otherwise supports the same flags as `renku workflow execute`
163163
##### Detailed Parameter Description
164164

165165
```
166-
renku workflow loop [<options>] <name or uuid>
166+
renku workflow iterate [<options>] <name or uuid>
167167
168168
<name or uuid> The name of a workflow or its id
169169
@@ -172,10 +172,10 @@ renku workflow loop [<options>] <name or uuid>
172172
173173
-c|--config YAML file containing config for the provider
174174
175-
-s|--set <parameter>=[<value> | <value>,<values...>] Set <value> or value range for a <parameter>
175+
-m|--map <parameter>=[<value> | <value>,<values...>] Set <value> or value range for a <parameter>
176176
to be used in execution
177177
178-
--values <file> YAML file containing parameter mappings to be used (See
178+
--mapping <file> YAML file containing parameter mappings to be used (See
179179
`Input/Output/Argument Mappings`)
180180
181181
```
@@ -318,35 +318,49 @@ myworkflow:
318318

319319
At the top level, it specifies the parameter values of the workflow (run or grouped run) to be executed. It can also contain values for steps contained in a grouped run, by specifying the name of the step and setting parameters for that step. In case of the grouped run mapping its values to child steps, setting values for child steps directly overwrites those values for the step and all its (potential) children.
320320

321-
For `renku workflow loop` the values file looks like:
321+
For `renku workflow iterate` the values file looks like:
322322

323323
```
324324
learning_rate: 0.9
325325
dataset_input: dataset.csv
326-
chart_output: mychart.{loop_index}.png
327-
looped_parameters:
328-
- alpha: 0.1
329-
beta: 0.7
330-
- alpha: 0.2
331-
beta: 0.6
332-
- alpha: 0.5
333-
beta: 0.2
326+
chart_output: mychart.{iter_index}.png
327+
alpha: [0.1, 0.2, 0.5]
328+
beta: [0.7, 0.6]
329+
gamma@tag1: [1.0, 2.0, 3.0]
330+
delta@tag1: [10.0, 20.0, 30.0]
334331
myworkflow:
335332
lr: 0.8
336333
lookuptable: lookup.xml
337334
myotherworkflow:
338335
language: en
339336
```
340337

341-
Where the workflow is run for each entry in `looped_parameters` and the templated variable `{loop}` is substituted for the loop index (1, 2, 3, ...).
338+
where the the paramaters with list values are considered as the iteration parameters and the templated variable `{iter_index}` is substituted with the iteration index (0, 1, 2, ...).
339+
There are two distinct type of paramaters:
340+
1. The parameter's value is a simple list, `alpha` and `beta` in the above example. These list values are simply the possible values of the given parameter. The iterate command will generate the cartesian product of these possible values and will be used in each iteration. Hence, the length of the list of possible values is not constrained, i.e. it can contain arbitrary amount of values.
341+
2. Tagged iteration parameters, `gamma` and `delta` in the above example. A parameter can be tagged in the values file by adding the `@<TAG>` suffix to the parameter's name. Parameters of the same tag shall have the same number of possible values. This is because these values are going to be iterated over as a tuple, in the provided order. For example in case of `gamma` and `delta` the `renku workflow iterate` command would simply result in three iterations: `[(1.0, 10.0), (2.0, 20.0), (3.0, 30.0)]`
342+
343+
One can mix these two types of parameters.
344+
345+
Based on the this, the first six iterations using the values file above will result in the following workflow parametrization and execution:
346+
```
347+
chart_output alpha beta gamma delta
348+
-------------- ------- ------ ------- -------
349+
mychart.0.png 0.1 0.7 1 10
350+
mychart.1.png 0.1 0.7 2 20
351+
mychart.2.png 0.1 0.7 3 30
352+
mychart.3.png 0.1 0.6 1 10
353+
mychart.4.png 0.1 0.6 2 20
354+
mychart.5.png 0.1 0.6 3 30
355+
```
342356

343357
On the commandline, values can be specified with `--set learning_rate=0.9 --set myworkflow.lr=0.8`.
344358

345359
#### Templated Values
346360

347361
Parameter values can contain one of several templated values or glob patterns:
348362

349-
- `{loop_index}`: Loop index in the case of a `renku workflow loop` call.
363+
- `{iter_index}`: Iteration index in the case of a `renku workflow iterate` call.
350364
- `{%m-%d-%Y_%H-%M-%S}`: Current date/time (Following python date formatting).
351365
- `a*b?`: Glob/`fnmatch` patterns for paths.
352366

@@ -466,7 +480,7 @@ Outputs:
466480
$ echo "
467481
static:
468482
epochs: 200
469-
output_file: result.{loop_index}.json
483+
output_file: result.{iter_index}.json
470484
variable:
471485
- lr:0.1
472486
batch-size: 32
@@ -477,7 +491,7 @@ variable:
477491
- lr:1.0
478492
batch-size: 1024
479493
" > mapping.yaml
480-
$ renku workflow loop --provider cwl --mapping mapping.yaml train_model
494+
$ renku workflow iterate --provider cwl --mapping mapping.yaml train_model
481495
Preparing environment....
482496
Executing workflows
483497
Run 1...
@@ -559,7 +573,7 @@ The following outputs were produced:
559573
data.2021-02-24.csv
560574
```
561575
#### Workflow execution with extensive parameter search
562-
See detailed user story to `renku workflow loop` [here](https://github.com/SwissDataScienceCenter/renku-python/edit/rfc-001-workflow-ux/design/001-new-workflow-commands/user-story-workflow-execution-with-extensive-parameter-space.md)
576+
See detailed user story to `renku workflow iterate` [here](https://github.com/SwissDataScienceCenter/renku-python/edit/rfc-001-workflow-ux/design/001-new-workflow-commands/user-story-workflow-execution-with-extensive-parameter-space.md)
563577

564578
## Drawbacks
565579

2.27 MB
Loading

renku/cli/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,15 @@ def cli(ctx, path, external_storage_requested):
185185
"""Check common Renku commands used in various situations."""
186186
from renku.core.management import RENKU_HOME
187187
from renku.core.management.client import LocalClient
188+
from renku.core.management.migrations.utils import OLD_METADATA_PATH
189+
from renku.core.management.repository import RepositoryApiMixin
190+
from renku.core.metadata.database import Database
188191

189192
renku_path = Path(path) / RENKU_HOME
190-
if not renku_path.exists() and not is_allowed_command(ctx):
193+
old_metadata = renku_path / OLD_METADATA_PATH
194+
new_metadata = renku_path / RepositoryApiMixin.DATABASE_PATH / Database.ROOT_OID
195+
196+
if not old_metadata.exists() and not new_metadata.exists() and not is_allowed_command(ctx):
191197
raise UsageError(
192198
(
193199
"`{0}` is not a renku repository.\n"

renku/cli/migrate.py

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -121,42 +121,10 @@ def migrate(check, skip_template_update, skip_docker_update, strict):
121121
@click.command(hidden=True)
122122
def migrationscheck():
123123
"""Check status of the project and current renku-python version."""
124-
from renku.core.commands.migrate import migrations_check, migrations_versions
125-
126-
latest_version, project_version = migrations_versions().build().execute().output
127-
(
128-
migration_required,
129-
project_supported,
130-
template_update_possible,
131-
current_template_version,
132-
latest_template_version,
133-
template_source,
134-
template_ref,
135-
template_id,
136-
automated_update,
137-
docker_update_possible,
138-
) = (
139-
migrations_check().lock_project().build().execute().output
140-
)
124+
from renku.core.commands.migrate import migrations_check
141125

142-
click.echo(
143-
json.dumps(
144-
{
145-
"latest_version": latest_version,
146-
"project_version": project_version,
147-
"migration_required": migration_required,
148-
"project_supported": project_supported,
149-
"template_update_possible": template_update_possible,
150-
"current_template_version": str(current_template_version),
151-
"latest_template_version": str(latest_template_version),
152-
"template_source": template_source,
153-
"template_ref": template_ref,
154-
"template_id": template_id,
155-
"automated_update": automated_update,
156-
"docker_update_possible": docker_update_possible,
157-
}
158-
)
159-
)
126+
result = migrations_check().lock_project().build().execute().output
127+
click.echo(json.dumps(result))
160128

161129

162130
@click.command(hidden=True)

renku/cli/workflow.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,55 @@
111111
values YAML file and passing that using ``--values``. Provider specific
112112
settings can be passed as file using the ``--config`` parameter.
113113
114+
Iterate Plans
115+
*************
116+
117+
.. image:: ../_static/asciicasts/iterate_plan.gif
118+
:width: 850
119+
:alt: Iterate Plans
120+
121+
For executing a Plan with different parameterization ``renku workflow iterate``
122+
could be used. This sub-command is basically conducting a 'grid search'-like
123+
execution of a Plan, with parameter-sets provided by the user.
124+
125+
.. code-block:: console
126+
127+
$ renku workflow iterate --map parameter-1=[1,2,3] \
128+
--map parameter-2=[10,20] my-run
129+
130+
The set of possible values for a parameter can be given by ``--map`` command
131+
line argument or by specifying them in a values YAML file and passing that
132+
using ``--mapping``.
133+
134+
By default ``renku workflow iterate`` will execute all the combination of the
135+
given parameters' list of possible values. Sometimes it is desired that instead
136+
of all the combination of possible values, a specific tuple of values are
137+
executed. This could be done by marking the parameters that should be bound
138+
together with the ``@tag`` suffix in their names.
139+
140+
.. code-block:: console
141+
142+
$ renku workflow iterate --map parameter-1@tag1=[1,2,3] \
143+
--map parameter-1@tag1=[10,5,30] my-run
144+
145+
This will result in only three distinct execution of the ``my-run`` Plan,
146+
with the following parameter combinations: ``[(1,10), (2,5), (3,30)]``. It is
147+
important to note that parameters that have the same tag, should have the same
148+
number of possible values, i.e. the values list should have the same length.
149+
150+
There's a special template variable for parameter values ``{iter_index}``, which
151+
can be used to mark each iteration's index in a value of a parameter. The template
152+
variable is going to be substituted with the iteration index (0, 1, 2, ...).
153+
154+
.. code-block:: console
155+
156+
$ renku workflow iterate --map parameter-1=[10,20,30] \
157+
--map output=output_{iter_index}.txt my-run
158+
159+
This would execute ``my-run`` three times, where ``parameter-1`` values would be
160+
``10``, `20`` and ``30`` and the producing output files ``output_0.txt``,
161+
``output_1.txt`` and ``output_2.txt`` files in this order.
162+
114163
Exporting Plans
115164
***************
116165
@@ -1060,3 +1109,58 @@ def visualize(sources, columns, exclude_files, ascii, interactive, no_color, pag
10601109
text_output, navigation_data, result.output.vertical_space, use_color=not no_color
10611110
)
10621111
viewer.run()
1112+
1113+
1114+
@workflow.command()
1115+
@click.option(
1116+
"mapping_path",
1117+
"--mapping",
1118+
metavar="<file>",
1119+
type=click.Path(exists=True, dir_okay=False),
1120+
help="YAML file containing parameter mappings to be used.",
1121+
)
1122+
@click.option(
1123+
"--dry-run",
1124+
"-n",
1125+
is_flag=True,
1126+
default=False,
1127+
help="Print the generated plans with their parameters instead of executing.",
1128+
show_default=True,
1129+
)
1130+
@click.option(
1131+
"provider",
1132+
"-p",
1133+
"--provider",
1134+
default="cwltool",
1135+
show_default=True,
1136+
type=click.Choice(Proxy(_available_workflow_providers), case_sensitive=False),
1137+
help="The workflow engine to use.",
1138+
)
1139+
@click.option("mappings", "-m", "--map", multiple=True, help="Mapping for a workflow parameter.")
1140+
@click.option("config", "-c", "--config", metavar="<config file>", help="YAML file containing config for the provider.")
1141+
@click.argument("name_or_id", required=True)
1142+
def iterate(name_or_id, mappings, mapping_path, dry_run, provider, config):
1143+
"""Execute a workflow by iterating through a range of provided parameters."""
1144+
from renku.core.commands.view_model.plan import PlanViewModel
1145+
from renku.core.commands.workflow import iterate_workflow_command, show_workflow_command
1146+
1147+
if len(mappings) == 0 and mapping_path is None:
1148+
raise errors.UsageError("No mapping has been given for the iteration!")
1149+
1150+
plan = show_workflow_command().build().execute(name_or_id=name_or_id).output
1151+
1152+
if plan:
1153+
if isinstance(plan, PlanViewModel):
1154+
_print_plan(plan)
1155+
else:
1156+
_print_composite_plan(plan)
1157+
1158+
communicator = ClickCallback()
1159+
iterate_workflow_command().with_communicator(communicator).build().execute(
1160+
name_or_id=name_or_id,
1161+
mapping_path=mapping_path,
1162+
mappings=mappings,
1163+
dry_run=dry_run,
1164+
provider=provider,
1165+
config=config,
1166+
)

renku/core/commands/init.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
from renku.core.management.interface.client_dispatcher import IClientDispatcher
3737
from renku.core.management.interface.database_dispatcher import IDatabaseDispatcher
3838
from renku.core.management.interface.database_gateway import IDatabaseGateway
39+
from renku.core.management.migrations.utils import OLD_METADATA_PATH
3940
from renku.core.management.repository import INIT_APPEND_FILES, INIT_KEEP_FILES
4041
from renku.core.metadata.repository import Repository
4142
from renku.core.models.tabulate import tabulate
@@ -326,6 +327,14 @@ def _init(
326327
database_gateway = inject.instance(IDatabaseGateway)
327328
database_gateway.initialize()
328329

330+
# add metadata.yml for backwards compatibility
331+
metadata_path = client.renku_path.joinpath(OLD_METADATA_PATH)
332+
with open(metadata_path, "w") as f:
333+
f.write(
334+
"# Dummy file kept for backwards compatibility, does not contain actual version\n"
335+
"'http://schema.org/schemaVersion': '9'"
336+
)
337+
329338
# NOTE: clone the repo
330339
communication.echo("Initializing new Renku repository... ")
331340
with client.lock:

0 commit comments

Comments
 (0)