Skip to content

Commit 5fd6cdb

Browse files
authored
Merge pull request #694 from binpash/future-airflow
[Renewed] Refactor preprocessor architecture to enhance extensibility
2 parents 29ccd26 + 4436c96 commit 5fd6cdb

File tree

5 files changed

+773
-597
lines changed

5 files changed

+773
-597
lines changed

compiler/preprocessor/preprocessor.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44

55
import config
6-
from shell_ast import ast_to_ast
6+
from shell_ast import transformation_options, ast_to_ast
77
from ir import FileIdGen
88
from parse import parse_shell_to_asts, from_ast_objects_to_shell
99
from util import *
@@ -30,20 +30,21 @@ def preprocess(input_script_path, args):
3030
## 3. Translate the new AST back to shell syntax
3131
preprocessing_unparsing_start_time = datetime.now()
3232
preprocessed_shell_script = from_ast_objects_to_shell(preprocessed_asts)
33-
33+
3434
preprocessing_unparsing_end_time = datetime.now()
3535
print_time_delta("Preprocessing -- Unparsing", preprocessing_unparsing_start_time, preprocessing_unparsing_end_time)
3636
return preprocessed_shell_script
3737

3838

3939
def preprocess_asts(ast_objects, args):
40-
trans_mode = ast_to_ast.TransformationType(args.preprocess_mode)
41-
if trans_mode is ast_to_ast.TransformationType.SPECULATIVE:
42-
trans_options = ast_to_ast.SpeculativeTransformationState(mode=trans_mode,
43-
po_file=args.partial_order_file)
40+
trans_mode = transformation_options.TransformationType(args.preprocess_mode)
41+
if trans_mode is transformation_options.TransformationType.SPECULATIVE:
42+
trans_options = transformation_options.SpeculativeTransformationState(po_file=args.partial_order_file)
4443
util_spec.initialize(trans_options)
44+
elif trans_mode is transformation_options.TransformationType.AIRFLOW:
45+
trans_options = transformation_options.AirflowTransformationState()
4546
else:
46-
trans_options = ast_to_ast.TransformationState(mode=trans_mode)
47+
trans_options = transformation_options.TransformationState()
4748

4849
## Preprocess ASTs by replacing AST regions with calls to PaSh's runtime.
4950
## Then the runtime will do the compilation and optimization with additional
@@ -52,7 +53,7 @@ def preprocess_asts(ast_objects, args):
5253

5354
## Let the scheduler know that we are done with the partial_order file
5455
## TODO: We could stream the partial_order_file to the scheduler
55-
if trans_mode is ast_to_ast.TransformationType.SPECULATIVE:
56+
if trans_mode is transformation_options.TransformationType.SPECULATIVE:
5657
## First complete the partial_order file
5758
util_spec.serialize_partial_order(trans_options)
5859

@@ -85,7 +86,7 @@ def main():
8586
## TODO: When we better integrate, this should be automatically set.
8687
parser_spec.add_argument("partial_order_file", help="the file to store the partial order (currently just a sequence)")
8788
parser_spec.set_defaults(preprocess_mode='spec')
88-
89+
8990
args = parser.parse_args()
9091
config.set_config_globals_from_pash_args(args)
9192

0 commit comments

Comments
 (0)