1- import os
21import subprocess
32import sys
43import tempfile
@@ -96,6 +95,8 @@ def _deploy(directory, debug, namespace, to_all_users):
9695 logging_process .start ()
9796 processes .append (logging_process )
9897
98+ run_plugins (directory , HookValue .PRE_NETWORK )
99+
99100 network_process = Process (target = deploy_network , args = (directory , debug , namespace ))
100101 network_process .start ()
101102
@@ -110,6 +111,8 @@ def _deploy(directory, debug, namespace, to_all_users):
110111 # Wait for the network process to complete
111112 network_process .join ()
112113
114+ run_plugins (directory , HookValue .POST_NETWORK )
115+
113116 # Start the fork observer process immediately after network process completes
114117 fork_observer_process = Process (target = deploy_fork_observer , args = (directory , debug ))
115118 fork_observer_process .start ()
@@ -130,11 +133,7 @@ def _deploy(directory, debug, namespace, to_all_users):
130133
131134
132135def run_plugins (directory , hook_value : HookValue ):
133- """ " Run the plugin commands within a given hook value"""
134-
135- def is_relative (path : str ) -> bool :
136- """Determine if the path is a command or a path to a command"""
137- return os .path .dirname (path ) != ""
136+ """Run the plugin commands within a given hook value"""
138137
139138 network_file_path = directory / NETWORK_FILE
140139
@@ -143,6 +142,8 @@ def is_relative(path: str) -> bool:
143142 if not isinstance (network_file , dict ):
144143 raise ValueError (f"Invalid network file structure: { network_file_path } " )
145144
145+ processes = []
146+
146147 plugins_section = network_file .get ("plugins" , {})
147148 hook_section = plugins_section .get (hook_value .value , {})
148149 for plugin_cmd in hook_section .items ():
@@ -152,16 +153,23 @@ def is_relative(path: str) -> bool:
152153 entrypoint_path = Path (plugin_cmd [1 ].get ("entrypoint" ))
153154 except Exception as err :
154155 raise SyntaxError ("Each plugin must have an 'entrypoint'" ) from err
156+
155157 cmd = f"{ network_file_path .parent / entrypoint_path / Path ('plugin.py' )} entrypoint { network_file_path } { hook_value .value } "
156- print ( f"Command: { cmd } " )
157- print ( run_command ( cmd ) )
158+ process = Process ( target = run_command , args = ( cmd ,) )
159+ processes . append ( process )
158160
159161 case _:
160162 print (
161163 f"The following plugin command does not match known plugin command structures: { plugin_cmd } "
162164 )
163165 sys .exit (1 )
164166
167+ for process in processes :
168+ process .start ()
169+
170+ for process in processes :
171+ process .join ()
172+
165173
166174def check_logging_required (directory : Path ):
167175 # check if node-defaults has logging or metrics enabled
0 commit comments