Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-45906: Create app that can use Butler to implement IVOA SIAv2 protocol #3

Merged
merged 9 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-toml
- id: check-yaml
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.5
rev: v0.6.9
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
35 changes: 17 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
# This Dockerfile has four stages:
# This Dockerfile has three stages:
#
# base-image
# Updates the base Python image with security patches and common system
# packages. This image becomes the base of all other images.
# dependencies-image
# Installs third-party dependencies (requirements/main.txt) into a virtual
# environment. This virtual environment is ideal for copying across build
# stages.
# install-image
# Installs the app into the virtual environment.
# Installs third-party dependencies (requirements/main.txt) and the
# application into a virtual environment. This virtual environment is
# ideal for copying across build stages.
# runtime-image
# - Copies the virtual environment into place.
# - Runs a non-root user.
# - Sets up the entrypoint and port.

FROM python:3.12.7-slim-bookworm as base-image
FROM python:3.12.7-slim-bookworm AS base-image

# Update system packages
COPY scripts/install-base-packages.sh .
RUN ./install-base-packages.sh && rm ./install-base-packages.sh

FROM base-image AS dependencies-image
FROM base-image AS install-image

# Install uv.
COPY --from=ghcr.io/astral-sh/uv:0.4.9 /uv /bin/uv

# Install system packages only needed for building dependencies.
COPY scripts/install-dependency-packages.sh .
Expand All @@ -29,23 +30,19 @@ RUN ./install-dependency-packages.sh
# Create a Python virtual environment
ENV VIRTUAL_ENV=/opt/venv
RUN python -m venv $VIRTUAL_ENV

# Make sure we use the virtualenv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Put the latest pip and setuptools in the virtualenv
RUN pip install --upgrade --no-cache-dir pip setuptools wheel

# Install the app's Python runtime dependencies
COPY requirements/main.txt ./requirements.txt
RUN pip install --quiet --no-cache-dir -r requirements.txt

FROM dependencies-image AS install-image

# Use the virtualenv
ENV PATH="/opt/venv/bin:$PATH"
RUN uv pip install --compile-bytecode --verify-hashes --no-cache \
-r requirements.txt

# Install the application.
COPY . /workdir
WORKDIR /workdir
RUN pip install --no-cache-dir .
RUN uv pip install --compile-bytecode --no-cache .

FROM base-image AS runtime-image

Expand All @@ -55,6 +52,8 @@ RUN useradd --create-home appuser
# Copy the virtualenv
COPY --from=install-image /opt/venv /opt/venv

WORKDIR /app

# Make sure we use the virtualenv
ENV PATH="/opt/venv/bin:$PATH"

Expand All @@ -65,4 +64,4 @@ USER appuser
EXPOSE 8080

# Run the application.
CMD ["uvicorn", "vosiav2.main:app", "--host", "0.0.0.0", "--port", "8080"]
CMD ["uvicorn", "sia.main:app", "--host", "0.0.0.0", "--port", "8080"]
21 changes: 5 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: help
help:
@echo "Make targets for vo-siav2"
@echo "Make targets for example"
@echo "make init - Set up dev environment"
@echo "make run - Start a local development instance"
@echo "make update - Update pinned dependencies and run make init"
Expand Down Expand Up @@ -29,20 +29,9 @@ update-deps:
pip install --upgrade uv
uv pip install --upgrade pre-commit
pre-commit autoupdate
uv pip compile --upgrade --generate-hashes \
uv pip compile --upgrade --universal --generate-hashes \
--output-file requirements/main.txt requirements/main.in
uv pip compile --upgrade --generate-hashes \
uv pip compile --upgrade --universal --generate-hashes \
--output-file requirements/dev.txt requirements/dev.in
uv pip compile --upgrade --generate-hashes \
--output-file requirements/tox.txt requirements/tox.in

