Skip to content

Commit

Permalink
Merge pull request #280 from lsst-sqre/tickets/DM-45281
Browse files Browse the repository at this point in the history
DM-45281: Separate safir-arq from safir
  • Loading branch information
rra authored Jul 25, 2024
2 parents f83776b + 55a5bd2 commit a44029a
Show file tree
Hide file tree
Showing 45 changed files with 108 additions and 97 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,20 @@ jobs:
with:
fetch-depth: 0 # full history for setuptools_scm

- name: Build and publish
- name: Test building and publishing safir
uses: lsst-sqre/build-and-publish-to-pypi@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
upload: false
working-directory: "safir"

- name: Test building and publishing safir-arq
uses: lsst-sqre/build-and-publish-to-pypi@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
upload: false
working-directory: "safir-arq"

pypi:

name: Upload release to PyPI
Expand All @@ -137,3 +144,8 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}
working-directory: "safir"

- uses: lsst-sqre/build-and-publish-to-pypi@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
working-directory: "safir-arq"
45 changes: 0 additions & 45 deletions Makefile

This file was deleted.

3 changes: 3 additions & 0 deletions changelog.d/20240724_155805_rra_DM_45281.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### New features

- `safir.arq` is now available as a separate PyPI package, `safir-arq`, so that it can be installed in environments where the full Safir dependency may be too heavy-weight or conflict with other packages. The `safir[arq]` dependency will continue to work as before (by installing `safir-arq` behind the scenes).
8 changes: 7 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
def _install(session: nox.Session) -> None:
"""Install the application and all dependencies into the session."""
session.install("--upgrade", "uv")
session.install("-e", "./safir[arq,db,dev,gcs,kubernetes,redis]")
session.install(
"-e", "./safir-arq", "./safir[arq,db,dev,gcs,kubernetes,redis]"
)


