Skip to content

Commit

Permalink
feat(controller): Step level memoization. Closes #944 (#3356)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbreeze authored Jul 22, 2020
1 parent 96e520e commit 13b1d3c
Show file tree
Hide file tree
Showing 15 changed files with 718 additions and 13 deletions.
8 changes: 8 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1951,6 +1951,14 @@
}
}
},
"io.argoproj.workflow.v1alpha1.Cache": {
"type": "object",
"properties": {
"configMap": {
"$ref": "#/definitions/io.k8s.api.core.v1.ConfigMapKeySelector"
}
}
},
"io.argoproj.workflow.v1alpha1.ClusterWorkflowTemplate": {
"description": "ClusterWorkflowTemplate is the definition of a workflow template resource in cluster scope",
"type": "object",
Expand Down
46 changes: 46 additions & 0 deletions docs/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ Workflow is the definition of a workflow resource

- [`loops.yaml`](https://github.com/argoproj/argo/blob/master/examples/loops.yaml)

- [`memoize.yaml`](https://github.com/argoproj/argo/blob/master/examples/memoize.yaml)

- [`nested-workflow.yaml`](https://github.com/argoproj/argo/blob/master/examples/nested-workflow.yaml)

- [`node-selector.yaml`](https://github.com/argoproj/argo/blob/master/examples/node-selector.yaml)
Expand Down Expand Up @@ -461,6 +463,8 @@ WorkflowSpec is the specification of a Workflow.

- [`loops.yaml`](https://github.com/argoproj/argo/blob/master/examples/loops.yaml)

- [`memoize.yaml`](https://github.com/argoproj/argo/blob/master/examples/memoize.yaml)

- [`nested-workflow.yaml`](https://github.com/argoproj/argo/blob/master/examples/nested-workflow.yaml)

- [`node-selector.yaml`](https://github.com/argoproj/argo/blob/master/examples/node-selector.yaml)
Expand Down Expand Up @@ -787,6 +791,8 @@ CronWorkflowSpec is the specification of a CronWorkflow

- [`loops.yaml`](https://github.com/argoproj/argo/blob/master/examples/loops.yaml)

- [`memoize.yaml`](https://github.com/argoproj/argo/blob/master/examples/memoize.yaml)

- [`nested-workflow.yaml`](https://github.com/argoproj/argo/blob/master/examples/nested-workflow.yaml)

- [`node-selector.yaml`](https://github.com/argoproj/argo/blob/master/examples/node-selector.yaml)
Expand Down Expand Up @@ -1076,6 +1082,8 @@ WorkflowTemplateSpec is a spec of WorkflowTemplate.

- [`loops.yaml`](https://github.com/argoproj/argo/blob/master/examples/loops.yaml)

- [`memoize.yaml`](https://github.com/argoproj/argo/blob/master/examples/memoize.yaml)

- [`nested-workflow.yaml`](https://github.com/argoproj/argo/blob/master/examples/nested-workflow.yaml)

- [`node-selector.yaml`](https://github.com/argoproj/argo/blob/master/examples/node-selector.yaml)
Expand Down Expand Up @@ -1313,6 +1321,8 @@ Arguments to a template

- [`loops.yaml`](https://github.com/argoproj/argo/blob/master/examples/loops.yaml)

- [`memoize.yaml`](https://github.com/argoproj/argo/blob/master/examples/memoize.yaml)

- [`nested-workflow.yaml`](https://github.com/argoproj/argo/blob/master/examples/nested-workflow.yaml)

- [`node-selector.yaml`](https://github.com/argoproj/argo/blob/master/examples/node-selector.yaml)
Expand Down Expand Up @@ -1598,6 +1608,8 @@ Template is a reusable and composable unit of execution in a workflow

- [`loops.yaml`](https://github.com/argoproj/argo/blob/master/examples/loops.yaml)

- [`memoize.yaml`](https://github.com/argoproj/argo/blob/master/examples/memoize.yaml)

- [`nested-workflow.yaml`](https://github.com/argoproj/argo/blob/master/examples/nested-workflow.yaml)

- [`node-selector.yaml`](https://github.com/argoproj/argo/blob/master/examples/node-selector.yaml)
Expand Down Expand Up @@ -1867,6 +1879,8 @@ Outputs hold parameters, artifacts, and results from a step

- [`k8s-wait-wf.yaml`](https://github.com/argoproj/argo/blob/master/examples/k8s-wait-wf.yaml)

- [`memoize.yaml`](https://github.com/argoproj/argo/blob/master/examples/memoize.yaml)

- [`nested-workflow.yaml`](https://github.com/argoproj/argo/blob/master/examples/nested-workflow.yaml)

- [`output-artifact-gcs.yaml`](https://github.com/argoproj/argo/blob/master/examples/output-artifact-gcs.yaml)
Expand Down Expand Up @@ -2063,6 +2077,8 @@ Parameter indicate a passed string parameter to a service template with an optio

- [`loops.yaml`](https://github.com/argoproj/argo/blob/master/examples/loops.yaml)

- [`memoize.yaml`](https://github.com/argoproj/argo/blob/master/examples/memoize.yaml)

- [`nested-workflow.yaml`](https://github.com/argoproj/argo/blob/master/examples/nested-workflow.yaml)

- [`node-selector.yaml`](https://github.com/argoproj/argo/blob/master/examples/node-selector.yaml)
Expand Down Expand Up @@ -2373,6 +2389,8 @@ Inputs are the mechanism for passing parameters, artifacts, volumes from one tem

- [`loops.yaml`](https://github.com/argoproj/argo/blob/master/examples/loops.yaml)

- [`memoize.yaml`](https://github.com/argoproj/argo/blob/master/examples/memoize.yaml)

- [`nested-workflow.yaml`](https://github.com/argoproj/argo/blob/master/examples/nested-workflow.yaml)

- [`node-selector.yaml`](https://github.com/argoproj/argo/blob/master/examples/node-selector.yaml)
Expand Down Expand Up @@ -2570,6 +2588,8 @@ Pod metdata

- [`loops.yaml`](https://github.com/argoproj/argo/blob/master/examples/loops.yaml)

- [`memoize.yaml`](https://github.com/argoproj/argo/blob/master/examples/memoize.yaml)

- [`nested-workflow.yaml`](https://github.com/argoproj/argo/blob/master/examples/nested-workflow.yaml)

- [`node-selector.yaml`](https://github.com/argoproj/argo/blob/master/examples/node-selector.yaml)
Expand Down Expand Up @@ -3276,6 +3296,8 @@ ValueFrom describes a location in which to obtain the value to a parameter

- [`k8s-wait-wf.yaml`](https://github.com/argoproj/argo/blob/master/examples/k8s-wait-wf.yaml)

- [`memoize.yaml`](https://github.com/argoproj/argo/blob/master/examples/memoize.yaml)

- [`nested-workflow.yaml`](https://github.com/argoproj/argo/blob/master/examples/nested-workflow.yaml)

- [`output-parameter.yaml`](https://github.com/argoproj/argo/blob/master/examples/output-parameter.yaml)
Expand Down Expand Up @@ -3744,6 +3766,8 @@ ObjectMeta is metadata that all persisted resources must have, which includes al

- [`loops.yaml`](https://github.com/argoproj/argo/blob/master/examples/loops.yaml)

- [`memoize.yaml`](https://github.com/argoproj/argo/blob/master/examples/memoize.yaml)

- [`nested-workflow.yaml`](https://github.com/argoproj/argo/blob/master/examples/nested-workflow.yaml)

- [`node-selector.yaml`](https://github.com/argoproj/argo/blob/master/examples/node-selector.yaml)
Expand Down Expand Up @@ -4225,6 +4249,8 @@ A single application container that you want to run within a pod.

- [`loops.yaml`](https://github.com/argoproj/argo/blob/master/examples/loops.yaml)

- [`memoize.yaml`](https://github.com/argoproj/argo/blob/master/examples/memoize.yaml)

- [`nested-workflow.yaml`](https://github.com/argoproj/argo/blob/master/examples/nested-workflow.yaml)

- [`node-selector.yaml`](https://github.com/argoproj/argo/blob/master/examples/node-selector.yaml)
Expand Down Expand Up @@ -4872,6 +4898,8 @@ PersistentVolumeClaimSpec describes the common attributes of storage devices and

- [`loops.yaml`](https://github.com/argoproj/argo/blob/master/examples/loops.yaml)

- [`memoize.yaml`](https://github.com/argoproj/argo/blob/master/examples/memoize.yaml)

- [`nested-workflow.yaml`](https://github.com/argoproj/argo/blob/master/examples/nested-workflow.yaml)

- [`node-selector.yaml`](https://github.com/argoproj/argo/blob/master/examples/node-selector.yaml)
Expand Down Expand Up @@ -5075,6 +5103,13 @@ Represents a cinder volume resource in Openstack. A Cinder volume must exist bef

Adapts a ConfigMap into a volume.The contents of the target ConfigMap's Data field will be presented in a volume as files using the keys in the Data field as the file names, unless the items element is populated with specific mappings of keys to paths. ConfigMap volumes support ownership management and SELinux relabeling.

<details>
<summary>Examples with this field (click to open)</summary>
<br>

- [`memoize.yaml`](https://github.com/argoproj/argo/blob/master/examples/memoize.yaml)
</details>

### Fields
| Field Name | Field Type | Description |
|:----------:|:----------:|---------------|
Expand Down Expand Up @@ -5397,6 +5432,8 @@ EnvVarSource represents a source for the value of an EnvVar.

- [`k8s-wait-wf.yaml`](https://github.com/argoproj/argo/blob/master/examples/k8s-wait-wf.yaml)

- [`memoize.yaml`](https://github.com/argoproj/argo/blob/master/examples/memoize.yaml)

- [`nested-workflow.yaml`](https://github.com/argoproj/argo/blob/master/examples/nested-workflow.yaml)

- [`output-parameter.yaml`](https://github.com/argoproj/argo/blob/master/examples/output-parameter.yaml)
Expand Down Expand Up @@ -5856,6 +5893,8 @@ ListMeta describes metadata that synthetic resources must have, including lists

- [`loops.yaml`](https://github.com/argoproj/argo/blob/master/examples/loops.yaml)

- [`memoize.yaml`](https://github.com/argoproj/argo/blob/master/examples/memoize.yaml)

- [`nested-workflow.yaml`](https://github.com/argoproj/argo/blob/master/examples/nested-workflow.yaml)

- [`node-selector.yaml`](https://github.com/argoproj/argo/blob/master/examples/node-selector.yaml)
Expand Down Expand Up @@ -5991,6 +6030,13 @@ A null or empty node selector term matches no objects. The requirements of them

Adapts a ConfigMap into a projected volume.The contents of the target ConfigMap's Data field will be presented in a projected volume as files using the keys in the Data field as the file names, unless the items element is populated with specific mappings of keys to paths. Note that this is identical to a configmap volume source without the default mode.

<details>
<summary>Examples with this field (click to open)</summary>
<br>

- [`memoize.yaml`](https://github.com/argoproj/argo/blob/master/examples/memoize.yaml)
</details>

### Fields
| Field Name | Field Type | Description |
|:----------:|:----------:|---------------|
Expand Down
6 changes: 6 additions & 0 deletions docs/swagger.md
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,12 @@ Backoff is a backoff strategy to use within retryStrategy
| factor | integer | Factor is a factor to multiply the base duration after each failed retry | No |
| maxDuration | string | MaxDuration is the maximum amount of time allowed for the backoff strategy | No |

#### io.argoproj.workflow.v1alpha1.Cache

| Name | Type | Description | Required |
| ---- | ---- | ----------- | -------- |
| configMap | [io.k8s.api.core.v1.ConfigMapKeySelector](#io.k8s.api.core.v1.configmapkeyselector) | | No |

#### io.argoproj.workflow.v1alpha1.ClusterWorkflowTemplate

ClusterWorkflowTemplate is the definition of a workflow template resource in cluster scope
Expand Down
30 changes: 30 additions & 0 deletions examples/memoize.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This example demonstrates the ability to memoize a template
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: memoized-workflow-
spec:
entrypoint: whalesay
arguments:
parameters:
- name: message
value: test-3
templates:
- name: whalesay
inputs:
parameters:
- name: message
memoize:
key: "{{inputs.parameters.message}}"
cache:
configMap:
name: whalesay-cache
container:
image: docker/whalesay:latest
command: [sh, -c]
args: ["sleep 10; cowsay {{inputs.parameters.message}} > /tmp/hello_world.txt"]
outputs:
parameters:
- name: hello
valueFrom:
path: /tmp/hello_world.txt
24 changes: 24 additions & 0 deletions manifests/base/crds/full/argoproj.io_clusterworkflowtemplates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3548,6 +3548,30 @@ spec:
type: object
type: array
type: object
memoize:
properties:
cache:
properties:
configMap:
properties:
key:
type: string
name:
type: string
optional:
type: boolean
required:
- key
type: object
required:
- configMap
type: object
key:
type: string
required:
- cache
- key
type: object
metadata:
properties:
annotations:
Expand Down
24 changes: 24 additions & 0 deletions manifests/base/crds/full/argoproj.io_cronworkflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3569,6 +3569,30 @@ spec:
type: object
type: array
type: object
memoize:
properties:
cache:
properties:
configMap:
properties:
key:
type: string
name:
type: string
optional:
type: boolean
required:
- key
type: object
required:
- configMap
type: object
key:
type: string
required:
- cache
- key
type: object
metadata:
properties:
annotations:
Expand Down
Loading

0 comments on commit 13b1d3c

Please sign in to comment.