-
Notifications
You must be signed in to change notification settings - Fork 10
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-45448: Add UWS support to FastAPI Safir app template #260
Conversation
76ca60f
to
a49a497
Compare
This depends on lsst-sqre/safir#281. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, but note the one issue with the number of fields in `templatekit.yaml.
@@ -17,6 +17,10 @@ dialog_fields: | |||
- label: "Initial copyright holder" | |||
key: "copyright_holder" | |||
component: "select" | |||
- label: "UWS service" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We’re still using the dialog API from Slack, which limits us to five fields in a dialog. I’d suggest two changes to templatekit.yaml
and the cookiecutter variables to accommodate that well:
-
Drop the “Deployed with Helm” field from templatekit.yaml. You can either then remove all the associated Kustomize templates, or for now just leave in cookiecutter.yaml a True default for
uses_helm
. -
Consider reconceptualizing the
UWS Service
flag field into aFlavor
orKind
choice. The default would be “Regular” and the second choice would be “UWS”. This will let us pack more of these app variations into the same Slack dialog field. Of course we don’t have to do this now since there aren’t any other variations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, great idea, thank you! Helm removal now submitted as #262. When that's merged, I'll rebase and change this to a flavor option instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now done, and there were no changes to the generated examples so I think I did the transformation correctly.
Add a new configuration option for the FastAPI Safir app project template that allows the user to indicate whether they are building a UWS app with a separate backend and a queuing system (defaulting to no). If that option is enabled, add in the machinery for a UWS application, including stub models and a stub worker function. This template uncovered a Ruff diagnostic for unused class method parameters that would fire on the initial application as generated from the template. Add an ignore rule for that diagnostic for the same reason as the similar diagnostic for unused method arguments.
Rather than a boolean saying whether or not the service in question is a UWS service, instead add a new flavor key that currently takes only two values: Default and UWS. Change all the conditionals to instead check that the flavor is UWS to enable the UWS code.
The Butler client requires a pip-installed httpx, and the log configuration requires structlog.
Make the UWS flavor depend on Safir 6.2.0, not 7, since the UWS support was just a feature release.
Overview
Add a new configuration option for the FastAPI Safir app project template that allows the user to indicate whether they are building a UWS app with a separate backend and a queuing system (defaulting to no). If that option is enabled, add in the machinery for a UWS application, including stub models and a stub worker function.
This template uncovered a Ruff diagnostic for unused class method parameters that would fire on the initial application as generated from the template. Add an ignore rule for that diagnostic for the same reason as the similar diagnostic for unused method arguments.
Remove the export of
config
frommain.py
, since our standard is to importconfig
directly fromconfig.py
.Testing
Tested by copying
example-uws
into its own directory, committing it to Git, pointing it to the branch version of Safir with UWS support, and running lint, typing, and py targets.