Skip to content

Commit 51702b4

Browse files
committed
add get_opendss_model
Signed-off-by: vince <vince.white@zepben.com>
1 parent 72c08dd commit 51702b4

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/zepben/eas/client/eas_client.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,3 +1325,35 @@ async def async_get_opendss_model_download_url(self, run_id: int):
13251325
else:
13261326
response = await response.text()
13271327
return response
1328+
1329+
def get_opendss_model(self, model_id: int):
1330+
"""
1331+
Retrieve information of a hosting capacity calibration run
1332+
:param model_id: The openDss model export ID
1333+
:return: The HTTP response received from the Evolve App Server after requesting the openDss model info
1334+
"""
1335+
return get_event_loop().run_until_complete(self.async_get_opendss_model(model_id))
1336+
1337+
async def async_get_opendss_model(self, model_id: int):
1338+
"""
1339+
Retrieve information of a hosting capacity calibration run
1340+
:param model_id: The openDss model export ID
1341+
:return: The HTTP response received from the Evolve App Server after requesting the openDss model info
1342+
"""
1343+
1344+
offset = 0
1345+
page_size = 2
1346+
1347+
while True:
1348+
response = await self.async_get_paged_opendss_models(page_size, offset)
1349+
total_count = int(response["data"]["pagedOpenDssModels"]["totalCount"])
1350+
page_count = len(response["data"]["pagedOpenDssModels"]["models"])
1351+
for model in response["data"]["pagedOpenDssModels"]["models"]:
1352+
if model["id"] == model_id:
1353+
return model
1354+
offset += page_count
1355+
1356+
if offset >= total_count:
1357+
break
1358+
1359+
raise ValueError(f"Model id:{model_id} was not found in EAS database.")

src/zepben/eas/client/work_package.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def __init__(
172172
def _validate(start_time: datetime, end_time: datetime):
173173
ddelta = (end_time - start_time).days
174174

175-
if ddelta > 365:
175+
if ddelta > 367:
176176
raise ValueError("The difference between 'start_time' and 'end_time' cannot be greater than a year.")
177177

178178
if ddelta < 1:

0 commit comments

Comments
 (0)