Skip to content

Commit

Permalink
Fix annotations and update requirements (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaFicarelli authored Oct 22, 2024
1 parent 052d964 commit 5861e98
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 164 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ make run

To make a release, build and publish the Docker image to the registry, you need to:

- push a tag to the main branch using git, or
- create a release through the GitHub UI.
- create a release through the GitHub UI (recommended), or
- push a tag to the main branch using git.

The format of the tag should be `YYYY.MM.DD`, where:
The format of the tag should be `YYYY.M.N`, where:

- `YYYY` is the full year (2024, 2025 ...)
- `MM` is the short month, not zero-padded (1, 2 ... 11, 12)
- `DD` is any incremental number, not zero-padded (it doesn't need to be the day number)
- `M` is the short month, not zero-padded (1, 2 ... 11, 12)
- `N` is any incremental number, not zero-padded (it doesn't need to be the day number)


## Documentation
Expand Down
6 changes: 3 additions & 3 deletions app/api/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def add_system_account(
) -> ApiResponse[SysAccountCreationOut]:
"""Add the system account."""
result = await account_service.add_system(repos, account_id=account.id, name=account.name)
return ApiResponse(
return ApiResponse[SysAccountCreationOut](
message="System account created",
data=SysAccountCreationOut.model_validate(result, from_attributes=True),
)
Expand All @@ -35,7 +35,7 @@ async def add_virtual_lab_account(
) -> ApiResponse[VlabAccountCreationOut]:
"""Add a new virtual lab account."""
result = await account_service.add_virtual_lab(repos, account_id=account.id, name=account.name)
return ApiResponse(
return ApiResponse[VlabAccountCreationOut](
message="Virtual lab created",
data=VlabAccountCreationOut.model_validate(result, from_attributes=True),
)
Expand All @@ -49,7 +49,7 @@ async def add_project_account(
result = await account_service.add_project(
repos, account_id=account.id, name=account.name, vlab_id=account.vlab_id
)
return ApiResponse(
return ApiResponse[ProjAccountCreationOut](
message="Project created",
data=ProjAccountCreationOut.model_validate(result, from_attributes=True),
)
6 changes: 3 additions & 3 deletions app/api/balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
async def get_balance_for_system(repos: RepoGroupDep) -> ApiResponse[SysBalanceOut]:
"""Return the balance for thr system."""
result = await balance_service.get_balance_for_system(repos)
return ApiResponse(
return ApiResponse[SysBalanceOut](
message="Balance for system",
data=result,
)
Expand All @@ -29,7 +29,7 @@ async def get_balance_for_virtual_lab(
result = await balance_service.get_balance_for_vlab(
repos, vlab_id=vlab_id, include_projects=include_projects
)
return ApiResponse(
return ApiResponse[VlabBalanceOut](
message=f"Balance for virtual-lab{' including projects' if include_projects else ''}",
data=result,
)
Expand All @@ -41,7 +41,7 @@ async def get_balance_for_project(
) -> ApiResponse[ProjBalanceOut]:
"""Return the balance for a given project."""
result = await balance_service.get_balance_for_project(repos, proj_id=proj_id)
return ApiResponse(
return ApiResponse[ProjBalanceOut](
message="Balance for project",
data=result,
)
2 changes: 1 addition & 1 deletion app/api/price.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async def add_price(
) -> ApiResponse[AddPriceOut]:
"""Add a new price."""
result = await price.add_price(repos, price_request)
return ApiResponse(
return ApiResponse[AddPriceOut](
message="Price added",
data=AddPriceOut.model_validate(result, from_attributes=True),
)
6 changes: 3 additions & 3 deletions app/api/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def get_jobs_for_system(
result = PaginatedOut[JobReportUnionOut].new(
items=jobs, total_items=total_items, pagination=pagination, url=request.url
)
return ApiResponse(
return ApiResponse[PaginatedOut[JobReportUnionOut]](
message="Job report for system",
data=result,
)
Expand All @@ -48,7 +48,7 @@ async def get_jobs_for_vlab(
result = PaginatedOut[JobReportUnionOut].new(
items=jobs, total_items=total_items, pagination=pagination, url=request.url
)
return ApiResponse(
return ApiResponse[PaginatedOut[JobReportUnionOut]](
message=f"Job report for virtual-lab {vlab_id}",
data=result,
)
Expand All @@ -70,7 +70,7 @@ async def get_jobs_for_proj(
result = PaginatedOut[JobReportUnionOut].new(
items=jobs, total_items=total_items, pagination=pagination, url=request.url
)
return ApiResponse(
return ApiResponse[PaginatedOut[JobReportUnionOut]](
message=f"Job report for project {proj_id}",
data=result,
)
8 changes: 4 additions & 4 deletions app/api/reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async def make_oneshot_reservation(
) -> ApiResponse[MakeReservationOut]:
"""Make a new reservation for oneshot job."""
result = await reservation.make_oneshot_reservation(repos, reservation_request)
return ApiResponse(
return ApiResponse[MakeReservationOut](
message="Oneshot reservation executed",
data=result,
)
Expand All @@ -37,7 +37,7 @@ async def make_longrun_reservation(
) -> ApiResponse[MakeReservationOut]:
"""Make a new reservation for longrun job."""
result = await reservation.make_longrun_reservation(repos, reservation_request)
return ApiResponse(
return ApiResponse[MakeReservationOut](
message="Longrun reservation executed",
data=result,
)
Expand All @@ -50,7 +50,7 @@ async def release_oneshot_reservation(
) -> ApiResponse[ReleaseReservationOut]:
"""Release the reservation for oneshot job."""
reservation_amount = await release.release_oneshot_reservation(repos, job_id=job_id)
return ApiResponse(
return ApiResponse[ReleaseReservationOut](
message="Oneshot reservation has been released",
data=ReleaseReservationOut(
job_id=job_id,
Expand All @@ -66,7 +66,7 @@ async def release_longrun_reservation(
) -> ApiResponse[ReleaseReservationOut]:
"""Release the reservation for longrun job."""
reservation_amount = await release.release_longrun_reservation(repos, job_id=job_id)
return ApiResponse(
return ApiResponse[ReleaseReservationOut](
message="Longrun reservation has been released",
data=ReleaseReservationOut(
job_id=job_id,
Expand Down
Loading

0 comments on commit 5861e98

Please sign in to comment.