1
1
import http .client
2
2
from typing import Annotated , Literal
3
3
4
+ import database .flows
4
5
from core .conversions import _str_to_num
5
- from database .flows import get_flow as db_get_flow
6
- from database .flows import get_flow_by_name , get_flow_parameters , get_flow_subflows , get_flow_tags
7
6
from fastapi import APIRouter , Depends , HTTPException
8
7
from schemas .flows import Flow , Parameter
9
8
from sqlalchemy import Connection
@@ -20,7 +19,7 @@ def flow_exists(
20
19
expdb : Annotated [Connection , Depends (expdb_connection )],
21
20
) -> dict [Literal ["flow_id" ], int ]:
22
21
"""Check if a Flow with the name and version exists, if so, return the flow id."""
23
- flow = get_flow_by_name (name , version , expdb )
22
+ flow = database . flows . get_by_name (name , version , expdb )
24
23
if flow is None :
25
24
raise HTTPException (
26
25
status_code = http .client .NOT_FOUND ,
@@ -31,11 +30,11 @@ def flow_exists(
31
30
32
31
@router .get ("/{flow_id}" )
33
32
def get_flow (flow_id : int , expdb : Annotated [Connection , Depends (expdb_connection )] = None ) -> Flow :
34
- flow = db_get_flow (flow_id , expdb )
33
+ flow = database . flows . get_by_id (flow_id , expdb )
35
34
if not flow :
36
35
raise HTTPException (status_code = http .client .NOT_FOUND , detail = "Flow not found" )
37
36
38
- parameter_rows = get_flow_parameters (flow_id , expdb )
37
+ parameter_rows = database . flows . get_parameters (flow_id , expdb )
39
38
parameters = [
40
39
Parameter (
41
40
name = parameter .name ,
@@ -49,9 +48,8 @@ def get_flow(flow_id: int, expdb: Annotated[Connection, Depends(expdb_connection
49
48
for parameter in parameter_rows
50
49
]
51
50
52
- tags = get_flow_tags (flow_id , expdb )
53
-
54
- flow_rows = get_flow_subflows (flow_id , expdb )
51
+ tags = database .flows .get_tags (flow_id , expdb )
52
+ flow_rows = database .flows .get_subflows (for_flow = flow_id , expdb = expdb )
55
53
subflows = [
56
54
{
57
55
"identifier" : flow .identifier ,
0 commit comments