Skip to content

Commit

Permalink
more flexible payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Feb 13, 2024
1 parent 0f7b7fa commit 1f1773a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 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 pydantic import BaseModel, create_model
from pydantic import BaseModel, create_model, ConfigDict

from hayhooks.server.pipelines import registry

Expand All @@ -26,10 +26,11 @@ def deploy_pipeline_def(app, pipeline_def: PipelineDefinition):
# },
# 'second_addition': {'add': {'type': typing.Optional[int], 'is_mandatory': False}},
# }
config = ConfigDict(arbitrary_types_allowed=True)
component_model = {}
for name, typedef in inputs.items():
component_model[name] = (typedef["type"], typedef.get("default_value", ...))
request_model[component_name] = (create_model('ComponentParams', **component_model), ...)
request_model[component_name] = (create_model('ComponentParams', **component_model, __config__=config), ...)

PipelineRunRequest = create_model(f'{pipeline_def.name.capitalize()}RunRequest', **request_model)

Expand Down

0 comments on commit 1f1773a

Please sign in to comment.