run chain input
This commit is contained in:
parent
f1cfa85843
commit
da00232fe7
|
|
@ -1,3 +1,6 @@
|
|||
from chain_service.schema.run_chain import RunChainInput
|
||||
from chain_service.dependencies.chain_repository import ChainRepositoryDependency
|
||||
|
||||
from loguru import logger
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
|
|
@ -5,11 +8,18 @@ router = APIRouter()
|
|||
|
||||
|
||||
@router.post("/run_chain")
|
||||
async def run_chain_controller():
|
||||
async def run_chain_controller(
|
||||
run_chain_input: RunChainInput, chain_repository: ChainRepositoryDependency
|
||||
):
|
||||
try:
|
||||
logger.info("Got chain to run")
|
||||
assert (chain := await chain_repository.get_by_id(run_chain_input.chain_id))
|
||||
logger.info(f"Got chain to run {chain}")
|
||||
return {"works": True}
|
||||
|
||||
except AssertionError:
|
||||
logger.info(f"Chain not found {run_chain_input.chain_id}")
|
||||
return HTTPException(status_code=404, detail="Chain not found")
|
||||
|
||||
except Exception:
|
||||
logger.exception("Error during run chain")
|
||||
return HTTPException(status_code=500, detail="Error during run chain")
|
||||
|
|
|
|||
0
chain_service/schema/__init__.py
Normal file
0
chain_service/schema/__init__.py
Normal file
6
chain_service/schema/base.py
Normal file
6
chain_service/schema/base.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
from pydantic.alias_generators import to_camel
|
||||
|
||||
|
||||
class BaseConfig:
|
||||
populate_by_name = True
|
||||
alias_generator = to_camel
|
||||
14
chain_service/schema/run_chain.py
Normal file
14
chain_service/schema/run_chain.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from .base import BaseConfig
|
||||
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Annotated, Optional, List
|
||||
|
||||
|
||||
class RunChainInput(BaseModel):
|
||||
task_id: int
|
||||
chain_id: str
|
||||
recipients: Annotated[Optional[List[int]], Field(default=[])]
|
||||
|
||||
class Config(BaseConfig):
|
||||
pass
|
||||
Loading…
Reference in New Issue
Block a user