def _install_dev(session: nox.Session, bin_prefix: str = "") -> None:
Expand Down Expand Up @@ -105,9 +107,13 @@ def typing(session: nox.Session) -> None:
session.run(
"mypy",
*session.posargs,
"--namespace-packages",
"--explicit-package-bases",
"noxfile.py",
"safir/src",
"safir-arq/src",
"safir/tests",
env={"MYPYPATH": "safir/src:safir:safir-arq/src"},
)


Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extend = "ruff-shared.toml"
"noxfile.py" = [
"T201", # print makes sense as output from nox rules
]
"safir/src/safir/**" = [
"*/src/safir/**" = [
"N818", # Exception is correct in some cases, others are part of API
]
"safir/src/safir/testing/**" = [
Expand All @@ -70,6 +70,7 @@ extend = "ruff-shared.toml"
]

[tool.ruff.lint.isort]
detect-same-package = false
known-first-party = ["safir", "tests"]
split-on-trailing-comma = false

Expand Down
1 change: 1 addition & 0 deletions safir-arq/LICENSE
13 changes: 13 additions & 0 deletions safir-arq/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# safir-arq

safir-arq is a subpackage of Safir, Rubin Observatory's library for building [FastAPI](https://fastapi.tiangolo.com/) services for the [Rubin Science Platform (Phalanx)](https://github.com/lsst-sqre/phalanx) and [Roundtable](https://github.com/lsst-sqre/roundtable) Kubernetes clusters.
It is a separate PyPI module so that it can be used as a dependency in contexts where the full Safir dependency is undesirable.

safir-arq is available from [PyPI](https://pypi.org/project/safir-arq/):

```sh
pip install safir-arq
```

safir-arq is developed and tested in conjunction with Safir.
Read more about Safir at https://safir.lsst.io.
51 changes: 51 additions & 0 deletions safir-arq/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[project]
# https://packaging.python.org/en/latest/specifications/declaring-project-metadata/
name = "safir-arq"
description = "arq support for the Rubin Observatory SQuaRE framework, Safir."
license = {file = "LICENSE"}
readme= "README.md"
keywords = [
"rubin",
"lsst",
]
# https://pypi.org/classifiers/
classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Intended Audience :: Developers",
"Natural Language :: English",
"Operating System :: POSIX",
"Typing :: Typed",
]
requires-python = ">=3.11"
dependencies = [
"arq>=0.23,<1",
"pydantic>2,<3",
"pydantic-core",
]
dynamic = ["version"]

[[project.authors]]
name = "Association of Universities for Research in Astronomy, Inc. (AURA)"
email = "[email protected]"

[project.urls]
Homepage = "https://safir.lsst.io"
Source = "https://github.com/lsst-sqre/safir"
"Change log" = "https://safir.lsst.io/changelog.html"
"Issue tracker" = "https://github.com/lsst-sqre/safir/issues"

[build-system]
requires = [
"setuptools>=61",
"wheel",
"setuptools_scm[toml]>=6.2"
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
root = ".."
14 changes: 6 additions & 8 deletions safir/src/safir/arq.py → safir-arq/src/safir/arq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import asyncio
import uuid
from dataclasses import dataclass
from datetime import datetime
from datetime import UTC, datetime
from enum import Enum
from typing import Any, Self

Expand All @@ -17,8 +17,6 @@
from pydantic import SecretStr
from pydantic_core import Url

from .datetime import current_datetime

__all__ = [
"ArqJobError",
"JobNotQueued",
Expand Down Expand Up @@ -515,7 +513,7 @@ async def enqueue(
name=task_name,
args=task_args,
kwargs=task_kwargs,
enqueue_time=current_datetime(microseconds=True),
enqueue_time=datetime.now(tz=UTC),
status=JobStatus.queued,
queue_name=queue_name,
)
Expand Down Expand Up @@ -545,8 +543,8 @@ async def abort_job(
kwargs=job_metadata.kwargs,
status=job_metadata.status,
enqueue_time=job_metadata.enqueue_time,
start_time=current_datetime(microseconds=True),
finish_time=current_datetime(microseconds=True),
start_time=datetime.now(tz=UTC),
finish_time=datetime.now(tz=UTC),
result=asyncio.CancelledError(),
success=False,
queue_name=queue_name,
Expand Down Expand Up @@ -614,8 +612,8 @@ async def set_complete(
kwargs=job_metadata.kwargs,
status=job_metadata.status,
enqueue_time=job_metadata.enqueue_time,
start_time=current_datetime(microseconds=True),
finish_time=current_datetime(microseconds=True),
start_time=datetime.now(tz=UTC),
finish_time=datetime.now(tz=UTC),
result=result,
success=success,
queue_name=queue_name,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion safir/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dynamic = ["version"]

[project.optional-dependencies]
arq = [
"arq>=0.23,<1"
"safir-arq",
]
db = [
"asyncpg<1",
Expand Down
22 changes: 0 additions & 22 deletions safir/src/safir/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from types import EllipsisType
from typing import Generic, ParamSpec, TypeVar

from .datetime import current_datetime
from safir.datetime import current_datetime

#: Parameter spec for functions decorated by `run_with_asyncio`.
P = ParamSpec("P")
Expand Down
Empty file.
File renamed without changes.
Empty file added safir/src/safir/click/py.typed
Empty file.
Empty file.
File renamed without changes.
Empty file.
2 changes: 1 addition & 1 deletion safir/src/safir/dependencies/arq.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from arq.connections import RedisSettings

from ..arq import ArqMode, ArqQueue, MockArqQueue, RedisArqQueue
from safir.arq import ArqMode, ArqQueue, MockArqQueue, RedisArqQueue

__all__ = ["ArqDependency", "arq_dependency"]

Expand Down
2 changes: 1 addition & 1 deletion safir/src/safir/dependencies/db_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pydantic import SecretStr
from sqlalchemy.ext.asyncio import AsyncEngine, async_scoped_session

from ..database import create_async_session, create_database_engine
from safir.database import create_async_session, create_database_engine

__all__ = ["DatabaseSessionDependency", "db_session_dependency"]

Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from fastapi import Request, status
from fastapi.responses import JSONResponse

from .models import ErrorLocation
from .slack.webhook import SlackIgnoredException
from safir.models import ErrorLocation
from safir.slack.webhook import SlackIgnoredException

__all__ = [
"ClientRequestError",
Expand Down
Empty file.
File renamed without changes.
Empty file added safir/src/safir/gcs/py.typed
Empty file.
Empty file added safir/src/safir/github/py.typed
Empty file.
File renamed without changes.
Empty file.
File renamed without changes.
Empty file.
File renamed without changes.
Empty file.
Empty file.
File renamed without changes.
Empty file added safir/src/safir/models/py.typed
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
)
from pydantic_core import Url

from .datetime import parse_timedelta
from safir.datetime import parse_timedelta

P = ParamSpec("P")
T = TypeVar("T")
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from cryptography.fernet import Fernet
from pydantic import BaseModel

from .slack.blockkit import (
from safir.slack.blockkit import (
SlackCodeBlock,
SlackException,
SlackMessage,
Expand Down
Empty file added safir/src/safir/redis/py.typed
Empty file.
Empty file added safir/src/safir/slack/py.typed
Empty file.
5 changes: 3 additions & 2 deletions safir/src/safir/slack/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
from starlette.exceptions import HTTPException as StarletteHTTPException
from structlog.stdlib import BoundLogger

from ..datetime import current_datetime, format_datetime_for_logging
from ..dependencies.http_client import http_client_dependency
from safir.datetime import current_datetime, format_datetime_for_logging
from safir.dependencies.http_client import http_client_dependency

from .blockkit import (
SlackCodeBlock,
SlackException,
Expand Down
2 changes: 1 addition & 1 deletion safir/src/safir/testing/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
V1Status,
)

from ..asyncio import AsyncMultiQueue
from safir.asyncio import AsyncMultiQueue

__all__ = [
"MockKubernetesApi",
Expand Down
Empty file.
8 changes: 0 additions & 8 deletions safir/tests/safir_test.py

This file was deleted.

0 comments on commit a44029a

Please sign in to comment.