forked from openml/server-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflows.py
More file actions
76 lines (65 loc) · 2.07 KB
/
flows.py
File metadata and controls
76 lines (65 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from collections.abc import Sequence
from typing import cast
from sqlalchemy import Row, text
from sqlalchemy.ext.asyncio import AsyncConnection
async def get_subflows(for_flow: int, expdb: AsyncConnection) -> Sequence[Row]:
result = await expdb.execute(
text(
"""
SELECT child as child_id, identifier
FROM implementation_component
WHERE parent = :flow_id
""",
),
parameters={"flow_id": for_flow},
)
return cast("Sequence[Row]", result.all())
async def get_tags(flow_id: int, expdb: AsyncConnection) -> list[str]:
tag_rows = await expdb.execute(
text(
"""
SELECT tag
FROM implementation_tag
WHERE id = :flow_id
""",
),
parameters={"flow_id": flow_id},
)
return [tag.tag for tag in tag_rows]
async def get_parameters(flow_id: int, expdb: AsyncConnection) -> Sequence[Row]:
result = await expdb.execute(
text(
"""
SELECT *, defaultValue as default_value, dataType as data_type
FROM input
WHERE implementation_id = :flow_id
""",
),
parameters={"flow_id": flow_id},
)
return cast("Sequence[Row]", result.all())
async def get_by_name(name: str, external_version: str, expdb: AsyncConnection) -> Row | None:
"""Gets flow by name and external version."""
result = await expdb.execute(
text(
"""
SELECT *, uploadDate as upload_date
FROM implementation
WHERE name = :name AND external_version = :external_version
""",
),
parameters={"name": name, "external_version": external_version},
)
return result.one_or_none()
async def get(id_: int, expdb: AsyncConnection) -> Row | None:
result = await expdb.execute(
text(
"""
SELECT *, uploadDate as upload_date
FROM implementation
WHERE id = :flow_id
""",
),
parameters={"flow_id": id_},
)
return result.one_or_none()