Skip to content

Commit

Permalink
Merge pull request #27 from alex-stoica/custom-deploy-utils
Browse files Browse the repository at this point in the history
deploy_utils.py w async execution support
  • Loading branch information
mpangrazzi authored Nov 13, 2024
2 parents 4c6d8f3 + 5af01d6 commit 35837d8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/hayhooks/server/utils/deploy_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from fastapi import HTTPException
from fastapi.responses import JSONResponse

from fastapi.concurrency import run_in_threadpool

from hayhooks.server.pipelines import registry
from hayhooks.server.pipelines.models import (
Expand All @@ -10,7 +10,6 @@
convert_component_output,
)


def deploy_pipeline_def(app, pipeline_def: PipelineDefinition):
try:
pipe = registry.add(pipeline_def.name, pipeline_def.source_code)
Expand All @@ -24,7 +23,7 @@ def deploy_pipeline_def(app, pipeline_def: PipelineDefinition):
# the endpoint handler. We have to ignore the type here to make FastAPI happy while
# silencing static type checkers (that would have good reasons to trigger!).
async def pipeline_run(pipeline_run_req: PipelineRunRequest) -> JSONResponse: # type: ignore
result = pipe.run(data=pipeline_run_req.dict())
result = await run_in_threadpool(pipe.run, data=pipeline_run_req.dict())
final_output = {}
for component_name, output in result.items():
final_output[component_name] = convert_component_output(output)
Expand Down

0 comments on commit 35837d8

Please sign in to comment.