Skip to content

Commit

Permalink
Add metadata to the root endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrondel committed Jan 14, 2025
1 parent edf7b06 commit a5bcd54
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Extract Git Tag or Branch
id: git_info
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "GIT_TAG=${{ github.ref_name }}" >> $GITHUB_TAG
else
echo "GIT_TAG=noversion" >> $GITHUB_TAG
fi
- name: Build hinfo
uses: lsst-sqre/build-and-push-to-ghcr@v1
with:
Expand All @@ -31,3 +40,5 @@ jobs:
image: ${{ github.repository }}-pq
github_token: ${{ secrets.GITHUB_TOKEN }}
dockerfile: Dockerfile.pqserver
build-args: |
GITHUB_TAG=${{ env.GITHUB_TAG }}
4 changes: 4 additions & 0 deletions Dockerfile.pqserver
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM python:3.11

ARG GITHUB_TAG
ENV VERSION=${GITHUB_TAG}

RUN pip install fastapi safir astropy uvicorn gunicorn sqlalchemy psycopg2
WORKDIR /
COPY \
Expand Down
14 changes: 13 additions & 1 deletion python/lsst/consdb/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Configuration(BaseSettings):

name: str = Field("pqserver", title="Application name")

version: str = Field("noversion", title="Application version number")
version: str | None = Field(None, title="Application version number")

url_prefix: str = Field("/consdb", title="URL prefix")

Expand Down Expand Up @@ -46,6 +46,18 @@ class Configuration(BaseSettings):

consdb_url: str | None = Field(None, title="Database URL set by CONSDB_URL")

description: str | None = Field(
"A web interface to the Rubin Observatory Consolidated Database.", title="Application description."
)

repository_url: str | None = Field(
"https://github.com/lsst-dm/consdb", title="Source repository for this code."
)

documentation_url: str | None = Field(
"https://consdb.lsst.io/index.html", title="URL for documentation of this project."
)

@property
def database_url(self) -> str:
"""Infers the database URL based on the provided configuration.
Expand Down
3 changes: 3 additions & 0 deletions python/lsst/consdb/handlers/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ def external_root(
return IndexResponseModel(
name=config.name,
version=config.version,
description=config.description,
repository_url=config.repository_url,
documentation_url=config.documentation_url,
instruments=instrument_list,
obs_types=[o.value for o in ObsTypeEnum],
dtypes=[d.value for d in AllowedFlexTypeEnum],
Expand Down
8 changes: 4 additions & 4 deletions python/lsst/consdb/handlers/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def internal_root(
return IndexResponseModel.model_validate(
{
"name": config.name,
"version": "0.0.0", # TODO: insert an actual version number
"description": "A web interface to the Rubin Observatory Consolidated Database.",
"repository_url": "https://github.com/lsst-db/consdb",
"documentation_url": "https://consdb.lsst.io/index.html",
"version": config.version,
"description": config.description,
"repository_url": config.repository_url,
"documentation_url": config.documentation_url,
"instruments": instrument_list,
"obs_types": [o.value for o in ObsTypeEnum],
"dtypes": [d.value for d in AllowedFlexTypeEnum],
Expand Down

0 comments on commit a5bcd54

Please sign in to comment.