@@ -26,20 +26,29 @@ def wait_for_export(eas_client: EasClient, model_id: int):
2626 print (f"Waiting for model generation ({ wait_limit_seconds } seconds) " , end = '' )
2727 # Retrieve the model information for the model we just requested
2828 model = eas_client .get_opendss_model (model_id )
29- while model ["state" ] != "COMPLETED" :
30- model = eas_client .get_opendss_model (model_id )
31- print ("." , end = '' )
32- sleep (step_seconds )
33- total += step_seconds
34- if total > wait_limit_seconds :
35- raise TimeoutError ("Timed out waiting for model export to complete." )
29+ while model ["state" ] == "CREATION" :
30+ try :
31+ model = eas_client .get_opendss_model (model_id )
32+ print ("." , end = '' )
33+ sleep (step_seconds )
34+ total += step_seconds
35+ if total > wait_limit_seconds :
36+ raise TimeoutError ("Timed out waiting for model export to complete." )
37+ except Exception as e :
38+ if isinstance (e , TimeoutError ):
39+ raise e
40+ else :
41+ print (f"Failed retrieving model export status: { e } " )
42+ print (f"Retrying in { step_seconds } secondds..." )
43+ sleep (step_seconds )
3644
3745
3846def download_generated_model (eas_client : EasClient , output_file_name : str , model_id : int ):
39- url = eas_client .get_opendss_model_download_url (model_id )
40- if url == f'Model with id { model_id } is still being created' :
41- print (url )
42- print ("Download failed." )
47+ try :
48+ url = eas_client .get_opendss_model_download_url (model_id )
49+ except Exception as e :
50+ print ()
51+ print (f"Download failed, model failed to generate: { e } " )
4352 return
4453
4554 print (f"\n URL (30 second expiry): { url } " , )
@@ -52,11 +61,11 @@ def download_generated_model(eas_client: EasClient, output_file_name: str, model
5261 file .write (requests .get (url ).content )
5362 print ("Download complete." )
5463 except Exception as error :
55- print ("Download failed." )
5664 print (error )
65+ print ("Download failed. Model may have failed to generate." )
5766
5867
59- def test_open_dss_export (export_file_name : str ):
68+ def open_dss_export (export_file_name : str ):
6069 eas_client = EasClient (
6170 host = c ["host" ],
6271 port = c ["rpc_port" ],
@@ -93,8 +102,8 @@ def test_open_dss_export(export_file_name: str):
93102 name_pattern = "LV Circuit Head.*"
94103 )]
95104 ),
96- vmax_pu = 1.2 ,
97- vmin_pu = 0.8 ,
105+ load_vmax_pu = 1.2 ,
106+ load_vmin_pu = 0.8 ,
98107 p_factor_base_exports = - 1 ,
99108 p_factor_base_imports = 1 ,
100109 p_factor_forecast_pv = 0.98 ,
@@ -135,4 +144,4 @@ def test_open_dss_export(export_file_name: str):
135144
136145
137146if __name__ == "__main__" :
138- test_open_dss_export ( "test_export-model " )
147+ open_dss_export ( f"test_export_model_ { datetime . now () } " )
0 commit comments