@@ -85,17 +85,31 @@ def project_cmd():
8585 """
8686
8787
88+ @click .group (name = "experimental" )
89+ def experimental_cmd ():
90+ """
91+ Sub-entrypoint for WIP/Experimental commands
92+ """
93+
94+
8895@project_cmd .command (name = "export" )
8996@click .option (
9097 "--project_name" ,
9198 "-p" ,
9299 help = "Name of the project to be migrated. Make sure the name matches with the section name in export-config.ini file" ,
93100 required = True ,
94101)
95- def project_export_cmd (project_name ):
102+ @click .option (
103+ "--ini_location" ,
104+ "-l" ,
105+ default = "/.cmlutils/export-config.ini" ,
106+ show_default = True ,
107+ help = "filepath of the export-config.ini file. default is <home-dir>/.cmlutils/export-config.ini" ,
108+ )
109+ def project_export_cmd (project_name , ini_location ):
96110 pexport = None
97111 config = _read_config_file (
98- os .path .expanduser ("~" ) + "/.cmlutils/export-config.ini" , project_name
112+ os .path .expanduser ("~" ) + ini_location , project_name
99113 )
100114
101115 username = config [USERNAME_KEY ]
@@ -207,17 +221,24 @@ def project_export_cmd(project_name):
207221 help = "Name of the project to be migrated. Make sure the name matches with the section name in import-config.ini file" ,
208222 required = True ,
209223)
224+ @click .option (
225+ "--ini_location" ,
226+ "-l" ,
227+ default = "/.cmlutils/import-config.ini" ,
228+ show_default = True ,
229+ help = "filepath of the import-config.ini file. default is <home-dir>/.cmlutils/import-config.ini" ,
230+ )
210231@click .option (
211232 "--verify" ,
212233 "-v" ,
213- is_flag = True ,
234+ is_flag = False ,
214235 help = "Flag to automatically trigger migration validation after import." ,
215236)
216- def project_import_cmd (project_name , verify ):
237+ def project_import_cmd (project_name , ini_location , verify = False ):
217238 pimport = None
218239 import_diff_file_list = None
219240 config = _read_config_file (
220- os .path .expanduser ("~" ) + "/.cmlutils/import-config.ini" , project_name
241+ os .path .expanduser ("~" ) + ini_location , project_name
221242 )
222243
223244 username = config [USERNAME_KEY ]
@@ -299,11 +320,10 @@ def project_import_cmd(project_name, verify):
299320 )
300321 start_time = time .time ()
301322 if verify :
302- import_diff_file_list = pimport .transfer_project (log_filedir = log_filedir , verify = True )
323+ import_diff_file_list = pimport .transfer_project (log_filedir = log_filedir , verify = True )
303324 else :
304325 pimport .transfer_project (log_filedir = log_filedir )
305326
306-
307327 if uses_engine :
308328 proj_patch_metadata = {"default_project_engine_type" : "legacy_engine" }
309329 pimport .convert_project_to_engine_based (
@@ -340,7 +360,9 @@ def project_import_cmd(project_name, verify):
340360 pimport .terminate_ssh_session ()
341361 # If verification is also needed after import
342362 if verify :
343- print ("***************************************************** Started verifying migration for project: {} ***************************************************** " .format (project_name ))
363+ print (
364+ "***************************************************** Started verifying migration for project: {} ***************************************************** " .format (
365+ project_name ))
344366 (
345367 imported_project_data ,
346368 imported_project_list ,
@@ -578,8 +600,9 @@ def project_import_cmd(project_name, verify):
578600 True if (job_diff or job_config_diff ) else False ,
579601 message = "Job Verification" ,
580602 )
581- result = [export_diff_file_list ,import_diff_file_list ,proj_diff ,
582- proj_config_diff ,app_diff ,app_config_diff ,model_diff ,model_config_diff ,job_diff , job_config_diff ]
603+ result = [export_diff_file_list , import_diff_file_list , proj_diff ,
604+ proj_config_diff , app_diff , app_config_diff , model_diff , model_config_diff , job_diff ,
605+ job_config_diff ]
583606 migration_status = all (not sublist for sublist in result )
584607 validation_data ["isMigrationSuccessful" ] = migration_status
585608 update_verification_status (
@@ -612,13 +635,29 @@ def project_import_cmd(project_name, verify):
612635 help = "Name of project migrated. Make sure the name matches with the section name in import-config.ini and export-config.ini file" ,
613636 required = True ,
614637)
615- def project_verify_cmd (project_name ):
638+ @click .option (
639+ "--export_ini_location" ,
640+ "-el" ,
641+ default = "/.cmlutils/export-config.ini" ,
642+ show_default = True ,
643+ help = "filepath of the export-config.ini file. default is <home-dir>/.cmlutils/export-config.ini" ,
644+ )
645+ @click .option (
646+ "--import_ini_location" ,
647+ "-il" ,
648+ default = "/.cmlutils/import-config.ini" ,
649+ show_default = True ,
650+ help = "filepath of the import-config.ini file. default is <home-dir>/.cmlutils/import-config.ini" ,
651+ )
652+ def project_verify_cmd (project_name , export_ini_location , import_ini_location ):
653+
616654 pexport = None
617655 validation_data = dict ()
618656 config = _read_config_file (
619- os .path .expanduser ("~" ) + "/.cmlutils/export-config.ini" , project_name
657+ os .path .expanduser ("~" ) + export_ini_location , project_name
620658 )
621659
660+
622661 export_username = config [USERNAME_KEY ]
623662 export_url = config [URL_KEY ]
624663 export_apiv1_key = config [API_V1_KEY ]
@@ -709,7 +748,7 @@ def project_verify_cmd(project_name):
709748 pexport .terminate_ssh_session ()
710749 pimport = None
711750 import_config = _read_config_file (
712- os .path .expanduser ("~" ) + "/.cmlutils/import-config.ini" , project_name
751+ os .path .expanduser ("~" ) + import_ini_location , project_name
713752 )
714753
715754 import_username = import_config [USERNAME_KEY ]
@@ -742,8 +781,8 @@ def project_verify_cmd(project_name):
742781 for v in validators :
743782 validation_response = v .validate ()
744783 if (
745- validation_response .validation_status
746- == ValidationResponseStatus .FAILED
784+ validation_response .validation_status
785+ == ValidationResponseStatus .FAILED
747786 ):
748787 logging .error (
749788 "Validation error for project %s: %s" ,
@@ -924,8 +963,9 @@ def project_verify_cmd(project_name):
924963 True if (job_diff or job_config_diff ) else False ,
925964 message = "Job Verification" ,
926965 )
927- result = [export_diff_file_list ,import_diff_file_list ,proj_diff ,
928- proj_config_diff ,app_diff ,app_config_diff ,model_diff ,model_config_diff ,job_diff , job_config_diff ]
966+ result = [export_diff_file_list , import_diff_file_list , proj_diff ,
967+ proj_config_diff , app_diff , app_config_diff , model_diff , model_config_diff , job_diff ,
968+ job_config_diff ]
929969 migration_status = all (not sublist for sublist in result )
930970 update_verification_status (
931971 not migration_status ,
@@ -961,11 +1001,18 @@ def project_helpers_cmd():
9611001 """
9621002
9631003
1004+ @click .option (
1005+ "--ini_location" ,
1006+ "-l" ,
1007+ default = "/.cmlutils/import-config.ini" ,
1008+ show_default = True ,
1009+ help = "filepath of the import-config.ini file. default is <home-dir>/.cmlutils/import-config.ini" ,
1010+ )
9641011@project_helpers_cmd .command ("populate_engine_runtimes_mapping" )
965- def populate_engine_runtimes_mapping ():
1012+ def populate_engine_runtimes_mapping (ini_location ):
9661013 project_name = "DEFAULT"
9671014 config = _read_config_file (
968- os .path .expanduser ("~" ) + "/.cmlutils/import-config.ini" , project_name
1015+ os .path .expanduser ("~" ) + ini_location , project_name
9691016 )
9701017
9711018 username = config [USERNAME_KEY ]
@@ -1020,10 +1067,10 @@ def populate_engine_runtimes_mapping():
10201067 # Please make sure utility is having necessary permissions to write/overwrite data
10211068 try :
10221069 with open (
1023- os .path .expanduser ("~" )
1024- + "/.cmlutils/"
1025- + "legacy_engine_runtime_constants.json" ,
1026- "w" ,
1070+ os .path .expanduser ("~" )
1071+ + "/.cmlutils/"
1072+ + "legacy_engine_runtime_constants.json" ,
1073+ "w" ,
10271074 ) as legacy_engine_runtime_constants :
10281075 dump (legacy_runtime_image_map , legacy_engine_runtime_constants )
10291076 except :
0 commit comments