|
|
|
@ -92,38 +92,37 @@ async def get_target_reliability(
|
|
|
|
# oh_duration=duration
|
|
|
|
# oh_duration=duration
|
|
|
|
# )
|
|
|
|
# )
|
|
|
|
|
|
|
|
|
|
|
|
if duration != 17520:
|
|
|
|
if simulation_id:
|
|
|
|
if not simulation_id:
|
|
|
|
try:
|
|
|
|
raise HTTPException(
|
|
|
|
temporal_client = await Client.connect(TEMPORAL_URL)
|
|
|
|
status_code=status.HTTP_400_BAD_REQUEST,
|
|
|
|
handle = temporal_client.get_workflow_handle(f"simulation-{simulation_id}")
|
|
|
|
detail="Simulation ID is required for non-default duration. Please run simulation first.",
|
|
|
|
desc = await handle.describe()
|
|
|
|
)
|
|
|
|
status_name = desc.status.name
|
|
|
|
else:
|
|
|
|
|
|
|
|
try:
|
|
|
|
if status_name in ["RUNNING", "CONTINUED_AS_NEW"]:
|
|
|
|
temporal_client = await Client.connect(TEMPORAL_URL)
|
|
|
|
raise HTTPException(
|
|
|
|
handle = temporal_client.get_workflow_handle(f"simulation-{simulation_id}")
|
|
|
|
status_code=status.HTTP_425_TOO_EARLY,
|
|
|
|
desc = await handle.describe()
|
|
|
|
detail="Simulation is still running.",
|
|
|
|
status_name = desc.status.name
|
|
|
|
)
|
|
|
|
|
|
|
|
elif status_name != "COMPLETED":
|
|
|
|
if status_name in ["RUNNING", "CONTINUED_AS_NEW"]:
|
|
|
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
|
|
|
status_code=status.HTTP_425_TOO_EARLY,
|
|
|
|
|
|
|
|
detail="Simulation is still running.",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
elif status_name != "COMPLETED":
|
|
|
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
|
|
|
status_code=status.HTTP_400_BAD_REQUEST,
|
|
|
|
|
|
|
|
detail=f"Simulation failed with status: {status_name}",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
except HTTPException:
|
|
|
|
|
|
|
|
raise
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
# Handle connection errors or invalid workflow IDs
|
|
|
|
|
|
|
|
raise HTTPException(
|
|
|
|
raise HTTPException(
|
|
|
|
status_code=status.HTTP_404_NOT_FOUND,
|
|
|
|
status_code=status.HTTP_400_BAD_REQUEST,
|
|
|
|
detail=f"Simulation not found or error checking status: {str(e)}",
|
|
|
|
detail=f"Simulation failed with status: {status_name}",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
except HTTPException:
|
|
|
|
|
|
|
|
raise
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
# Handle connection errors or invalid workflow IDs
|
|
|
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
|
|
|
status_code=status.HTTP_404_NOT_FOUND,
|
|
|
|
|
|
|
|
detail=f"Simulation not found or error checking status: {str(e)}",
|
|
|
|
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
|
|
|
|
if duration != 17520 or oh_duration != 1200:
|
|
|
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
|
|
|
status_code=status.HTTP_400_BAD_REQUEST,
|
|
|
|
|
|
|
|
detail="Simulation ID is required for non-default duration or OH duration. Please run simulation first.",
|
|
|
|
|
|
|
|
)
|
|
|
|
simulation_id = TR_RBD_ID
|
|
|
|
simulation_id = TR_RBD_ID
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|