MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / megflow_run

Function megflow_run

flow-python/megflow/command_line.py:9–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7import pkg_resources
8
9def megflow_run():
10 if pkg_resources.resource_exists('megflow', 'lib') and pkg_resources.resource_isdir('megflow', 'lib'):
11 if 'MGF_CMDLINE_FLAG' not in os.environ:
12 os.environ['MGF_CMDLINE_FLAG'] = '1'
13 if 'LD_LIBRARY_PATH' in os.environ:
14 os.environ['LD_LIBRARY_PATH'] = pkg_resources.resource_filename('megflow', 'lib') + ':' + os.environ['LD_LIBRARY_PATH']
15 else:
16 os.environ['LD_LIBRARY_PATH'] = pkg_resources.resource_filename('megflow', 'lib')
17
18 try:
19 os.execv(sys.argv[0], sys.argv)
20 return
21 except Exception as exc:
22 print('Failed re-exec:', exc)
23 sys.exit(1)
24
25 import argparse
26 import megflow
27
28 parser = argparse.ArgumentParser(prog='megflow_run', description='run a pipeline with plugins.')
29 parser.add_argument('--dump', help='the path to dump graph', action='store_true')
30 parser.add_argument('-p', '--plugin', required=True, type=str, help='plugin path')
31 parser.add_argument('-m', '--module', type=str, help='module path')
32 parser.add_argument('-c', '--config', type=str, help='config path')
33 parser.add_argument('--dynamic', type=str, help='dynamic config path')
34 parser.add_argument('--version', action='version', version='%(prog)s {version}'.format(version=megflow.__version__))
35
36 args = parser.parse_args()
37
38 megflow.Graph(
39 dump=args.dump,
40 plugin_path=args.plugin,
41 module_path=args.module,
42 config_path=args.config,
43 dynamic_path = args.dynamic
44 ).wait()
45
46
47def run_with_plugins():

Callers 1

command_line.pyFile · 0.85

Calls 1

waitMethod · 0.45

Tested by

no test coverage detected