-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun-msml-operator.py
More file actions
executable file
·53 lines (35 loc) · 1.24 KB
/
run-msml-operator.py
File metadata and controls
executable file
·53 lines (35 loc) · 1.24 KB
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
__author__ = 'weigl'
__version__ = '0.1alpha'
from argparse import ArgumentParser
from itertools import chain
from msml.frontend import *
from msml.model.alphabet import *
msml = App(novalidate=True)
def build_argparse():
parser = ArgumentParser(prog="run-msml-operator.py", description="""
Let you execute every msml operator in the alphabet.
""", version=__version__)
subparsers = parser.add_subparsers(dest='operator_name')
for op in msml.alphabet.operators.values():
assert isinstance(op, Operator)
op_args = subparsers.add_parser(op.name,
help=op.meta.get('doc'))
for i in chain(op.input.values(), op.parameters.values()):
isinstance(i, Slot)
op_args.add_argument("--%s" % i.name,
help="wait for merge",
default=i.default)
return parser
def run_operator(name, kwargs):
operator = msml.alphabet.get(name)
operator.validate()
print operator(**kwargs)
def main():
parser = build_argparse()
ns = parser.parse_args()
dct = vars(ns)
print ns
name = dct.get('operator_name')
del dct['operator_name']
run_operator(name, dct)
main()