-
Notifications
You must be signed in to change notification settings - Fork 10
/
example.py
executable file
·57 lines (43 loc) · 1.63 KB
/
example.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
import os
use_multi_process = (os.environ.get('PFLOW_MULTIPROCESS', '') == '1')
if use_multi_process:
from pflow.executors.multi_process import MultiProcessGraphExecutor as GraphExecutorImpl
else:
# Need to load before logging
from pflow.executors.single_process import SingleProcessGraphExecutor as GraphExecutorImpl
import logging
import pflow
import pflow.utils
import example_graphs
log = logging.getLogger(__name__)
def run_graph(graph):
# Write graphml file
graphml_out_path = os.path.expanduser('~/graphml')
if not os.path.exists(graphml_out_path):
os.mkdir(graphml_out_path)
graph_file = '%s/%s.graphml' % (graphml_out_path, graph.name)
graph.write_graphml(graph_file)
log.info('Running graph: %s' % graph.name)
log.debug('Runtime is: %s' % GraphExecutorImpl.__name__)
# Execute graph
executor = GraphExecutorImpl(graph)
executor.execute()
def main():
pflow.utils.init_logger(filename='debug.log',
default_level=logging.DEBUG,
console_level=logging.INFO)
sag = example_graphs.awesome.SuperAwesomeDemoGraph('AWESOME_1')
test_graphs = [
example_graphs.simple.SimpleGraph('SIMPLE'),
sag,
sag,
# example_graphs.popular_music.PopularMusicGraph('MUSIC_1'),
# example_graphs.mongo_poc.MongoPocGraph('MONGO_POC'),
# example_graphs.process_spawning_logger.ProcessSpawningLogger('PROCSPAWN_1'),
example_graphs.subgraphs.SubGraphExample('SUBGRAPH_1')
]
for graph in test_graphs:
run_graph(graph)
if __name__ == '__main__':
main()