44
55"""Plan module."""
66
7- import os
87import sys
98from logging import getLogger
109from os import makedirs
1110from os .path import isfile
1211from pathlib import Path
1312from shutil import copyfile , rmtree
14- from subprocess import check_call # nosec
1513
1614from click import Path as ClickPath
1715from click import echo , group , option , pass_context
@@ -92,14 +90,6 @@ def plan(context):
9290 required = False ,
9391 help = "GaNDLF Configuration File Path" ,
9492)
95- @option (
96- "-r" ,
97- "--install_reqs" ,
98- required = False ,
99- help = "If set, installs packages listed under 'requirements.txt'." ,
100- default = True ,
101- show_default = True ,
102- )
10393@option (
10494 "-i" ,
10595 "--init_model_path" ,
@@ -115,7 +105,6 @@ def initialize(
115105 aggregator_address ,
116106 input_shape ,
117107 gandlf_config ,
118- install_reqs ,
119108 init_model_path ,
120109):
121110 """
@@ -134,10 +123,6 @@ def initialize(
134123 if gandlf_config is not None :
135124 gandlf_config = Path (gandlf_config ).absolute ()
136125
137- if install_reqs :
138- requirements_path = Path ("requirements.txt" ).absolute ()
139- _handle_requirements_install (requirements_path )
140-
141126 plan = Plan .parse (
142127 plan_config_path = plan_config ,
143128 cols_config_path = cols_config ,
@@ -205,37 +190,6 @@ def initialize(
205190 logger .info (f"{ context .obj ['plans' ]} " )
206191
207192
208- def _handle_requirements_install (requirements_path ):
209- """Handle the installation of requirements and process restart if needed.
210-
211- This method checks if a requirements.txt file exists at the provided path.
212- If found, it installs the packages listed in the file using pip. After
213- successful installation, it restarts the current process with the same
214- arguments, but with the --install_reqs flag set to False to avoid
215- re-installing requirements.
216-
217- If no requirements.txt file is found, it prints a message indicating that
218- no additional requirements are defined for the workspace and skips the
219- installation.
220-
221- Args:
222- requirements_path (str or Path): The path to the requirements.txt file.
223- """
224- if isfile (str (requirements_path )):
225- check_call (
226- [sys .executable , "-m" , "pip" , "install" , "-r" , str (requirements_path )],
227- shell = False ,
228- )
229- echo (f"Successfully installed packages from { requirements_path } ." )
230-
231- # Required to restart the process for newly installed packages to be recognized
232- args_restart = [arg for arg in sys .argv if not arg .startswith ("--install_reqs" )]
233- args_restart .append ("--install_reqs=False" )
234- os .execv (args_restart [0 ], args_restart )
235- else :
236- echo ("No additional requirements for workspace defined. Skipping..." )
237-
238-
239193def _initialize_tensor_dict (plan , input_shape , init_model_path ):
240194 """Initialize and return the tensor dictionary.
241195
0 commit comments