1010import pythia .util
1111
1212
13- def build_context (args ):
14- run , ctx , config = args
13+ def build_context (run , ctx , config , plugins ):
1514 if not config ["silence" ]:
1615 print ("+" , end = "" , flush = True )
1716 context = run .copy ()
@@ -28,13 +27,25 @@ def build_context(args):
2827 else :
2928 context = None
3029 break
30+
31+ hook = pythia .plugin .PluginHook .post_peerless_pixel_success
32+ if context is None :
33+ hook = pythia .plugin .PluginHook .post_peerless_pixel_skip
34+
35+ context = pythia .plugin .run_plugin_functions (
36+ hook ,
37+ plugins ,
38+ context = context ,
39+ args = {"run" : run , "config" : config , "ctx" : ctx },
40+ ).get ("context" , context )
41+
3142 return context
3243
3344
34- def _generate_context_args (runs , peers , config ):
45+ def _generate_context_args (runs , peers , config , plugins ):
3546 for idx , run in enumerate (runs ):
3647 for peer in peers [idx ]:
37- yield run , peer , config
48+ yield run , peer , config , plugins
3849
3950
4051def symlink_wth_soil (output_dir , config , context ):
@@ -69,6 +80,7 @@ def compose_peerless(context, config, env):
6980 f .write (xfile )
7081 return context ["contextWorkDir" ]
7182
83+
7284def process_context (context , plugins , config , env ):
7385 if context is not None :
7486 pythia .io .make_run_directory (context ["contextWorkDir" ])
@@ -78,9 +90,25 @@ def process_context(context, plugins, config, env):
7890 pythia .plugin .PluginHook .post_build_context ,
7991 plugins ,
8092 context = context ,
81- )
82- return os .path .abspath (compose_peerless (context , config , env ))
93+ ).get ("context" , context )
94+ compose_peerless_result = compose_peerless (context , config , env )
95+ compose_peerless_result = pythia .plugin .run_plugin_functions (
96+ pythia .plugin .PluginHook .post_compose_peerless_pixel_success ,
97+ plugins ,
98+ context = context ,
99+ compose_peerless_result = compose_peerless_result ,
100+ config = config ,
101+ env = env ,
102+ ).get ("compose_peerless_result" , compose_peerless_result )
103+ return os .path .abspath (compose_peerless_result )
83104 else :
105+ pythia .plugin .run_plugin_functions (
106+ pythia .plugin .PluginHook .post_compose_peerless_pixel_skip ,
107+ plugins ,
108+ context = context ,
109+ config = config ,
110+ env = env ,
111+ )
84112 if not config ["silence" ]:
85113 print ("X" , end = "" , flush = True )
86114
@@ -102,8 +130,8 @@ def execute(config, plugins):
102130 # Parallelize the context build (build_context), it is CPU intensive because it
103131 # runs the functions (functions.py) declared in the config files.
104132 with concurrent .futures .ProcessPoolExecutor (max_workers = pool_size ) as executor :
105- tasks = _generate_context_args (runs , peers , config )
106- future_to_context = {executor .submit (build_context , task ): task for task in tasks }
133+ tasks = _generate_context_args (runs , peers , config , plugins )
134+ future_to_context = {executor .submit (build_context , * task ): task for task in tasks }
107135
108136 # process_context is mostly I/O intensive, no reason to parallelize it.
109137 for future in concurrent .futures .as_completed (future_to_context ):
@@ -116,5 +144,11 @@ def execute(config, plugins):
116144 if config ["exportRunlist" ]:
117145 with open (os .path .join (config ["workDir" ], "run_list.txt" ), "w" ) as f :
118146 [f .write (f"{ x } \n " ) for x in runlist ]
119- if not config ["silence" ]:
120- print ()
147+
148+ pythia .plugin .run_plugin_functions (
149+ pythia .plugin .PluginHook .post_compose_peerless_all ,
150+ plugins ,
151+ run_list = runlist ,
152+ config = config ,
153+ env = env ,
154+ )
0 commit comments