• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Clinical-Genomics / arnold / 7102454002

05 Dec 2023 02:52PM UTC coverage: 0.0%. Remained the same
7102454002

push

github

web-flow
Update to pydantic v2 (#47) (patch)

Added
Move the models to pydantic v2

add Codeowners for automatic reviewer tagging

0 of 89 new or added lines in 5 files covered. (0.0%)

28 existing lines in 5 files now uncovered.

0 of 699 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/arnold/api/api_v1/endpoints/step.py
1
from typing import List
×
2

3
from fastapi import APIRouter, Depends, status
×
4
from fastapi.responses import JSONResponse
×
5
from pydantic import parse_obj_as
×
6

7
from arnold.adapter import ArnoldAdapter
×
8
from arnold.constants import QUERY_RULES
×
9
from arnold.crud import create, update
×
10
from arnold.crud.read.step import (
×
11
    aggregate_step,
12
    find_step_type_artifact_udfs,
13
    find_step_type_process_udfs,
14
    find_step,
15
    query_steps,
16
)
17
from arnold.models.database.step import Step
×
18
import logging
×
19

20
from arnold.models.api_models import WorkflowResponce, StepFilters, StepFiltersBase, Pagination
×
21
from arnold.settings import get_arnold_adapter
×
22
import arnold.crud.read.step
×
23

24
LOG = logging.getLogger(__name__)
×
25

26
router = APIRouter()
×
27

28

29
@router.get("/step/query_rules")
×
30
def get_query_rules():
×
31
    """Get possible filtering rules."""
32

33
    return QUERY_RULES
×
34

35

36
@router.get("/step/workflows", response_model=list[WorkflowResponce])
×
37
def get_workflows(adapter: ArnoldAdapter = Depends(get_arnold_adapter)):
×
38
    """Get available workflows and step types from the step collection"""
39

40
    pipe = [{"$group": {"_id": "$workflow", "step_types": {"$addToSet": "$step_type"}}}]
×
41
    workflows: list[dict] = aggregate_step(adapter=adapter, pipe=pipe)
×
42
    return parse_obj_as(List[WorkflowResponce], workflows)
×
43

44

45
@router.get("/step/step_type/udfs")
×
46
def get_step_type_udfs(
×
47
    step_type: str,
48
    workflow: str,
49
    adapter: ArnoldAdapter = Depends(get_arnold_adapter),
50
):
51
    """Get available artifact udfs for a step type"""
52

53
    artifact_udfs = find_step_type_artifact_udfs(
×
54
        adapter=adapter, step_type=step_type, workflow=workflow
55
    )
56
    process_udfs = find_step_type_process_udfs(
×
57
        adapter=adapter, step_type=step_type, workflow=workflow
58
    )
59
    return artifact_udfs + process_udfs
×
60

61

62
@router.get("/step/{step_id}", response_model=Step)
×
63
def get_step_by_id(
×
64
    step_id: str,
65
    adapter: ArnoldAdapter = Depends(get_arnold_adapter),
66
):
67
    """fetch a step by step id"""
68

69
    step: Step = find_step(step_id=step_id, adapter=adapter)
×
70
    return step
×
71

72

73
@router.post("/get_steps/", response_model=List[Step])
×
74
def get_steps(
×
75
    step_filters: StepFilters,
76
    adapter: ArnoldAdapter = Depends(get_arnold_adapter),
77
):
78
    """Get steps based on filters"""
79

80
    steps: List[Step] = query_steps(
×
81
        step_filters=StepFiltersBase(**step_filters.dict()),
82
        pagination=Pagination(**step_filters.dict()),
83
        udf_filters=step_filters.udf_filters,
84
        adapter=adapter,
85
    )
86
    return steps
×
87

88

89
@router.post("/step/")
×
90
def create_step(step: Step, adapter: ArnoldAdapter = Depends(get_arnold_adapter)) -> JSONResponse:
×
91
    if arnold.crud.read.step.find_step(step_id=step.step_id, adapter=adapter):
×
92
        return JSONResponse(
×
93
            status_code=status.HTTP_405_METHOD_NOT_ALLOWED, content="step already in database"
94
        )
95
    try:
×
96
        create.create_step(adapter=adapter, step=step)
×
97
    except Exception as e:
×
98
        return JSONResponse(
×
99
            status_code=status.HTTP_405_METHOD_NOT_ALLOWED,
100
            content=f"exception {e} ",
101
        )
102

103
    return JSONResponse(
×
104
        status_code=status.HTTP_200_OK, content=f"step {step.step_id} inserted to db"
105
    )
106

107

108
@router.post("/steps/")
×
109
def create_steps(
×
110
    steps: List[Step], adapter: ArnoldAdapter = Depends(get_arnold_adapter)
111
) -> JSONResponse:
112
    try:
×
113
        create.create_steps(adapter=adapter, steps=steps)
×
114
    except Exception as e:
×
115
        return JSONResponse(
×
116
            status_code=status.HTTP_405_METHOD_NOT_ALLOWED,
117
            content=f"exception {e} ",
118
        )
119
    return JSONResponse(status_code=status.HTTP_200_OK, content="steps inserted to db")
×
120

121

122
@router.put("/step/")
×
123
def update_step(step: Step, adapter: ArnoldAdapter = Depends(get_arnold_adapter)) -> JSONResponse:
×
124
    try:
×
125
        update.update_step(adapter=adapter, step=step)
×
126
    except Exception as e:
×
UNCOV
127
        return JSONResponse(
×
128
            status_code=status.HTTP_405_METHOD_NOT_ALLOWED,
129
            content=f"exception {e} ",
130
        )
131

UNCOV
132
    return JSONResponse(
×
133
        status_code=status.HTTP_200_OK, content=f"step {step.step_id} inserted to db"
134
    )
135

136

137
@router.put("/steps/")
×
UNCOV
138
def update_steps(
×
139
    steps: List[Step], adapter: ArnoldAdapter = Depends(get_arnold_adapter)
140
) -> JSONResponse:
141
    try:
×
142
        update.update_steps(adapter=adapter, steps=steps)
×
UNCOV
143
    except Exception as e:
×
UNCOV
144
        return JSONResponse(
×
145
            status_code=status.HTTP_405_METHOD_NOT_ALLOWED,
146
            content=f"exception {e} ",
147
        )
UNCOV
148
    return JSONResponse(status_code=status.HTTP_200_OK, content="steps inserted to db")
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc