@@ -91,14 +91,21 @@ def get_parser():
9191 type = Path ,
9292 default = None ,
9393 help = "directory where the analysis output is stored "
94- "[default: '~/cobrawap_output/']" ,
94+ "[default: '~/cobrawap_output/']" ,
9595)
9696CLI_init .add_argument (
9797 "--config_path" ,
9898 type = Path ,
9999 default = None ,
100100 help = "directory where the analysis config files are "
101- "stored [default: '~/cobrawap_config/']" ,
101+ "stored [default: '~/cobrawap_config/']" ,
102+ )
103+ CLI_init .add_argument (
104+ "-F" ,
105+ "--force_overwrite" ,
106+ action = "store_true" ,
107+ help = "force the initialization, overwriting previous settings"
108+ "when already present" ,
102109)
103110
104111# Show Settings
@@ -128,23 +135,23 @@ def get_parser():
128135 type = Path ,
129136 default = None ,
130137 help = "name of the data specific loading script "
131- "(in <config_path>/stage01_data_entry/scripts/)" ,
138+ "(in <config_path>/stage01_data_entry/scripts/)" ,
132139)
133140CLI_create .add_argument (
134141 "--profile" ,
135142 type = str ,
136143 nargs = "?" ,
137144 default = None ,
138145 help = "profile name of this dataset/application "
139- "(see profile name conventions in documentation)" ,
146+ "(see profile name conventions in documentation)" ,
140147)
141148CLI_create .add_argument (
142149 "--parent_profile" ,
143150 type = str ,
144151 nargs = "?" ,
145152 default = None ,
146153 help = "optional parent profile name "
147- "(see profile name conventions in documentation)" ,
154+ "(see profile name conventions in documentation)" ,
148155)
149156
150157# Additional configurations
@@ -159,7 +166,7 @@ def get_parser():
159166 nargs = "?" ,
160167 default = None ,
161168 help = "profile name of this dataset/application "
162- "(see profile name conventions in documentation)" ,
169+ "(see profile name conventions in documentation)" ,
163170)
164171CLI_profile .add_argument (
165172 "--stages" ,
@@ -175,15 +182,15 @@ def get_parser():
175182 nargs = "?" ,
176183 default = None ,
177184 help = "optional parent profile name from which to "
178- "initialize the new config "
179- "[default: basic template]" ,
185+ "initialize the new config "
186+ "[default: basic template]" ,
180187)
181188
182189# Run
183190CLI_run = subparsers .add_parser (
184191 "run" ,
185192 help = "run the analysis pipeline on the selected "
186- "input and with the specified configurations" ,
193+ "input and with the specified configurations" ,
187194)
188195CLI_run .set_defaults (command = "run" )
189196CLI_run .add_argument (
@@ -292,7 +299,7 @@ def main():
292299 return None
293300
294301
295- def initialize (output_path = None , config_path = None , ** kwargs ):
302+ def initialize (output_path = None , config_path = None , force_overwrite = False , ** kwargs ):
296303 # set output_path
297304 if output_path is None :
298305 output_path = (
@@ -307,7 +314,8 @@ def initialize(output_path=None, config_path=None, **kwargs):
307314 if not output_path .is_dir ():
308315 raise ValueError (f"{ output_path } is not a valid directory!" )
309316
310- set_setting (dict (output_path = str (output_path )))
317+ set_setting (dict (output_path = str (output_path )),
318+ force_overwrite = force_overwrite )
311319
312320 # set config_path
313321 if config_path is None :
@@ -323,18 +331,21 @@ def initialize(output_path=None, config_path=None, **kwargs):
323331 if not config_path .is_dir ():
324332 raise ValueError (f"{ config_path } is not a valid directory!" )
325333
326- set_setting (dict (config_path = str (config_path )))
334+ set_setting (dict (config_path = str (config_path )),
335+ force_overwrite = force_overwrite )
327336
328337 # set pipeline path
329338 pipeline_path = Path (inspect .getfile (lambda : None )).parent / "pipeline"
330- set_setting (dict (pipeline_path = str (pipeline_path .resolve ())))
339+ set_setting (dict (pipeline_path = str (pipeline_path .resolve ())),
340+ force_overwrite = force_overwrite )
331341
332342 # set available stages
333- set_setting (dict (stages = get_initial_available_stages ()))
343+ set_setting (dict (stages = get_initial_available_stages ()),
344+ force_overwrite = force_overwrite )
334345 stages = get_setting ("stages" )
335346
336347 # populate config_path with template config files
337- if any (config_path .iterdir ()):
348+ if any (config_path .iterdir ()) and not force_overwrite :
338349 overwrite = (
339350 input (
340351 f"The config directory { config_path } already exists "
0 commit comments