Skip to content

Commit

Permalink
chore: update ruff formatting, remove pause, fixup actions
Browse files Browse the repository at this point in the history
  • Loading branch information
tcjennings committed Jan 16, 2025
1 parent 4465fa8 commit 27b7f05
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 77 deletions.
44 changes: 16 additions & 28 deletions .github/workflows/build_and_push.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
# A workflow that builds and (optionally) pushes the Docker container image
# artifacts for the application. The build action occurs on pull request events
# that target the `main` branch, and the push action occurs only with tagged releases
# and ticket branches.
# A workflow that builds and pushes the Docker container image artifacts for
# the application. The action occurs on new tags and when called from another
# workflow.
---
name: "Build and Push"

"on":
pull_request:
branches:
- main
paths:
- 'src/lsst/cmservice/**'
push:
tags:
- "*"
workflow_call:
workflow_dispatch:

jobs:
ci:
uses:
./.github/workflows/ci.yaml

build:
name: "Build and Push Application Container Images"
needs:
- ci
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- target: cmservice
image: ${{ github.repository_owner }}/cm-service
- target: cmworker
image: ${{ github.repository_owner }}/cm-worker
timeout-minutes: 20

steps:
Expand All @@ -34,19 +31,10 @@ jobs:
fetch-depth: 0

- uses: lsst-sqre/build-and-push-to-ghcr@v1
id: build-service
with:
dockerfile: docker/Dockerfile
target: cmservice
image: ${{ github.repository }}
target: ${{ matrix.target }}
platforms: linux/amd64,linux/arm64
image: ${{ matrix.image }}
github_token: ${{ secrets.GITHUB_TOKEN }}
push: ${{ github.ref_type == 'tag' || (github.ref_type == 'branch' && startsWith(github.ref_name, 'tickets/DM-')) }}

- uses: lsst-sqre/build-and-push-to-ghcr@v1
id: build-worker
with:
dockerfile: docker/Dockerfile
target: cmworker
image: ${{ github.repository }}
github_token: ${{ secrets.GITHUB_TOKEN }}
push: ${{ github.ref_type == 'tag' || (github.ref_type == 'branch' && startsWith(github.ref_name, 'tickets/DM-')) }}
push: true
44 changes: 31 additions & 13 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# and when called from another workflow.
---
name: "CI"

"on":
workflow_call:
push:
Expand All @@ -13,8 +14,14 @@ env:
UV_FROZEN: "1"

jobs:
rebase-checker:
uses:
./.github/workflows/rebase_checker.yaml

lint:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04-arm
needs:
- rebase-checker
steps:

- name: Checkout Repository
Expand All @@ -28,50 +35,61 @@ jobs:
- name: Run pre-commit
uses: pre-commit/action@v3.0.1

test:
runs-on: ubuntu-latest
mypy:
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ["3.11"]
needs:
- rebase-checker
steps:

- name: Checkout Repository
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.5.x"
enable_cache: true
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: Install packages for testing
run: uv sync --dev --frozen

- name: Run tests
run: |
uv run playwright install
uv run make test
run: uv run make typing

mypy:
runs-on: ubuntu-latest
test:
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ["3.11"]

needs:
- lint
- mypy
steps:

- name: Checkout Repository
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.5.x"
enable_cache: true
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: Install packages for testing
run: uv sync --dev --frozen

- name: Run tests
run: uv run make typing
run: |
uv run playwright install
uv run make test
build-and-push:
needs:
- test
if: ${{ startsWith(github.ref_name, 'tickets/DM-') }}
uses: ./.github/workflows/build_and_push.yaml
3 changes: 2 additions & 1 deletion .github/workflows/rebase_checker.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
name: Rebase Checker

on: pull_request
"on":
workflow_call:

jobs:
call-workflow:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:

jobs:
release:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04-arm
timeout-minutes: 10
if: >-
github.event_name == 'pull_request'
Expand Down
4 changes: 2 additions & 2 deletions src/lsst/cmservice/client/queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from __future__ import annotations

from datetime import datetime, timedelta
from time import sleep
from typing import TYPE_CHECKING

import httpx
import pause
from pydantic import TypeAdapter, ValidationError

