From fb9ed5a91f021347e1ca57e7a528b9f4581f21a5 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Fri, 18 Nov 2022 13:39:16 -0800 Subject: [PATCH 1/2] Regenerate from latest template Regenerate safirdemo from https://github.com/lsst/templates/pull/189 except for the Kustomize version number and the README.rst. --- .github/workflows/ci.yaml | 42 ++++++++++++++++------------------ .pre-commit-config.yaml | 4 ++-- Makefile | 7 ++++++ requirements/dev.txt | 6 ++--- requirements/main.in | 2 +- requirements/main.txt | 6 ++--- src/safirdemo/config.py | 48 +++++++++++++++++---------------------- src/safirdemo/main.py | 5 ++-- 8 files changed, 60 insertions(+), 60 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8c9ccbb..ab4889c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,14 +16,9 @@ name: CI pull_request: {} jobs: - test: - runs-on: ubuntu-latest + lint: - strategy: - matrix: - python: - - "3.9" - - "3.10" + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -31,31 +26,34 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python }} + python-version: "3.10" - name: Run pre-commit uses: pre-commit/action@v3.0.0 - - name: Install tox - run: pip install tox + test: - - name: Cache tox environments - id: cache-tox - uses: actions/cache@v3 - with: - path: .tox - # requirements/*.txt and pyproject.toml have versioning info - # that would impact the tox environment. - key: tox-${{ matrix.python }}-${{ hashFiles('requirements/*.txt') }}-${{ hashFiles('pyproject.toml') }} - restore-keys: | - tox-${{ matrix.python }}-${{ hashFiles('requirements/*.txt') }}- + runs-on: ubuntu-latest + + strategy: + matrix: + python: + - "3.9" + - "3.10" + + steps: + - uses: actions/checkout@v3 - name: Run tox - run: tox -e py,coverage-report,typing + uses: lsst-sqre/run-tox@v1 + with: + python-version: ${{ matrix.python }} + tox-envs: "py,coverage-report,typing" build: + runs-on: ubuntu-latest - needs: [test] + needs: [lint, test] # Only do Docker builds of tagged releases and pull requests from ticket # branches. This will still trigger on pull requests from untrusted diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9cde74d..adfed1d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,6 +2,7 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: + - id: trailing-whitespace - id: check-yaml - id: check-toml @@ -9,8 +10,7 @@ repos: rev: 5.10.1 hooks: - id: isort - additional_dependencies: - - toml + additional_dependencies: [toml] - repo: https://github.com/psf/black rev: 22.10.0 diff --git a/Makefile b/Makefile index 03df41e..ec5c977 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,13 @@ update-deps: pip-compile --upgrade --build-isolation --generate-hashes --output-file requirements/main.txt requirements/main.in pip-compile --upgrade --build-isolation --generate-hashes --output-file requirements/dev.txt requirements/dev.in +# Useful for testing against a Git version of Safir. +.PHONY: update-deps-no-hashes +update-deps-no-hashes: + pip install --upgrade pip-tools pip setuptools + pip-compile --upgrade --build-isolation --allow-unsafe --output-file requirements/main.txt requirements/main.in + pip-compile --upgrade --build-isolation --allow-unsafe --output-file requirements/dev.txt requirements/dev.in + .PHONY: init init: pip install --editable . diff --git a/requirements/dev.txt b/requirements/dev.txt index e3626e9..25d190b 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -279,9 +279,9 @@ typing-extensions==4.4.0 \ # via # -c requirements/main.txt # mypy -virtualenv==20.16.7 \ - --hash=sha256:8691e3ff9387f743e00f6bb20f70121f5e4f596cae754531f2b3b3a1b1ac696e \ - --hash=sha256:efd66b00386fdb7dbe4822d172303f40cd05e50e01740b19ea42425cbe653e29 +virtualenv==20.17.0 \ + --hash=sha256:40a7e06a98728fd5769e1af6fd1a706005b4bb7e16176a272ed4292473180389 \ + --hash=sha256:7d6a8d55b2f73b617f684ee40fd85740f062e1f2e379412cb1879c7136f05902 # via pre-commit # WARNING: The following packages were not pinned, but pip requires them to be diff --git a/requirements/main.in b/requirements/main.in index 68b8fb1..efa2601 100644 --- a/requirements/main.in +++ b/requirements/main.in @@ -11,4 +11,4 @@ starlette uvicorn[standard] # Other dependencies. -safir +safir>=3.4.0 diff --git a/requirements/main.txt b/requirements/main.txt index c3b1de0..6c4d14c 100644 --- a/requirements/main.txt +++ b/requirements/main.txt @@ -180,9 +180,9 @@ rfc3986[idna2008]==1.5.0 \ --hash=sha256:270aaf10d87d0d4e095063c65bf3ddbc6ee3d0b226328ce21e036f946e421835 \ --hash=sha256:a86d6e1f5b1dc238b218b012df0aa79409667bb209e58da56d0b94704e712a97 # via httpx -safir==3.3.0 \ - --hash=sha256:0f17d32d7f18f771a42ec2f638093c3d4b1599332d5f53c82cd8e6419c7d5146 \ - --hash=sha256:142402e90e6ec581d4a7a9e7b8e34ad5efb3de8507460c47d42b451b3b369dc7 +safir==3.4.0 \ + --hash=sha256:02379c630049b7f7f70f568f212090bbf5fb1dfd959a1b1e75dca85e515015e8 \ + --hash=sha256:888ce44a83b45bc247f85f9eac1a8de8221758ea181bb483186b789339c9b29c # via -r requirements/main.in sniffio==1.3.0 \ --hash=sha256:e60305c5e5d314f5389259b7f22aaa33d8f7dee49763119234af3755c55b9101 \ diff --git a/src/safirdemo/config.py b/src/safirdemo/config.py index f7ba6d1..4bf4e65 100644 --- a/src/safirdemo/config.py +++ b/src/safirdemo/config.py @@ -2,39 +2,33 @@ from __future__ import annotations -import os -from dataclasses import dataclass +from pydantic import BaseSettings, Field +from safir.logging import LogLevel, Profile __all__ = ["Configuration", "config"] -@dataclass -class Configuration: +class Configuration(BaseSettings): """Configuration for safirdemo.""" - name: str = os.getenv("SAFIR_NAME", "safirdemo") - """The application's name, which doubles as the root HTTP endpoint path. - - Set with the ``SAFIR_NAME`` environment variable. - """ - - profile: str = os.getenv("SAFIR_PROFILE", "development") - """Application run profile: "development" or "production". - - Set with the ``SAFIR_PROFILE`` environment variable. - """ - - logger_name: str = os.getenv("SAFIR_LOGGER", "safirdemo") - """The root name of the application's logger. - - Set with the ``SAFIR_LOGGER`` environment variable. - """ - - log_level: str = os.getenv("SAFIR_LOG_LEVEL", "INFO") - """The log level of the application's logger. - - Set with the ``SAFIR_LOG_LEVEL`` environment variable. - """ + name: str = Field( + "safirdemo", + title="Name of application", + description="Doubles as the root HTTP endpoint path.", + env="SAFIR_NAME", + ) + + profile: Profile = Field( + Profile.development, + title="Application logging profile", + env="SAFIR_PROFILE", + ) + + log_level: LogLevel = Field( + LogLevel.INFO, + title="Log level of the application's logger", + env="SAFIR_LOG_LEVEL", + ) config = Configuration() diff --git a/src/safirdemo/main.py b/src/safirdemo/main.py index 8087dae..a08738b 100644 --- a/src/safirdemo/main.py +++ b/src/safirdemo/main.py @@ -11,7 +11,7 @@ from fastapi import FastAPI from safir.dependencies.http_client import http_client_dependency -from safir.logging import configure_logging +from safir.logging import configure_logging, configure_uvicorn_logging from safir.middleware.x_forwarded import XForwardedMiddleware from .config import config @@ -24,8 +24,9 @@ configure_logging( profile=config.profile, log_level=config.log_level, - name=config.logger_name, + name="safirdemo", ) +configure_uvicorn_logging(config.log_level) app = FastAPI( title="safirdemo", From ef4a1174a208e17f5333fedcaca18ae2bce08b14 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Tue, 29 Nov 2022 09:26:03 -0800 Subject: [PATCH 2/2] Bump version of Kubernetes manifest to 1.2.0 --- manifests/base/kustomization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/base/kustomization.yaml b/manifests/base/kustomization.yaml index 2adae02..e9126d0 100644 --- a/manifests/base/kustomization.yaml +++ b/manifests/base/kustomization.yaml @@ -3,7 +3,7 @@ kind: Kustomization images: - name: "ghcr.io/lsst-sqre/safirdemo" - newTag: 1.1.0 + newTag: 1.2.0 resources: - configmap.yaml