# Useful for testing against a Git version of Safir.
.PHONY: update-deps-no-hashes
update-deps-no-hashes:
pip install --upgrade uv
uv pip compile --upgrade \
--output-file requirements/main.txt requirements/main.in
uv pip compile --upgrade \
--output-file requirements/dev.txt requirements/dev.in
uv pip compile --upgrade \
--output-file requirements/tox.txt requirements/tox.in
uv pip compile --upgrade --universal --generate-hashes \
--output-file requirements/tox.txt requirements/tox.in
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# vo-siav2
# SIA

Rubin Observatory SIAV2 implementation over Butler
Learn more at https://vo-siav2.lsst.io
SIA is an implementation of the IVOA [Simple Image Access v2](https://www.ivoa.net/documents/SIA/20150610/PR-SIA-2.0-20150610.pdf) protocol as a [FastAPI](https://fastapi.tiangolo.com/) web service, designed to be deployed as part of the Rubin Science Platform.

The default configuration uses the [dax_obscore](https://github.com/lsst-dm/dax_obscore) package and interacts with a [Butler](https://github.com/lsst/daf_butler) repository to find images matching specific criteria.


While the current release supports both remote and direct (local) Butler repositories, our primary focus has been on the Remote Butler, resulting in more mature support for this option.

Query results are streamed to the user as VOTable responses, which is currently the only supported format.

The application expects as part of the configuration a list of Butler Data Collections, each of which expects a number of attributes which define how to access the repository.

The system architecture & design considerations have been documented in https://github.com/lsst-sqre/sqr-095.

See [CHANGELOG.md](https://github.com/lsst-sqre/sia/blob/main/CHANGELOG.md) for the change history of sia.

vo-siav2 is developed with [FastAPI](https://fastapi.tiangolo.com) and [Safir](https://safir.lsst.io).
20 changes: 12 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
# https://packaging.python.org/en/latest/specifications/declaring-project-metadata/
name = "vo-siav2"
description = "Rubin Observatory SIAV2 implementation over Butler"
name = "sia"
description = "Rubin Observatory SIA implementation over Butler"
license = { file = "LICENSE" }
readme = "README.md"
keywords = ["rubin", "lsst"]
Expand All @@ -23,22 +23,25 @@ dependencies = []
dynamic = ["version"]

[project.scripts]
vo-siav2 = "vosiav2.cli:main"
sia = "sia.cli:main"

[project.urls]
Homepage = "https://vo-siav2.lsst.io"
Source = "https://github.com/lsst-sqre/vo-siav2"
Homepage = "https://sia.lsst.io"
Source = "https://github.com/lsst-sqre/sia"

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

[tool.setuptools_scm]

[tool.setuptools.package-data]
"sia" = ["templates/*.xml"]

[tool.coverage.run]
parallel = true
branch = true
source = ["vosiav2"]
source = ["sia"]

[tool.coverage.paths]
source = ["src", ".tox/*/site-packages"]
Expand All @@ -62,7 +65,7 @@ disallow_untyped_defs = true
disallow_incomplete_defs = true
ignore_missing_imports = true
local_partial_types = true
plugins = ["pydantic.mypy"]
plugins = ["pydantic.mypy","pydantic_xml.mypy"]
no_implicit_reexport = true
show_error_codes = true
strict_equality = true
Expand All @@ -87,6 +90,7 @@ asyncio_mode = "strict"
# with complex data structures rather than only the assert message) in files
# listed in python_files.
python_files = ["tests/*.py", "tests/*/*.py"]
asyncio_default_fixture_loop_scope = "function"

# Use the generic Ruff configuration in ruff.toml and extend it with only
# project-specific settings. Add a [tool.ruff.lint.extend-per-file-ignores]
Expand All @@ -95,7 +99,7 @@ python_files = ["tests/*.py", "tests/*/*.py"]
extend = "ruff-shared.toml"

[tool.ruff.lint.isort]
known-first-party = ["vosiav2", "tests"]
known-first-party = ["sia", "tests"]
split-on-trailing-comma = false

[tool.scriv]
Expand Down
Loading