-
Notifications
You must be signed in to change notification settings - Fork 16
/
template.yaml
52 lines (49 loc) · 1.47 KB
/
template.yaml
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
entrypoint: main
templates:
- name: main
dag:
tasks:
- name: metrics-mocker
template: metrics-mocker
- name: metrics-writer
template: metrics-writer
dependencies: [metrics-mocker]
arguments:
# Use sys-metrics artifact output from metrics-mocker
# Note that this output is automatically available from previous task
artifacts:
- name: sys-metrics
from: "{{tasks.metrics-mocker.outputs.artifacts.sys-metrics}}"
- name: metrics-mocker
script:
image: python:3.9.1-alpine
command: [python, '-u']
source: |
import json
# Mock metrics
metrics = [
{'name': 'accuracy', 'value': 0.981},
{'name': 'loss', 'value': 0.018},
]
# Write mock metrics to `/tmp/sys-metrics.json`
# Writing to this exact file automatically exposes this file to next Workflow task
with open('/tmp/sys-metrics.json', 'w') as f:
json.dump(metrics, f)
- name: metrics-writer
inputs:
artifacts:
- name: sys-metrics
path: /tmp/sys-metrics.json
- git:
repo: https://github.com/onepanelio/templates.git
revision: v0.18.0
name: src
path: /mnt/src
container:
image: onepanel/python-sdk:v0.19.0
command:
- python
- -u
args:
- /mnt/src/tasks/metrics-writer/main.py
- --from_file=/tmp/sys-metrics.json