generated from lenskit/lk-demo-experiment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.py
34 lines (27 loc) · 816 Bytes
/
tasks.py
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
import json
import sys
from os import fspath
from pathlib import Path
from _jsonnet import evaluate_file
from invoke import task
from ruamel.yaml import YAML
ENV_BASE = Path("envs")
def _msg(fmt, *args):
print(fmt.format(*args), file=sys.stderr)
@task
def update_pipeline(c):
"""
Update the DVC pipeline.
The pipeline is miantained in jsonnet files for consistency and to reduce
repetitive code. This task re-renders them.
"""
yaml = YAML()
runs = Path("runs")
pipes = runs.glob("*/dvc.jsonnet")
for file in pipes:
print("processing", file, file=sys.stderr)
config = evaluate_file(fspath(file))
config = json.loads(config)
yf = file.with_suffix(".yaml")
with yf.open("w", encoding="utf8") as f:
yaml.dump(config, f)