Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #180 from lsst-sqre/tickets/DM-37046
Browse files Browse the repository at this point in the history
DM-37046: Regenerate from latest template
  • Loading branch information
rra authored Nov 29, 2022
2 parents fa39159 + ef4a117 commit 74ee7a7
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 61 deletions.
42 changes: 20 additions & 22 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,44 @@ 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

- 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/[email protected]

- 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
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: check-yaml
- id: check-toml

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
additional_dependencies:
- toml
additional_dependencies: [toml]

- repo: https://github.com/psf/black
rev: 22.10.0
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
2 changes: 1 addition & 1 deletion manifests/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Kustomization

images:
- name: "ghcr.io/lsst-sqre/safirdemo"
newTag: 1.1.0
newTag: 1.2.0

resources:
- configmap.yaml
Expand Down
6 changes: 3 additions & 3 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements/main.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ starlette
uvicorn[standard]

# Other dependencies.
safir
safir>=3.4.0
6 changes: 3 additions & 3 deletions requirements/main.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
48 changes: 21 additions & 27 deletions src/safirdemo/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions src/safirdemo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand Down

0 comments on commit 74ee7a7

Please sign in to comment.