3
3
import os
4
4
5
5
import config
6
- from shell_ast import ast_to_ast
6
+ from shell_ast import transformation_options , ast_to_ast
7
7
from ir import FileIdGen
8
8
from parse import parse_shell_to_asts , from_ast_objects_to_shell
9
9
from util import *
@@ -30,20 +30,21 @@ def preprocess(input_script_path, args):
30
30
## 3. Translate the new AST back to shell syntax
31
31
preprocessing_unparsing_start_time = datetime .now ()
32
32
preprocessed_shell_script = from_ast_objects_to_shell (preprocessed_asts )
33
-
33
+
34
34
preprocessing_unparsing_end_time = datetime .now ()
35
35
print_time_delta ("Preprocessing -- Unparsing" , preprocessing_unparsing_start_time , preprocessing_unparsing_end_time )
36
36
return preprocessed_shell_script
37
37
38
38
39
39
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 )
44
43
util_spec .initialize (trans_options )
44
+ elif trans_mode is transformation_options .TransformationType .AIRFLOW :
45
+ trans_options = transformation_options .AirflowTransformationState ()
45
46
else :
46
- trans_options = ast_to_ast .TransformationState (mode = trans_mode )
47
+ trans_options = transformation_options .TransformationState ()
47
48
48
49
## Preprocess ASTs by replacing AST regions with calls to PaSh's runtime.
49
50
## Then the runtime will do the compilation and optimization with additional
@@ -52,7 +53,7 @@ def preprocess_asts(ast_objects, args):
52
53
53
54
## Let the scheduler know that we are done with the partial_order file
54
55
## 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 :
56
57
## First complete the partial_order file
57
58
util_spec .serialize_partial_order (trans_options )
58
59
@@ -85,7 +86,7 @@ def main():
85
86
## TODO: When we better integrate, this should be automatically set.
86
87
parser_spec .add_argument ("partial_order_file" , help = "the file to store the partial order (currently just a sequence)" )
87
88
parser_spec .set_defaults (preprocess_mode = 'spec' )
88
-
89
+
89
90
args = parser .parse_args ()
90
91
config .set_config_globals_from_pash_args (args )
91
92
0 commit comments