-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UWS support to FastAPI Safir app template
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.
- Loading branch information
Showing
72 changed files
with
2,213 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
project_templates/fastapi_safir_app/example-uws/.dockerignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# VSCode | ||
.vscode/ | ||
|
||
# Everything below this point is a copy of .gitignore. | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# macOS | ||
.DS_Store |
11 changes: 11 additions & 0 deletions
11
project_templates/fastapi_safir_app/example-uws/.github/dependabot.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
|
||
- package-ecosystem: "docker" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
87 changes: 87 additions & 0 deletions
87
project_templates/fastapi_safir_app/example-uws/.github/workflows/ci.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: CI | ||
|
||
env: | ||
# Current supported Python version. For applications, there is generally no | ||
# reason to support multiple Python versions, so all actions are run with | ||
# this version. Quote the version to avoid interpretation as a floating | ||
# point number. | ||
PYTHON_VERSION: "3.12" | ||
|
||
"on": | ||
merge_group: {} | ||
pull_request: {} | ||
push: | ||
branches-ignore: | ||
# These should always correspond to pull requests, so ignore them for | ||
# the push trigger and let them be triggered by the pull_request | ||
# trigger, avoiding running the workflow twice. This is a minor | ||
# optimization so there's no need to ensure this is comprehensive. | ||
- "dependabot/**" | ||
- "gh-readonly-queue/**" | ||
- "renovate/**" | ||
- "tickets/**" | ||
- "u/**" | ||
tags: | ||
- "*" | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: Run pre-commit | ||
uses: pre-commit/[email protected] | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Run tox | ||
uses: lsst-sqre/run-tox@v1 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
tox-envs: "py,coverage-report,typing" | ||
tox-requirements: requirements/tox.txt | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
needs: [lint, test] | ||
timeout-minutes: 10 | ||
|
||
# Only do Docker builds of tagged releases and pull requests from ticket | ||
# branches. This will still trigger on pull requests from untrusted | ||
# repositories whose branch names match our tickets/* branch convention, | ||
# but in this case the build will fail with an error since the secret | ||
# won't be set. | ||
if: > | ||
github.event_name != 'merge_group' | ||
&& (startsWith(github.ref, 'refs/tags/') | ||
|| startsWith(github.head_ref, 'tickets/')) | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: lsst-sqre/build-and-push-to-ghcr@v1 | ||
id: build | ||
with: | ||
image: ${{ github.repository }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: lsst-sqre/build-and-push-to-ghcr@v1 | ||
id: build-worker | ||
with: | ||
image: ${{ github.repository }}-worker | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
57 changes: 57 additions & 0 deletions
57
project_templates/fastapi_safir_app/example-uws/.github/workflows/periodic-ci.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# This is a separate run of the Python test suite that runs from a schedule, | ||
# doesn't cache the tox environment, and updates pinned dependencies first. | ||
# The purpose is to test compatibility with the latest versions of | ||
# dependencies. | ||
|
||
name: Periodic CI | ||
|
||
env: | ||
# Current supported Python version. For applications, there is generally no | ||
# reason to support multiple Python versions, so all actions are run with | ||
# this version. Quote the version to avoid interpretation as a floating | ||
# point number. | ||
PYTHON_VERSION: "3.12" | ||
|
||
"on": | ||
schedule: | ||
- cron: "0 12 * * 1" | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: Update dependencies | ||
run: | | ||
pip install --upgrade uv | ||
uv venv | ||
source .venv/bin/activate | ||
make update-deps | ||
shell: bash | ||
|
||
- name: Run tests in tox | ||
uses: lsst-sqre/run-tox@v1 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
tox-envs: "lint,typing,py" | ||
tox-requirements: requirements/tox.txt | ||
use-cache: false | ||
|
||
- name: Report status | ||
if: failure() | ||
uses: ravsamhq/notify-slack-action@v2 | ||
with: | ||
status: ${{ job.status }} | ||
notify_when: "failure" | ||
notification_title: "Periodic test for {repo} failed" | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ALERT_WEBHOOK }} |
Oops, something went wrong.