-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwith_items_aggregate.yml
35 lines (35 loc) · 1.13 KB
/
with_items_aggregate.yml
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
# This workflow demonstrates how to combine the results of multiple with-items
# tasks to determine whether to run a follow-on task. In this example, the
# value of $.go_on will be [False, False, True], .any() will evaluate to
# True, and task_2 will run.
version: '2.0'
workflow:
tasks:
task_1:
action: civis.scripts.python3
with-items: item in <% range(3) %>
input:
source: |
import civis
import json
import os
client = civis.APIClient()
json_val = client.json_values.post(
json.dumps({ 'go_on': <% $.item %> > 1 }),
name='result'
)
client.scripts.post_python3_runs_outputs(
os.environ['CIVIS_JOB_ID'],
os.environ['CIVIS_RUN_ID'],
'JSONValue',
json_val.id
)
publish:
go_on: <% task(task_1).result.select($.outputs).flatten().select($.value).select($.go_on) %>
on-success:
- task_2: <% $.go_on.where($).any() %>
task_2:
action: civis.scripts.python3
input:
source: |
print('<% $.go_on %>')