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-45448: Add UWS support to FastAPI Safir app template #260

Merged
merged 4 commits into from
Aug 2, 2024
Merged

Conversation

rra
Copy link
Member

@rra rra commented Jul 29, 2024

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 from main.py, since our standard is to import config directly from config.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.

@rra rra requested a review from jonathansick July 29, 2024 22:21
@rra rra force-pushed the tickets/DM-45448 branch 2 times, most recently from 76ca60f to a49a497 Compare July 29, 2024 22:33
@rra
Copy link
Member Author

rra commented Jul 29, 2024

This depends on lsst-sqre/safir#281.

Copy link
Member

@jonathansick jonathansick left a 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"
Copy link
Member

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:

  1. 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.

  2. Consider reconceptualizing the UWS Service flag field into a Flavor or Kind 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.

Copy link
Member Author

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.

Copy link
Member Author

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.
@rra rra force-pushed the tickets/DM-45448 branch from a49a497 to 6c97b25 Compare July 30, 2024 22:04
rra added 3 commits July 30, 2024 15:23
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.
@rra rra merged commit cb94753 into main Aug 2, 2024
4 checks passed
@rra rra deleted the tickets/DM-45448 branch August 2, 2024 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants