Skip to content

Commit

Permalink
ILAB API unit testing
Browse files Browse the repository at this point in the history
This covers 100% of the ilab.py API module using `FastAPI`'s `TestClient`.

This proved ... interesting ... as the FastAPI and Starlette versions we use
are incompatible with the underlying httpx version ... TestClient init fails
in a way that can't be worked around. (Starlette passes an unknown keyword
parameter.)

After some experimentation, I ended up "unlocking" all the API-related
packages in `project.toml` to `"*"` and letting `poetry update` resolve them,
then "re-locked" them to those versions. The resulting combination of modules
works for unit testing, and appears to work in a real `./local-compose.sh`
deployment as well.
  • Loading branch information
dbutenhof committed Jan 16, 2025
1 parent c6d7456 commit c3b359f
Show file tree
Hide file tree
Showing 6 changed files with 1,021 additions and 726 deletions.
49 changes: 0 additions & 49 deletions backend/app/api/v1/endpoints/ilab/ilab.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,55 +360,6 @@ async def iteration_samples(
return await crucible.get_samples(iteration=iteration)


@router.get(
"/api/v1/ilab/runs/{run}/timeline",
summary="Returns the 'timeline' of a run",
description="Describes the sequence of iterations, samples, and periods.",
responses={
200: example_response(
{
"run": {
"id": "70d3b53f-c588-49a3-91c2-7fcf3927be7e",
"iterations": [
{
"id": "BFC16DA6-60C8-11EF-AB10-CF940109872B",
"num": 1,
"path": None,
"primary-metric": "ilab::train-samples-sec",
"primary-period": "measurement",
"status": "pass",
"samples": [
{
"id": "C021BECC-60C8-11EF-A619-E0BC70D6C320",
"num": "1",
"path": None,
"status": "pass",
"periods": [
{
"begin": "2024-08-22 19:09:08.642000+00:00",
"end": "2024-08-22 20:04:32.889000+00:00",
"id": "C022CDC6-60C8-11EF-BA80-AFE7B4B2692B",
"name": "measurement",
}
],
}
],
}
],
"begin": "2024-08-22 19:09:08.642000+00:00",
"end": "2024-08-22 20:04:32.889000+00:00",
}
}
),
400: example_error("Parameter error"),
},
)
async def timeline(
crucible: Annotated[CrucibleService, Depends(crucible_svc)], run: str
):
return await crucible.get_timeline(run)


@router.get(
"/api/v1/ilab/runs/{run}/metrics",
summary="Describe the metrics collected for a run",
Expand Down
Loading

0 comments on commit c3b359f

Please sign in to comment.