refac: on_valves_update hook added

This commit is contained in:
Timothy J. Baek
2024-05-28 16:58:56 -07:00
parent 5494d2d3c6
commit 2109df8230
3 changed files with 205 additions and 3 deletions

View File

@@ -268,18 +268,19 @@ async def update_valves(pipeline_id: str, form_data: dict):
pipeline_module = PIPELINE_MODULES[pipeline_id]
await pipeline_module.on_shutdown()
try:
ValvesModel = pipeline_module.valves.__class__
valves = ValvesModel(**form_data)
pipeline_module.valves = valves
if hasattr(pipeline_module, "on_valves_update"):
await pipeline_module.on_valves_update()
except Exception as e:
print(e)
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail=f"{str(e)}",
)
await pipeline_module.on_startup()
return pipeline_module.valves