88import pyemu
99
1010bin_path = os .path .join ("test_bin" )
11+ plat = "unknown"
1112if "linux" in platform .platform ().lower ():
1213 bin_path = os .path .join (bin_path ,"linux" )
14+ plat = "linux"
1315elif "darwin" in platform .platform ().lower () or "macos" in platform .platform ().lower () :
1416 bin_path = os .path .join (bin_path ,"mac" )
17+ plat = "apple"
1518else :
1619 bin_path = os .path .join (bin_path ,"win" )
20+ plat = "windows"
1721
1822bin_path = os .path .abspath ("test_bin" )
1923os .environ ["PATH" ] += os .pathsep + bin_path
4347num_reals = 20
4448port = 4021
4549
50+
51+ def nonascii_path_test (model_d = "ies_10par_xsec" ):
52+ pyemu .Ensemble .reseed ()
53+ base_d = os .path .join (model_d , "template" )
54+ new_d = os .path .join (model_d , "test_template_\u0187 " )
55+ if os .path .exists (new_d ):
56+ shutil .rmtree (new_d )
57+ shutil .copytree (base_d , new_d )
58+ print (platform .platform ().lower ())
59+ pst = pyemu .Pst (os .path .join (new_d , "pest.pst" ))
60+ cmd = pst .model_command [0 ].split ()
61+ print (cmd )
62+ cmd = "\" \" {0}\" \" {1}\" \" " .format (cmd [0 ],cmd [1 ])
63+ print (cmd )
64+ pst .model_command .append (cmd )
65+ cmd = pst .model_command [0 ].split ()
66+ cmd = "\" \' {0}\' \' {1}\' \" " .format (cmd [0 ],cmd [1 ])
67+ pst .model_command .append (cmd )
68+
69+ tpl_data = pst .model_input_data
70+ tpl_data ["pest_file" ] = tpl_data .pest_file .apply (lambda x : "\" {0}\" " .format (x ))
71+ tpl_data ["model_file" ] = tpl_data .model_file .apply (lambda x : "\" {0}\" " .format (x ))
72+
73+ ins_data = pst .model_output_data
74+ ins_data ["pest_file" ] = ins_data .pest_file .apply (lambda x : "\" {0}\" " .format (x ))
75+ ins_data ["model_file" ] = ins_data .model_file .apply (lambda x : "\" {0}\" " .format (x ))
76+
77+ pst .control_data .noptmax = 1
78+ pst .observation_data .loc [pst .nnz_obs_names ,"weight" ] = 1.0
79+ #pst.pestpp_options["panther_agent_freeze_on_fail"] = True
80+ pst .pestpp_options ["ies_num_reals" ] = 5
81+ pst .write (os .path .join (new_d , "pest.pst" ))
82+
83+
84+ m_d = os .path .join (model_d ,"master_pestpp" )
85+ if os .path .exists (m_d ):
86+ shutil .rmtree (m_d )
87+ shutil .copytree (new_d ,m_d )
88+
89+ worker_root = os .path .join (model_d + "_\u0187 " )
90+ if os .path .exists (worker_root ):
91+ shutil .rmtree (worker_root )
92+ os .makedirs (worker_root )
93+ try :
94+ pyemu .os_utils .start_workers (new_d , exe_path , "pest.pst" , 1 , master_dir = m_d ,
95+ worker_root = worker_root ,port = port ,verbose = True )
96+ except Exception as e :
97+ if plat != "windows" :
98+ raise Exception (e )
99+ else :
100+ if plat == "windows" :
101+ raise Exception ("should have failed" )
102+
103+
46104def basic_test (model_d = "ies_10par_xsec" ):
47105 pyemu .Ensemble .reseed ()
48106 base_d = os .path .join (model_d , "template" )
@@ -57,7 +115,38 @@ def basic_test(model_d="ies_10par_xsec"):
57115 cmd = "\" \" {0}\" \" {1}\" \" " .format (cmd [0 ],cmd [1 ])
58116 print (cmd )
59117 pst .model_command .append (cmd )
118+ cmd = pst .model_command [0 ].split ()
119+ cmd = "\" \' {0}\' \' {1}\' \" " .format (cmd [0 ],cmd [1 ])
120+ pst .model_command .append (cmd )
121+
122+ tpl_data = pst .model_input_data
123+ tpl_data ["pest_file" ] = tpl_data .pest_file .apply (lambda x : "\" {0}\" " .format (x ))
124+ tpl_data ["model_file" ] = tpl_data .model_file .apply (lambda x : "\" {0}\" " .format (x ))
60125
126+ ins_data = pst .model_output_data
127+ ins_data ["pest_file" ] = ins_data .pest_file .apply (lambda x : "\" {0}\" " .format (x ))
128+ ins_data ["model_file" ] = ins_data .model_file .apply (lambda x : "\" {0}\" " .format (x ))
129+
130+ pst .control_data .noptmax = 0
131+ pst .write (os .path .join (new_d , "pest.pst" ))
132+ pyemu .os_utils .run ("{0} pest.pst" .format (exe_path ),cwd = new_d )
133+ # pst.write(os.path.join(new_d, "pest.pst"),version=2)
134+ # pyemu.os_utils.run("{0} pest.pst".format(exe_path),cwd=new_d)
135+
136+ tpl_data = pst .model_input_data
137+ tpl_data ["pest_file" ] = tpl_data .pest_file .apply (lambda x : "\' {0}\' " .format (x ))
138+ tpl_data ["model_file" ] = tpl_data .model_file .apply (lambda x : "\' {0}\' " .format (x ))
139+
140+ ins_data = pst .model_output_data
141+ ins_data ["pest_file" ] = ins_data .pest_file .apply (lambda x : "\' {0}\' " .format (x ))
142+ ins_data ["model_file" ] = ins_data .model_file .apply (lambda x : "\' {0}\' " .format (x ))
143+
144+ pst .control_data .noptmax = 0
145+ pst .write (os .path .join (new_d , "pest.pst" ))
146+ pyemu .os_utils .run ("{0} pest.pst" .format (exe_path ),cwd = new_d )
147+ # pst.write(os.path.join(new_d, "pest.pst"),version=2)
148+ # pyemu.os_utils.run("{0} pest.pst".format(exe_path),cwd=new_d)
149+
61150 # set first par as fixed
62151 #pst.parameter_data.loc[pst.par_names[0], "partrans"] = "fixed"
63152
@@ -2030,11 +2119,15 @@ def mf6_v5_ies_nonpersistent_test():
20302119 assert found == num_workers
20312120
20322121
2033-
2122+ def parse_pst_test ():
2123+ t_d = os .path .join ("parse_pst_testfiles" ,"kerry" )
2124+ pyemu .os_utils .run ("{0} control.pst" .format (exe_path ),cwd = t_d )
20342125
20352126
20362127if __name__ == "__main__" :
2037- basic_test ()
2128+ #parse_pst_test()
2129+ #basic_test()
2130+ nonascii_path_test ()
20382131
20392132 #mf6_v5_ies_nonpersistent_test()
20402133 #large_fake_test()
@@ -2049,7 +2142,7 @@ def mf6_v5_ies_nonpersistent_test():
20492142 #plot_collapse_invest()
20502143
20512144 #run()
2052- # mf6_v5_ies_test()
2145+ #mf6_v5_ies_test()
20532146 #prep_ends()
20542147 #sweep_bin_test()
20552148 # mf6_v5_sen_test()
@@ -2096,7 +2189,7 @@ def mf6_v5_ies_nonpersistent_test():
20962189 #mf6_v5_sen_test()
20972190
20982191 #shutil.copy2(os.path.join("..","exe","windows","x64","Debug","pestpp-opt.exe"),os.path.join("..","bin","win","pestpp-opt.exe"))
2099- mf6_v5_opt_stack_test ()
2192+ # mf6_v5_opt_stack_test()
21002193 # mf6_v5_glm_test()
21012194 # mf6_v5_ies_test()
21022195 #cmdline_test()
0 commit comments