1
- import os
2
1
import subprocess
3
2
import sys
4
3
import tempfile
@@ -96,6 +95,8 @@ def _deploy(directory, debug, namespace, to_all_users):
96
95
logging_process .start ()
97
96
processes .append (logging_process )
98
97
98
+ run_plugins (directory , HookValue .PRE_NETWORK )
99
+
99
100
network_process = Process (target = deploy_network , args = (directory , debug , namespace ))
100
101
network_process .start ()
101
102
@@ -110,6 +111,8 @@ def _deploy(directory, debug, namespace, to_all_users):
110
111
# Wait for the network process to complete
111
112
network_process .join ()
112
113
114
+ run_plugins (directory , HookValue .POST_NETWORK )
115
+
113
116
# Start the fork observer process immediately after network process completes
114
117
fork_observer_process = Process (target = deploy_fork_observer , args = (directory , debug ))
115
118
fork_observer_process .start ()
@@ -130,11 +133,7 @@ def _deploy(directory, debug, namespace, to_all_users):
130
133
131
134
132
135
def 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"""
138
137
139
138
network_file_path = directory / NETWORK_FILE
140
139
@@ -143,6 +142,8 @@ def is_relative(path: str) -> bool:
143
142
if not isinstance (network_file , dict ):
144
143
raise ValueError (f"Invalid network file structure: { network_file_path } " )
145
144
145
+ processes = []
146
+
146
147
plugins_section = network_file .get ("plugins" , {})
147
148
hook_section = plugins_section .get (hook_value .value , {})
148
149
for plugin_cmd in hook_section .items ():
@@ -152,16 +153,23 @@ def is_relative(path: str) -> bool:
152
153
entrypoint_path = Path (plugin_cmd [1 ].get ("entrypoint" ))
153
154
except Exception as err :
154
155
raise SyntaxError ("Each plugin must have an 'entrypoint'" ) from err
156
+
155
157
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 )
158
160
159
161
case _:
160
162
print (
161
163
f"The following plugin command does not match known plugin command structures: { plugin_cmd } "
162
164
)
163
165
sys .exit (1 )
164
166
167
+ for process in processes :
168
+ process .start ()
169
+
170
+ for process in processes :
171
+ process .join ()
172
+
165
173
166
174
def check_logging_required (directory : Path ):
167
175
# check if node-defaults has logging or metrics enabled
0 commit comments