-
Notifications
You must be signed in to change notification settings - Fork 239
/
workflows.py
33 lines (29 loc) · 921 Bytes
/
workflows.py
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
from fastapi import APIRouter
from mlrun.k8s_utils import get_k8s_helper
from mlrun.run import list_pipelines
router = APIRouter()
# curl http://localhost:8080/workflows?full=no
@router.get("/workflows")
def list_workflows(
experiment_id: str = None,
namespace: str = None,
sort_by: str = "",
page_token: str = "",
full: bool = False,
page_size: int = 10,
):
total_size, next_page_token, runs = None, None, None
if get_k8s_helper(silent=True).is_running_inside_kubernetes_cluster():
total_size, next_page_token, runs = list_pipelines(
full=full,
page_token=page_token,
page_size=page_size,
sort_by=sort_by,
experiment_id=experiment_id,
namespace=namespace,
)
return {
"runs": runs or [],
"total_size": total_size or 0,
"next_page_token": next_page_token or None,
}