-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrun.py
executable file
·51 lines (44 loc) · 1.15 KB
/
run.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
#!/usr/bin/env python3 -B
import os
import sys
import bonobo
import importlib
from cromulent import vocab
import settings
if len(sys.argv) < 2:
print("python3 ./run.py project [dot] [*args]")
sys.exit()
else:
project = sys.argv[1]
pipe = importlib.import_module(f'pipeline.projects.{project}')
Pipeline = pipe.Pipeline
sys.argv = [sys.argv[0], *sys.argv[2:]]
### Run the Pipeline
if __name__ == '__main__':
if settings.DEBUG:
LIMIT = int(os.environ.get('GETTY_PIPELINE_LIMIT', 1))
PACK_SIZE = 1
else:
LIMIT = int(os.environ.get('GETTY_PIPELINE_LIMIT', 10000000))
PACK_SIZE = 10000000
vocab.add_linked_art_boundary_check()
print_dot = False
if 'dot' in sys.argv[1:]:
print_dot = True
sys.argv[1:] = [a for a in sys.argv[1:] if a != 'dot']
parser = bonobo.get_argument_parser()
with bonobo.parse_args(parser) as options:
try:
pipeline = Pipeline(
output_path=settings.output_file_path,
models=settings.arches_models,
pack_size=PACK_SIZE,
limit=LIMIT,
debug=settings.DEBUG
)
if print_dot:
print(pipeline.get_graph()._repr_dot_())
else:
pipeline.run(**options)
except RuntimeError:
raise ValueError()