@@ -20,24 +20,26 @@ def wait_for_export(eas_client: EasClient, model_id: int):
2020 total = 0
2121 print (f"Waiting for model generation ({ wait_limit_seconds } seconds) " , end = '' )
2222 # Retrieve the model information for the model we just requested
23- get_result = eas_client .get_paged_opendss_models ()
24- model = next (x for x in get_result ["data" ]["pagedOpenDssModels" ]["models" ] if x ["id" ] == model_id )
23+ model = eas_client .get_opendss_model (model_id )
2524 while model ["state" ] != "COMPLETED" :
26- get_result = eas_client .get_paged_opendss_models ()
27- model = next (x for x in get_result ["data" ]["pagedOpenDssModels" ]["models" ] if x ["id" ] == model_id )
25+ model = eas_client .get_opendss_model (model_id )
2826 print ("." , end = '' )
2927 sleep (step_seconds )
3028 total += step_seconds
3129 if total > wait_limit_seconds :
3230 raise TimeoutError ("Timed out waiting for model export to complete." )
3331
3432
35- def download_generated_model (eas_client : EasClient , model_id : int ):
33+ def download_generated_model (eas_client : EasClient , output_file_name : str , model_id : int ):
3634 url = eas_client .get_opendss_model_download_url (model_id )
35+ if url == f'Model with id { model_id } is still being created' :
36+ print (url )
37+ print ("Download failed." )
38+ return
3739
3840 print (f"\n URL (30 second expiry): { url } " , )
3941
40- file_name = f"Opendss_export_output_model_ { model_id } .zip"
42+ file_name = f"{ output_file_name } - { model_id } .zip"
4143 print (f"Downloading model zip to: { file_name } " )
4244
4345 try :
@@ -51,23 +53,22 @@ def download_generated_model(eas_client: EasClient, model_id: int):
5153
5254def test_open_dss_export (export_file_name : str ):
5355 eas_client = EasClient (
54- "staging.dev.zb.energy " ,
56+ "<EAS_HOSTNAME> " ,
5557 443 ,
56- verify_certificate = True ,
57- access_token = "eyJraWQiOiI2ZDFiZGMxOS00MDEyLTQ4NzAtYjIzNy1lZTFlY2NkNTBiOTYiLCJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiNjU2ZWRiYWMtYzE0OS00NGFlLWIwODctYzMyYTA4Y2M4N2QwIiwiNmI5OTkzNTItMmIwZi00YTJkLThkMGMtYTI4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zJEUyYb0xv82E023MJlgT7fpPrlzdO4bVTT-RfZBZ8DKRs3jiLQ4oqIVUDzptHln3CIoL0sFec3Mg3DaHWTU3jQ7IHdJ2T3n6CZyr3jNfkOa3yaUApf7WP-hoA-BeJGyKz056WovOy6BdAcnm5a3XwB-ODPlkD6ZtulVvtVy2ClhuK1QM8"
58+ access_token = "<PERSONAL_ACCESS_TOKEN>"
5859 )
5960
6061 # Run an opendss export
6162 print ("Sending OpenDss model export request to EAS" )
6263
6364 response = eas_client .run_opendss_export (
6465 OpenDssConfig (
65- scenario = "1 " ,
66+ scenario = "Base " ,
6667 year = 2024 ,
67- feeder = "WD24 " ,
68+ feeder = "<FEEDER_ID> " ,
6869 load_time = TimePeriod (
69- datetime .strptime ("2022 -04-01T00:00:00" , "%Y-%m-%dT%H:%M:%S" ),
70- datetime .strptime ("2023 -04-01T00:00:00" , "%Y-%m-%dT%H:%M:%S" )
70+ datetime .strptime ("2024 -04-01T00:00:00" , "%Y-%m-%dT%H:%M:%S" ),
71+ datetime .strptime ("2025 -04-01T00:00:00" , "%Y-%m-%dT%H:%M:%S" )
7172 ),
7273 generator_config = GeneratorConfig (
7374 model = ModelConfig (
@@ -112,7 +113,7 @@ def test_open_dss_export(export_file_name: str):
112113 wait_for_export (eas_client , int (model_id ))
113114
114115 # Request a download URL from EAS and download to a local file
115- download_generated_model (eas_client , int (model_id ))
116+ download_generated_model (eas_client , export_file_name , int (model_id ))
116117
117118 except TimeoutError :
118119 print ("\n ERROR: Timed out waiting for model export to complete." )
@@ -121,4 +122,4 @@ def test_open_dss_export(export_file_name: str):
121122
122123
123124if __name__ == "__main__" :
124- test_open_dss_export ("monday_test " )
125+ test_open_dss_export ("test_export-model " )
0 commit comments