Skip to content

Commit ebda7d2

Browse files
committed
fix: re-enable logging on system metrics
style: drop alignments with openning delimiters
1 parent ca29dbe commit ebda7d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1976
-1263
lines changed

app/api/api.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,18 @@ def _get_app(msd_overwritten: Optional[ModelServiceDep] = None, streamable: bool
115115
"description": tag.value
116116
} for tag in (Tags if not streamable else TagsStreamable)]
117117
config = get_settings()
118-
app = FastAPI(title="CogStack ModelServe",
119-
summary="A model serving and governance system for CogStack NLP solutions",
120-
docs_url=None,
121-
redoc_url=None,
122-
debug=(config.DEBUG == "true"),
123-
openapi_tags=tags_metadata)
118+
app = FastAPI(
119+
title="CogStack ModelServe",
120+
summary="A model serving and governance system for CogStack NLP solutions",
121+
docs_url=None,
122+
redoc_url=None,
123+
debug=(config.DEBUG == "true"),
124+
openapi_tags=tags_metadata,
125+
)
124126
add_exception_handlers(app)
125127
instrumentator = Instrumentator(
126-
excluded_handlers=["/docs", "/redoc", "/metrics", "/openapi.json", "/favicon.ico", "none"]).instrument(app)
128+
excluded_handlers=["/docs", "/redoc", "/metrics", "/openapi.json", "/favicon.ico", "none"]
129+
).instrument(app)
127130

128131
if msd_overwritten is not None:
129132
cms_globals.model_service_dep = msd_overwritten

app/api/routers/evaluation.py

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,19 @@
2929
assert cms_globals.props is not None, "Current active user dependency not injected"
3030
assert cms_globals.model_service_dep is not None, "Model service dependency not injected"
3131