from .. import db, models
Expand Down Expand Up @@ -133,7 +133,7 @@ def pause_until_next_check(
# In unit tests we set queue.interval to zero
# so don't ever get to these lines
print("pausing")
pause.until(next_check)
sleep(sleep_time)

def daemon(
self,
Expand Down
4 changes: 1 addition & 3 deletions src/lsst/cmservice/handlers/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ async def _write_script(
pass

# build up the bps wrapper script
command = (
f"{config.bps.bps_bin} --log-file {json_url} --no-log-tty submit " f"{config_path} > {log_url}"
)
command = f"{config.bps.bps_bin} --log-file {json_url} --no-log-tty submit {config_path} > {log_url}"

prepend = bps_core_script_template_.data["text"].replace("{lsst_version}", lsst_version) # type: ignore
prepend = prepend.replace("{lsst_distrib_dir}", lsst_distrib_dir)
Expand Down
4 changes: 2 additions & 2 deletions src/lsst/cmservice/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ async def lifespan(app: FastAPI) -> AsyncGenerator:
lifespan=lifespan,
title=config.asgi.title,
version=__version__,
openapi_url="/openapi.json",
openapi_url="/docs/openapi.json",
openapi_tags=tags_metadata,
docs_url="/docs",
redoc_url="/redoc",
redoc_url=None,
)

app.add_middleware(XForwardedMiddleware)
Expand Down
25 changes: 5 additions & 20 deletions tests/cli/util_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,7 @@ def check_update_methods(
) -> None:
result = runner.invoke(
client_top,
f"{entry_class_name} update data_dict "
"--output yaml "
f"--row_id {entry.id} "
"--update_dict test:dummy",
f"{entry_class_name} update data_dict --output yaml --row_id {entry.id} --update_dict test:dummy",
)
check = check_and_parse_result(result, dict)
assert check["test"] == "dummy", "update_data_dict failed"
Expand All @@ -267,10 +264,7 @@ def check_update_methods(

result = runner.invoke(
client_top,
f"{entry_class_name} update collections "
"--output yaml "
f"--row_id {entry.id} "
"--update_dict test:dummy",
f"{entry_class_name} update collections --output yaml --row_id {entry.id} --update_dict test:dummy",
)
check = check_and_parse_result(result, dict)
assert check["test"] == "dummy", "update_collections failed"
Expand Down Expand Up @@ -303,20 +297,14 @@ def check_update_methods(

result = runner.invoke(
client_top,
f"{entry_class_name} update child_config "
f"--row_id {entry.id} "
"--output yaml "
"--update_dict test:dummy",
f"{entry_class_name} update child_config --row_id {entry.id} --output yaml --update_dict test:dummy",
)
check = check_and_parse_result(result, dict)
assert check["test"] == "dummy", "update_child_config failed"

result = runner.invoke(
client_top,
f"{entry_class_name} update child_config "
f"--row_id -1 "
"--output yaml "
"--update_dict test:dummy",
f"{entry_class_name} update child_config --row_id -1 --output yaml --update_dict test:dummy",
)
expect_failed_result(result, 1)

Expand All @@ -331,10 +319,7 @@ def check_update_methods(

result = runner.invoke(
client_top,
f"{entry_class_name} update spec_aliases "
"--output yaml "
f"--row_id {entry.id} "
"--update_dict test:dummy",
f"{entry_class_name} update spec_aliases --output yaml --row_id {entry.id} --update_dict test:dummy",
)
# FIXME: is this the return type we want?
check_spec = check_and_parse_result(result, entry_class)
Expand Down
12 changes: 6 additions & 6 deletions tests/db/test_pipetask_error_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ async def test_error_match_db(engine: AsyncEngine) -> None:
# Here we test that the same error with a different pipetask name will
# not match. Let's consider the same error, but on task "isr"

assert (
e1.match("isr", known_error["diagnostic_message"]) is False
), "Failure to identify non-matching pipetask name"
assert e1.match("isr", known_error["diagnostic_message"]) is False, (
"Failure to identify non-matching pipetask name"
)

# Here we test that the same pipetask name but different error does not
# match.
assert (
e1.match(known_error["task_name"], "A different error message") is False
), "Failure to identify separate errors with the same associated pipetask"
assert e1.match(known_error["task_name"], "A different error message") is False, (
"Failure to identify separate errors with the same associated pipetask"
)

# Here we test that a different valid PipetaskError does not match to
# the wrong PipetaskErrorType
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 27b7f05

Please sign in to comment.