-
Notifications
You must be signed in to change notification settings - Fork 0
/
archipelago_xml_data.py
48 lines (37 loc) · 1.74 KB
/
archipelago_xml_data.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
import click
import importlib
import transformation.script as transformation
import upload.script as upload
@click.command()
@click.option('-p', '--preprocessing', 'exec_preprocessing', is_flag=True, help="Execute the pre-processing")
@click.option('-t', '--transformation', 'exec_transformation', is_flag=True, help="Execute the transformation")
@click.option('-u', '--upload', 'exec_upload', is_flag=True, help="Execute the upload", default=False)
@click.option('-d', '--delete', 'exec_delete', is_flag=True, help="Execute the delete", default=False)
@click.option('-c', '--config', 'config', help="configuration option", default='veniss')
@click.option('-a', required=True, multiple=True, help="Types to iterate")
@click.option('-sa', '--subtype', 'sa', multiple=True, help="Sub types to iterate")
@click.option('-l', '--limit', help="Number of files to execute", default=None)
def execute_pipeline(exec_preprocessing, exec_transformation, exec_upload, exec_delete, a, sa, limit, config):
if limit:
print(f'A limit of {limit} as been passed.')
for file in a:
print(f'\n{file}')
if exec_preprocessing:
try:
print('Executing preprocessing ...')
mod = importlib.import_module(f'preprocessing.{file}.script')
mod.execute(limit, sa)
print('Done preprocessing.')
except ImportError as err:
print('Error:', err)
print()
if exec_transformation:
print('Executing transformation ...')
transformation.execute(file, limit, sa)
print('Done transformation.\n')
if exec_upload or exec_delete:
print('Calling RS graph api...')
upload.execute(file, limit, exec_delete, exec_upload, config, sa)
print('Done.\n')
if __name__ == '__main__':
execute_pipeline()