-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_traintype_component.yaml
60 lines (53 loc) · 1.76 KB
/
get_traintype_component.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
53
54
55
56
57
58
59
60
name: Get train type
inputs:
- {name: args, type: String}
outputs:
- {name: Output, type: String}
implementation:
container:
image: lkorver/praxi-columbus-base:0.065
command:
- sh
- -ec
- |
program_path=$(mktemp)
printf "%s" "$0" > "$program_path"
python3 -u "$program_path" "$@"
- |
def get_train_type(args_path):
import tagset_gen
import json
import pickle
with open(args_path, 'rb') as reader:
user_in = pickle.load(reader)
train_type = 'multilabel'
return train_type
def _serialize_str(str_value: str) -> str:
if not isinstance(str_value, str):
raise TypeError('Value "{}" has type "{}" instead of str.'.format(
str(str_value), str(type(str_value))))
return str_value
import argparse
_parser = argparse.ArgumentParser(prog='Get train type', description='')
_parser.add_argument("--args", dest="args_path", type=str, required=True, default=argparse.SUPPRESS)
_parser.add_argument("----output-paths", dest="_output_paths", type=str, nargs=1)
_parsed_args = vars(_parser.parse_args())
_output_files = _parsed_args.pop("_output_paths", [])
_outputs = get_train_type(**_parsed_args)
_outputs = [_outputs]
_output_serializers = [
_serialize_str,
]
import os
for idx, output_file in enumerate(_output_files):
try:
os.makedirs(os.path.dirname(output_file))
except OSError:
pass
with open(output_file, 'w') as f:
f.write(_output_serializers[idx](_outputs[idx]))
args:
- --args
- {inputPath: args}
- '----output-paths'
- {outputPath: Output}