Skip to content

Commit

Permalink
Merge pull request #104 from lsst-sqre:tickets/DM-48302
Browse files Browse the repository at this point in the history
DM-48302: Updates for new ruff FastAPI rules
  • Loading branch information
jonathansick authored Jan 6, 2025
2 parents 762f0da + 13a1a2a commit e61ad19
Show file tree
Hide file tree
Showing 12 changed files with 1,353 additions and 1,213 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.2
rev: v0.8.6
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
18 changes: 3 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ help:
@echo "make run - Start a local development instance"
@echo "make update - Update pinned dependencies and run make init"
@echo "make update-deps - Update pinned dependencies"
@echo "make update-deps-no-hashes - Pin dependencies without hashes"

.PHONY: init
init:
Expand All @@ -29,20 +28,9 @@ update-deps:
pip install --upgrade uv
uv pip install --upgrade pre-commit
pre-commit autoupdate
uv pip compile --upgrade --generate-hashes \
uv pip compile --upgrade --universal --generate-hashes \
--output-file requirements/main.txt requirements/main.in
uv pip compile --upgrade --generate-hashes \
uv pip compile --upgrade --universal --generate-hashes \
--output-file requirements/dev.txt requirements/dev.in
uv pip compile --upgrade --generate-hashes \
--output-file requirements/tox.txt requirements/tox.in

# Useful for testing against a Git version of Safir.
.PHONY: update-deps-no-hashes
update-deps-no-hashes:
pip install --upgrade uv
uv pip compile --upgrade \
--output-file requirements/main.txt requirements/main.in
uv pip compile --upgrade \
--output-file requirements/dev.txt requirements/dev.in
uv pip compile --upgrade \
uv pip compile --upgrade --universal --generate-hashes \
--output-file requirements/tox.txt requirements/tox.in
18 changes: 18 additions & 0 deletions changelog.d/20250106_122656_jsick_DM_48302.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- Delete the sections that don't apply -->

### Backwards-incompatible changes

-

### New features

-

### Bug fixes

-

### Other changes

- Update `make update` to use the `--universal` flag for `uv pip compile`.
- Use `Annotated` for `Query` dependencies in the path operations.
1,319 changes: 752 additions & 567 deletions requirements/dev.txt

Large diffs are not rendered by default.

1,102 changes: 524 additions & 578 deletions requirements/main.txt

Large diffs are not rendered by default.

