-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipeline-set.nix
54 lines (47 loc) · 1.21 KB
/
pipeline-set.nix
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
53
54
{ lib
, runCommandNoCC
, remarshal
}:
{ annotators
, pipelines
, tokenizers
}:
let
# Convert a Nix value to YAML by using the built-in JSON support and then
# converting JSON to YAML using remarshal.
toYAML = name: value: runCommandNoCC name
{
nativeBuildInputs = [ remarshal ];
value = builtins.toJSON value;
passAsFile = [ "value" ];
} ''
json2yaml "$valuePath" "$out"
'';
defaultPipelineSettings = {
batch_size = 32;
read_ahead = 200;
};
# Map annotator derivations to their configuration files.
annotators' =
let
annotatorConfig = _: drv: {
syntaxdot_config = "${drv.out}/share/syntaxdot/models/${drv.pname}/syntaxdot.conf";
max_len = 150;
};
in
lib.mapAttrs annotatorConfig annotators;
# Add default settings and descriptions to the pipelines.
pipelines' =
let
addAttrs = _: pipeline: pipeline // defaultPipelineSettings // {
description = annotators.${pipeline.annotator}.meta.description;
};
in
lib.mapAttrs addAttrs pipelines;
# REST server configuration.
config = {
inherit tokenizers;
annotators = annotators';
pipelines = pipelines';
};
in toYAML "syntaxdot-rest.conf" config