forked from UiPath/uipath-dev-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreload.py
More file actions
37 lines (28 loc) · 1005 Bytes
/
Copy pathreload.py
File metadata and controls
37 lines (28 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""Reload endpoint for hot-reloading the runtime factory."""
from __future__ import annotations
import logging
from fastapi import APIRouter, HTTPException, Request
router = APIRouter(tags=["reload"])
logger = logging.getLogger(__name__)
@router.post("/reload")
async def reload_factory(request: Request) -> dict[str, str]:
"""Reload the runtime factory by re-importing user modules."""
server = request.app.state.server
if server.factory_creator is None:
raise HTTPException(
status_code=400,
detail="Hot reload is not available (no factory_creator configured)",
)
# Block reload while any run is active
active = [
r
for r in server.run_service.runs.values()
if r.status in ("pending", "running")
]
if active:
raise HTTPException(
status_code=409,
detail="Cannot reload while runs are in progress",
)
await server.reload_factory()
return {"status": "ok"}