62 changes: 32 additions & 30 deletions requirements/tox.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file was autogenerated by uv via the following command:
# uv pip compile --generate-hashes --output-file requirements/tox.txt requirements/tox.in
# uv pip compile --universal --generate-hashes --output-file requirements/tox.txt requirements/tox.in
cachetools==5.5.0 \
--hash=sha256:02134e8439cdc2ffb62023ce1debca2944c3f289d66bb17ead3ab3dede74b292 \
--hash=sha256:2cc24fb4cbe39633fb7badd9db9ca6295d766d9c2995f245725a46715d050f2a
Expand All @@ -11,7 +11,10 @@ chardet==5.2.0 \
colorama==0.4.6 \
--hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
--hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
# via tox
# via
# -c requirements/dev.txt
# -c requirements/main.txt
# tox
distlib==0.3.9 \
--hash=sha256:47f8c22fd27c27e25a65601af709b38e4f0a45ea4fc2e710f65755fa8caaaf87 \
--hash=sha256:a60f20dea646b8a33f3e7772f74dc0b2d0772d2837ee1342a00645c81edf9403
Expand All @@ -25,9 +28,9 @@ filelock==3.16.1 \
# -c requirements/dev.txt
# tox
# virtualenv
packaging==24.1 \
--hash=sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002 \
--hash=sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124
packaging==24.2 \
--hash=sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759 \
--hash=sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f
# via
# -c requirements/dev.txt
# -c requirements/main.txt
Expand Down Expand Up @@ -57,33 +60,32 @@ tox==4.23.2 \
# via
# -r requirements/tox.in
# tox-uv
tox-uv==1.16.0 \
--hash=sha256:71b2e2fa6c35c1360b91a302df1d65b3e5a1f656b321c5ebf7b84545804c9f01 \
--hash=sha256:e6f0b525a687e745ab878d07cbf5c7e85d582028d4a7c8935f95e84350651432
tox-uv==1.17.0 \
--hash=sha256:07020acd90048b5c898b2c8f1e7c1c4cf944161745d7bfe5b9458ed67f4998b7 \
--hash=sha256:cdc95eca6fd98a7716b9da7c9cf901d4836d6956089d6cb3417f00c8d98b513c
# via -r requirements/tox.in
uv==0.4.29 \
--hash=sha256:0be21afa0e582ddc5badff6ef40c3c6784efc5feae4ad568307b668d40dc49bd \
--hash=sha256:246da468ac0d51e7fb257cd038db2f8d6376ae269a44d01f56776e32108aa9da \
--hash=sha256:24cccff9c248864ba0ab3429bae56314146c9494ce66a881d70ea8cf2805945f \
--hash=sha256:287dc3fd3f78093a5a82136f01cbd9f224e0905b38d3dcffdc96c08fbbe48ee9 \
--hash=sha256:3473b05142ba436ac30d036b7ab5e9bcfa97f63df5d1382f92e0a3e4aaa391bc \
--hash=sha256:668d3e6095c6f0cac6a831ef4030f7ad79442d1c84b9569f01f50b60c2d51a77 \
--hash=sha256:67dcfd253020e25ed1c49e5bd06406205c37264f99e14002de53a357cd1cdadf \
--hash=sha256:68d4967b5f0af8bd46085e0f3ded229026700668a97734a21c3d11a5fc350c47 \
--hash=sha256:6b03859068aaa08ca9907a51d403d54b0a9d8054091646845a9192f213f099d4 \
--hash=sha256:7060dfbad0bc26e9cecbb4f8482445c958071511f23728948478f81acfb29048 \
--hash=sha256:75927da78f74bb935314d236dc61ecdc192e878e06eb79585b6d9d5ee9829f98 \
--hash=sha256:8c71663c7df4f512c697de39a4926dc191897f5fede73644bb2329f532c1ebfa \
--hash=sha256:950bbfe1954e9c3a5d6c4777bb778b4c23d0dea9ad9f77622c45d4fbba433355 \
--hash=sha256:9c559b6fdc042add463e86afa1c210716f7020bfc2e96b00df5af7afcb587ce7 \
--hash=sha256:b5775db128b98251c3ea7874367fc20dce9f9aac3dbfa635e3ef4a1c56842d9c \
--hash=sha256:cfb797a87b55d96cc0593e9f29ab5d58454be74598ea0158e1b2f4f2dc97cede \
--hash=sha256:df35d9cbe4cfbb7bce287f56e3bb7a7cef0b7b5173ed889d936d4c470f2b1b83 \
--hash=sha256:f6224a322267570e0470c61008fd1c8e2f50bf073b339f4c3010da86aef3c44c
uv==0.5.14 \
--hash=sha256:02fa1c9223ccb90e686a02c5c37a3357cac00165263b41f5f53119f815335157 \
--hash=sha256:03c0fe3f1257fb73650230e13e1fd928422b708276539e816242953681561bd7 \
--hash=sha256:12f041458a9d00c84a29eab79d3b5bc53dfd50947787b7c0f628eda7678621a7 \
--hash=sha256:2a6ecf961d96896f32fd6c198baa25d99f20ed12d6aeb5e514aa5874ae5000c3 \
--hash=sha256:2dd71f94881d2d402896ab4e94f47dd5e6f4f097c6ae4115345030e263910911 \
--hash=sha256:42d1e3849d3594b2d3a93f335a776597db8a1d3dcee43dbd4ec49f1ad1f63093 \
--hash=sha256:484e7921268057011264352696877e1e0c4fd1e0dab5057da73623c0a9d21067 \
--hash=sha256:54672772289c01811cf1efca4425fa2ae70bfaff020ec197288b7f6c969357e3 \
--hash=sha256:5fe0748a1c045dc1e95e77a8181ce9bfb848ebbeb175e277ad256a7befbbb61d \
--hash=sha256:786e16620d679cfa98cea1dd126405a82b63ee43e63994bc208abd0ab68cc529 \
--hash=sha256:90731cdc9ecb5fa7366696e07b81adf211d54417757f240ddd600f8b7b0107c7 \
--hash=sha256:93a187ed9da2df5788b755016c77559486c29cf3c87b9ca46822946e3c0734a4 \
--hash=sha256:a436e948f5ea149b9cd0eb30f923eca190b2d05bb48d9543d4373e1132da1b91 \
--hash=sha256:b4aa2131c1fc6db62311b26e768987aa582fe6c9256951b5fc9f6f56fb3e2cb9 \
--hash=sha256:d78a1289d51a9a605703540712963703e58c43380f9645738f6fea0ab4657788 \
--hash=sha256:f83af784fc842535c382aa58870a8c61aba0dfaa4bf4f2fdf5df03ec934060e2 \
--hash=sha256:ff362cb0ed592af69433680d9597f34e62c22fe7658a894212e80e24f7c506b6
# via tox-uv
virtualenv==20.27.1 \
--hash=sha256:142c6be10212543b32c6c45d3d3893dff89112cc588b7d0879ae5a1ec03a47ba \
--hash=sha256:f11f1b8a29525562925f745563bfd48b189450f61fb34c4f9cc79dd5aa32a1f4
virtualenv==20.28.1 \
--hash=sha256:412773c85d4dab0409b83ec36f7a6499e72eaf08c80e81e9576bca61831c71cb \
--hash=sha256:5d34ab240fdb5d21549b76f9e8ff3af28252f5499fb6d6f031adac4e5a8c5329
# via
# -c requirements/dev.txt
# tox
2 changes: 1 addition & 1 deletion src/noteburst/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
from safir.slack.blockkit import SlackException, SlackMessage, SlackTextField

