Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-47928: Update FastAPI Safir UWS app parameter dependency #290

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Annotated

from fastapi import Depends
from safir.uws import UWSJobParameter, uws_post_params_dependency
from safir.uws import UWSJobParameter

__all__ = [
"post_params_dependency",
Expand All @@ -13,15 +13,9 @@
async def post_params_dependency(
*,
# Add POST parameters here. All of them should be Form() parameters.
# Use str | None for single-valued attributes and str | list[str] | None
# for parameters that can be given more than one time.
params: Annotated[
list[UWSJobParameter], Depends(uws_post_params_dependency)
],
# Use str | None for single-valued attributes and list[str] | None for
# parameters that can be given more than one time.
) -> list[UWSJobParameter]:
"""Parse POST parameters into job parameters."""
return [
p
for p in params
if p.parameter_id in set() # Replace with set of parameter names
]
params: list[UWSJobParameter] = []
# Populate params with the values of all form parameters that were set.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Annotated

from fastapi import Depends
from safir.uws import UWSJobParameter, uws_post_params_dependency
from safir.uws import UWSJobParameter

__all__ = [
"post_params_dependency",
Expand All @@ -14,16 +14,10 @@
async def post_params_dependency(
*,
# Add POST parameters here. All of them should be Form() parameters.
# Use str | None for single-valued attributes and str | list[str] | None
# for parameters that can be given more than one time.
params: Annotated[
list[UWSJobParameter], Depends(uws_post_params_dependency)
],
# Use str | None for single-valued attributes and list[str] | None for
# parameters that can be given more than one time.
) -> list[UWSJobParameter]:
"""Parse POST parameters into job parameters."""
return [
p
for p in params
if p.parameter_id in set() # Replace with set of parameter names
]
params: list[UWSJobParameter] = []
# Populate params with the values of all form parameters that were set.
{%- endif %}
2 changes: 1 addition & 1 deletion project_templates/technote_md/testn-000/technote.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ series_id = "TESTN"
canonical_url = "https://testn-000.lsst.io"
github_url = "https://github.com/lsst/testn-000"
github_default_branch = "main"
date_created = 2024-11-25T22:09:21Z
date_created = 2024-12-03T22:35:26Z
organization.name = "Vera C. Rubin Observatory"
organization.ror = "https://ror.org/048g3cy84"
license.id = "CC-BY-4.0"
Expand Down
2 changes: 1 addition & 1 deletion project_templates/technote_rst/testn-000/technote.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ series_id = "TESTN"
canonical_url = "https://testn-000.lsst.io"
github_url = "https://github.com/lsst/testn-000"
github_default_branch = "main"
date_created = 2024-11-25T22:09:21Z
date_created = 2024-12-03T22:35:26Z
organization.name = "Vera C. Rubin Observatory"
organization.ror = "https://ror.org/048g3cy84"
license.id = "CC-BY-4.0"
Expand Down
Loading