32-
@router.post("/sanity-check",
33-
tags=[Tags.Evaluating.name],
34-
response_class=StreamingResponse,
35-
dependencies=[Depends(cms_globals.props.current_active_user)],
36-
description="Sanity check the model being served with a trainer export")
37-
def get_sanity_check_with_trainer_export(request: Request,
38-
trainer_export: Annotated[List[UploadFile], File(description="One or more trainer export files to be uploaded")],
39-
tracking_id: Union[str, None] = Depends(validate_tracking_id),
40-
model_service: AbstractModelService = Depends(cms_globals.model_service_dep)) -> StreamingResponse:
32+
@router.post(
33+
"/sanity-check",
34+
tags=[Tags.Evaluating.name],
35+
response_class=StreamingResponse,
36+
dependencies=[Depends(cms_globals.props.current_active_user)],
37+
description="Sanity check the model being served with a trainer export",
38+
)
39+
def get_sanity_check_with_trainer_export(
40+
request: Request,
41+
trainer_export: Annotated[List[UploadFile], File(description="One or more trainer export files to be uploaded")],
42+
tracking_id: Union[str, None] = Depends(validate_tracking_id),
43+
model_service: AbstractModelService = Depends(cms_globals.model_service_dep),
44+
) -> StreamingResponse:
4145
"""
4246
Performs a sanity check on the running model using the provided trainer export files.
4347
@@ -77,17 +81,21 @@ def get_sanity_check_with_trainer_export(request: Request,
7781
return response
7882

7983

80-
@router.post("/iaa-scores",
81-
tags=[Tags.Evaluating.name],
82-
response_class=StreamingResponse,
83-
dependencies=[Depends(cms_globals.props.current_active_user)],
84-
description="Calculate inter annotator agreement scores between two projects")
85-
def get_inter_annotator_agreement_scores(request: Request,
86-
trainer_export: Annotated[List[UploadFile], File(description="A list of trainer export files to be uploaded")],
87-
annotator_a_project_id: Annotated[int, Query(description="The project ID from one annotator")],
88-
annotator_b_project_id: Annotated[int, Query(description="The project ID from another annotator")],
89-
scope: Annotated[str, Query(enum=[s.value for s in Scope], description="The scope for which the score will be calculated, e.g., per_concept, per_document or per_span")],
90-
tracking_id: Union[str, None] = Depends(validate_tracking_id)) -> StreamingResponse:
84+
@router.post(
85+
"/iaa-scores",
86+
tags=[Tags.Evaluating.name],
87+
response_class=StreamingResponse,
88+
dependencies=[Depends(cms_globals.props.current_active_user)],
89+
description="Calculate inter annotator agreement scores between two projects",
90+
)
91+
def get_inter_annotator_agreement_scores(
92+
request: Request,
93+
trainer_export: Annotated[List[UploadFile], File(description="A list of trainer export files to be uploaded")],
94+
annotator_a_project_id: Annotated[int, Query(description="The project ID from one annotator")],
95+
annotator_b_project_id: Annotated[int, Query(description="The project ID from another annotator")],
96+
scope: Annotated[str, Query(enum=[s.value for s in Scope], description="The scope for which the score will be calculated, e.g., per_concept, per_document or per_span")],
97+
tracking_id: Union[str, None] = Depends(validate_tracking_id),
98+
) -> StreamingResponse:
9199
"""
92100
Calculates Inter-Annotator Agreement (IAA) scores between projects done by two annotators.
93101
@@ -136,14 +144,18 @@ def get_inter_annotator_agreement_scores(request: Request,
136144
return response
137145

138146

139-
@router.post("/concat_trainer_exports",
140-
tags=[Tags.Evaluating.name],
141-
response_class=JSONResponse,
142-
dependencies=[Depends(cms_globals.props.current_active_user)],
143-
description="Concatenate multiple trainer export files into a single file for download")
144-
def get_concatenated_trainer_exports(request: Request,
145-
trainer_export: Annotated[List[UploadFile], File(description="A list of trainer export files to be concatenated")],
146-
tracking_id: Union[str, None] = Depends(validate_tracking_id)) -> JSONResponse:
147+
@router.post(
148+
"/concat_trainer_exports",
149+
tags=[Tags.Evaluating.name],
150+
response_class=JSONResponse,
151+
dependencies=[Depends(cms_globals.props.current_active_user)],
152+
description="Concatenate multiple trainer export files into a single file for download",
153+
)
154+
def get_concatenated_trainer_exports(
155+
request: Request,
156+
trainer_export: Annotated[List[UploadFile], File(description="A list of trainer export files to be concatenated")],
157+
tracking_id: Union[str, None] = Depends(validate_tracking_id),
158+
) -> JSONResponse:
147159
"""
148160
Concatenates multiple trainer export files into a single file.
149161
@@ -172,14 +184,18 @@ def get_concatenated_trainer_exports(request: Request,
172184
return response
173185

174186

175-
@router.post("/annotation-stats",
176-
tags=[Tags.Evaluating.name],
177-
response_class=StreamingResponse,
178-
dependencies=[Depends(cms_globals.props.current_active_user)],
179-
description="Get annotation stats of trainer export files")
180-
def get_annotation_stats(request: Request,
181-
trainer_export: Annotated[List[UploadFile], File(description="One or more trainer export files to be uploaded")],
182-
tracking_id: Union[str, None] = Depends(validate_tracking_id)) -> StreamingResponse:
187+
@router.post(
188+
"/annotation-stats",
189+
tags=[Tags.Evaluating.name],
190+
response_class=StreamingResponse,
191+
dependencies=[Depends(cms_globals.props.current_active_user)],
192+
description="Get annotation stats of trainer export files",
193+
)
194+
def get_annotation_stats(
195+
request: Request,
196+
trainer_export: Annotated[List[UploadFile], File(description="One or more trainer export files to be uploaded")],
197+
tracking_id: Union[str, None] = Depends(validate_tracking_id),
198+
) -> StreamingResponse:
183199
"""
184200
Gets annotation statistics from the provided trainer export files.
185201

app/api/routers/health_check.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77

88
assert cms_globals.model_service_dep is not None, "Model service dependency not injected"
99

10-
@router.get("/healthz",
11-
description="Health check endpoint",
12-
include_in_schema=False)
10+
@router.get(
11+
"/healthz",
12+
description="Health check endpoint",
13+
include_in_schema=False,
14+
)
1315
async def is_healthy() -> PlainTextResponse:
1416
"""
1517
Performs a health check to ensure the FastAPI service is in operation.
@@ -21,9 +23,11 @@ async def is_healthy() -> PlainTextResponse:
2123
return PlainTextResponse(content="OK", status_code=200)
2224

2325

24-
@router.get("/readyz",
25-
description="Readiness check endpoint",
26-
include_in_schema=False)
26+
@router.get(
27+
"/readyz",
28+
description="Readiness check endpoint",
29+
include_in_schema=False,
30+
)
2731
async def is_ready(model_service: AbstractModelService = Depends(cms_globals.model_service_dep)) -> PlainTextResponse:
2832
"""
2933
Performs a readiness check to ensure the model service is ready for scoring and training tasks.

0 commit comments

Comments
 (0)