__all__ = [
"TaskError",
"NbexecTaskError",
"NbexecTaskTimeoutError",
"NoteburstClientRequestError",
"NoteburstError",
"TaskError",
]


Expand Down
3 changes: 1 addition & 2 deletions src/noteburst/handlers/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from noteburst.config import config

__all__ = ["get_index", "external_router"]
__all__ = ["external_router", "get_index"]

external_router = APIRouter()
"""FastAPI router for all external handlers."""
Expand All @@ -26,7 +26,6 @@ class Index(BaseModel):
@external_router.get(
"/",
description=("Discover metadata about the application."),
response_model=Index,
response_model_exclude_none=True,
summary="Application metadata",
)
Expand Down
1 change: 0 additions & 1 deletion src/noteburst/handlers/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
" a health check. This route is not exposed outside the cluster and"
" therefore cannot be used by external clients."
),
response_model=Metadata,
response_model_exclude_none=True,
summary="Internal application metadata",
)
Expand Down
35 changes: 19 additions & 16 deletions src/noteburst/handlers/v1/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"/notebooks/",
summary="Submit a notebook for execution",
status_code=202,
response_model=NotebookResponse,
response_model_exclude_none=True,
)
async def post_nbexec(
Expand Down Expand Up @@ -81,30 +80,34 @@ async def post_nbexec(
@v1_router.get(
"/notebooks/{job_id}",
summary="Get information about a notebook execution job",
response_model=NotebookResponse,
response_model_exclude_none=True,
responses={404: {"description": "Not found", "model": ErrorModel}},
)
async def get_nbexec_job(
*,
job_id: str,
request: Request,
source: bool = Query(
False,
title="Include source ipynb",
description=(
"If set to true, the `source` field will include the JSON-encoded "
"content of the source ipynb notebook."
source: Annotated[
bool,
Query(
title="Include source ipynb",
description=(
"If set to true, the `source` field will include the "
"JSON-encoded content of the source ipynb notebook."
),
),
),
result: bool = Query(
True,
title="Include the result",
description=(
"If set to true and the notebook run is complete, the response "
"includes the executed notebook and metadata about the run."
] = False,
result: Annotated[
bool,
Query(
title="Include the result",
description=(
"If set to true and the notebook run is complete, the "
"response includes the executed notebook and metadata about "
"the run."
),
),
),
] = True,
logger: Annotated[structlog.BoundLogger, Depends(auth_logger_dependency)],
user: Annotated[str, Depends(auth_dependency)],
arq_queue: Annotated[ArqQueue, Depends(arq_dependency)],
Expand Down
2 changes: 1 addition & 1 deletion src/noteburst/user/_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from noteburst.config import config

__all__ = ["User", "AuthenticatedUser"]
__all__ = ["AuthenticatedUser", "User"]


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion src/noteburst/worker/functions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__all__ = ["ping", "nbexec", "run_python", "keep_alive"]
__all__ = ["keep_alive", "nbexec", "ping", "run_python"]

from .keepalive import keep_alive
from .nbexec import nbexec
Expand Down

0 comments on commit e61ad19

Please sign in to comment.