|
|
|
@ -46,10 +46,10 @@ async def get_target_reliability(
|
|
|
|
# cut_hours = Query(0)
|
|
|
|
# cut_hours = Query(0)
|
|
|
|
):
|
|
|
|
):
|
|
|
|
"""Get all scope pagination."""
|
|
|
|
"""Get all scope pagination."""
|
|
|
|
oh_session_id = params.oh_session_id,
|
|
|
|
oh_session_id = params.oh_session_id
|
|
|
|
eaf_input = params.eaf_input,
|
|
|
|
eaf_input = params.eaf_input
|
|
|
|
duration = params.duration,
|
|
|
|
duration = params.duration
|
|
|
|
simulation_id = params.simulation_id,
|
|
|
|
simulation_id = params.simulation_id
|
|
|
|
cut_hours = params.cut_hours
|
|
|
|
cut_hours = params.cut_hours
|
|
|
|
|
|
|
|
|
|
|
|
if not oh_session_id:
|
|
|
|
if not oh_session_id:
|
|
|
|
@ -68,20 +68,34 @@ async def get_target_reliability(
|
|
|
|
if duration != 17520:
|
|
|
|
if duration != 17520:
|
|
|
|
if not simulation_id:
|
|
|
|
if not simulation_id:
|
|
|
|
raise HTTPException(
|
|
|
|
raise HTTPException(
|
|
|
|
status_code=status.HTTP_425_TOO_EARLY, # or 409 Conflict
|
|
|
|
status_code=status.HTTP_400_BAD_REQUEST,
|
|
|
|
detail="Simulation still running. Please wait.",
|
|
|
|
detail="Simulation ID is required for non-default duration. Please run simulation first.",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
temporal_client = await Client.connect(TEMPORAL_URL)
|
|
|
|
try:
|
|
|
|
handle = temporal_client.get_workflow_handle(f"simulation-{simulation_id}")
|
|
|
|
temporal_client = await Client.connect(TEMPORAL_URL)
|
|
|
|
desc = await handle.describe()
|
|
|
|
handle = temporal_client.get_workflow_handle(f"simulation-{simulation_id}")
|
|
|
|
status_name = desc.status.name
|
|
|
|
desc = await handle.describe()
|
|
|
|
|
|
|
|
status_name = desc.status.name
|
|
|
|
|
|
|
|
|
|
|
|
if status_name in ["RUNNING", "CONTINUED_AS_NEW"]:
|
|
|
|
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_425_TOO_EARLY, # or 409 Conflict
|
|
|
|
status_code=status.HTTP_404_NOT_FOUND,
|
|
|
|
detail="Simulation still running. Please wait.",
|
|
|
|
detail=f"Simulation not found or error checking status: {str(e)}",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
simulation_id = TR_RBD_ID
|
|
|
|
simulation_id = TR_RBD_ID
|
|
|
|
|
|
|
|
|
|
|
|
|