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-40149: Rewrite RubinTV with FastAPI #154

Merged
merged 64 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
0eca88b
Start afresh
ugyballoons Jun 27, 2023
a8b1dc1
Add flake8 config
ugyballoons Jun 27, 2023
05926db
Use match in buckethandler
ugyballoons Jun 27, 2023
8d2df29
Include GCS auth in tox tests
ugyballoons Jun 28, 2023
ae81a40
Update GHA/CI script
ugyballoons Jun 28, 2023
8aa002a
Pass in GCS creds to GHA
ugyballoons Jun 28, 2023
8597066
First attempt to add table api
ugyballoons Jun 28, 2023
ffea26c
Add TMA defaults and tooltips
ugyballoons Jun 28, 2023
62fc1c3
Add TMA to Tucson
ugyballoons Jun 29, 2023
758101d
Bump up to pydantic v2
ugyballoons Jul 17, 2023
009310d
Add mock bucket and Event parsing
ugyballoons Jul 21, 2023
53dc3e7
First attempt adding background bucket polling
ugyballoons Jul 24, 2023
6d1ae7d
Remove GCS creds
ugyballoons Jul 24, 2023
9c1f63c
Refactor api routing
ugyballoons Jul 25, 2023
7010171
Add websocket server for updating camera channels
ugyballoons Jul 27, 2023
af9b13a
Move moto to main from dev and rebuild deps
mfisherlevine Aug 7, 2023
3fb5cf9
Remove current camera check in tests
ugyballoons Aug 10, 2023
9b1db3c
Add static assets to manifest
ugyballoons Aug 10, 2023
0b90e04
Add /rubintv to static mount
ugyballoons Aug 14, 2023
7298d4d
fix repo references
athornton Aug 15, 2023
7ab56eb
Add metadata polling
ugyballoons Aug 23, 2023
41ca8fb
Begin adding night report filtering
ugyballoons Aug 30, 2023
a33eac3
Update .nvmrc to v18.17.1
ugyballoons Aug 30, 2023
b8caf45
First pass s3 historical poller
ugyballoons Sep 13, 2023
8cf4edf
Add historical poller and mock testing
ugyballoons Sep 18, 2023
8280df4
Run app and background tasks concurrently
ugyballoons Sep 22, 2023
aaed58d
Add get single event page
ugyballoons Sep 23, 2023
4245dc6
Begin adding historical page
ugyballoons Sep 30, 2023
5c1f757
Merge per day channels into general channels
ugyballoons Sep 30, 2023
0dd718d
Finish adding historical page
ugyballoons Oct 2, 2023
02a2bb5
Begin adding night reports to current
ugyballoons Oct 3, 2023
4a2b09c
Add night report links
ugyballoons Oct 4, 2023
da5a94e
Add allsky pages
ugyballoons Oct 4, 2023
0c80b67
Add night report pages
ugyballoons Oct 4, 2023
7c1cc22
Get existing js working
ugyballoons Oct 6, 2023
84f253d
Sure-up websocket service
ugyballoons Oct 11, 2023
af64013
Add template for no data & fix table scroll
ugyballoons Oct 11, 2023
31e4937
Add js websocket client class
ugyballoons Oct 12, 2023
e2a6325
First attempt React draws table
ugyballoons Oct 16, 2023
7d6f73c
Add React-driven table controls
ugyballoons Oct 18, 2023
ae5f475
Add current event updating
ugyballoons Oct 18, 2023
3297995
First attempt at table refresh via websocket
ugyballoons Oct 18, 2023
48cd8fd
Fix allsky video streaming
ugyballoons Oct 18, 2023
115c37f
Fix AuxTel page not displaying just movies
ugyballoons Oct 18, 2023
af8f564
Fix table not updating
ugyballoons Oct 20, 2023
68340c7
Fix data getting to suit AllSky too
ugyballoons Oct 20, 2023
1cb9cf9
Fix historical data not being stored
ugyballoons Oct 23, 2023
adb75dd
Add React-rendered night report
ugyballoons Oct 24, 2023
0b61024
Add dict button/modal to table
ugyballoons Oct 24, 2023
da8c161
Add updating to current allsky
ugyballoons Oct 24, 2023
cce128d
Add admin page
ugyballoons Oct 25, 2023
157e57a
Fix new event breaking currentpoller
ugyballoons Oct 26, 2023
a16932c
Convert Per Day to use React for updates
ugyballoons Oct 26, 2023
ec72b12
Bring channel colour into yaml
ugyballoons Nov 6, 2023
389ebe3
Add clock to tables
ugyballoons Nov 6, 2023
d5d8cb9
Change AllSky channels to per-day
ugyballoons Nov 6, 2023
e60ff81
Add location aware code
ugyballoons Nov 23, 2023
8df1f63
Add PropTypes for all components
ugyballoons Nov 24, 2023
3a56507
Change image repo to point to `lsst-ts` space
sebastian-aranda Nov 30, 2023
dd02016
Add BTS location
sebastian-aranda Dec 14, 2023
e0dbb45
Finish making recommended changes (PR #154)
ugyballoons Dec 14, 2023
9cfbe61
Adjust tests after locations refactor
sebastian-aranda Dec 14, 2023
e63897c
Remove redundant js logging
ugyballoons Dec 20, 2023
e213db1
Clean-up merge with v1
ugyballoons Dec 21, 2023
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
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env", "@babel/preset-react"]
}
7 changes: 7 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[flake8]
max-line-length = 79
# E203: whitespace before :, flake8 disagrees with PEP-8
# W503: line break after binary operator, flake8 disagrees with PEP-8
ignore = E203, W503
exclude =
docs/conf.py
86 changes: 37 additions & 49 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
name: CI

'on':
"on":
merge_group: {}
pull_request: {}
push:
branches-ignore:
# These should always correspond to pull requests, so ignore them for
# the push trigger and let them be triggered by the pull_request
# trigger, avoiding running the workflow twice. This is a minor
# optimization so there's no need to ensure this is comprehensive.
- 'dependabot/**'
- 'renovate/**'
- 'tickets/**'
- 'u/**'
- "dependabot/**"
- "gh-readonly-queue/**"
- "renovate/**"
- "tickets/**"
- "u/**"
tags:
- '*'
pull_request: {}
- "*"

jobs:
test:
runs-on: ubuntu-latest
lint:

strategy:
matrix:
python:
- '3.9'
- '3.10'
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- uses: actions/checkout@v3
Expand All @@ -42,48 +40,45 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
python-version: "3.11"

- name: Run pre-commit
uses: pre-commit/[email protected]

- name: Install tox
run: pip install tox
test:

runs-on: ubuntu-latest
timeout-minutes: 10

- 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') }}-

- name: Stash Google credentials
run: echo "$GOOGLE_CREDS" > /tmp/google_creds.json
shell: bash
env:
GOOGLE_CREDS: ${{ secrets.GOOGLE_CREDS }}
strategy:
matrix:
python:
- "3.11"

steps:
- uses: actions/checkout@v3

- name: Run tox
run: tox -e py,coverage-report,typing
env:
GOOGLE_APPLICATION_CREDENTIALS: '/tmp/google_creds.json'
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]
timeout-minutes: 10

# Only do Docker builds of tagged releases and pull requests from ticket
# branches. This will still trigger on pull requests from untrusted
# repositories whose branch names match our tickets/* branch convention,
# but in this case the build will fail with an error since the secret
# won't be set.
if: >
startsWith(github.ref, 'refs/tags/') || startsWith(github.head_ref, 'tickets/') || startsWith(github.ref, 'refs/heads/develop')

github.event_name != 'merge_group'
&& (startsWith(github.ref, 'refs/tags/')
|| startsWith(github.head_ref, 'tickets/'))

steps:
- uses: actions/checkout@v3
Expand All @@ -102,7 +97,7 @@ jobs:

- name: Define the Docker tag
id: vars
run: echo "tag=$(scripts/docker-tag.sh)" >> $GITHUB_OUTPUT
run: echo ::set-output name=tag::$(scripts/docker-tag.sh)

- name: Print the tag
id: print
Expand All @@ -111,12 +106,6 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
Expand All @@ -125,12 +114,11 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: |
lsstsqre/rubintv:${{ steps.vars.outputs.tag }}
ghcr.io/lsst-sqre/rubintv:${{ steps.vars.outputs.tag }}
ghcr.io/lsst-ts/rubintv:${{ steps.vars.outputs.tag }}
cache-from: type=gha
cache-to: type=gha,mode=max
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ jsconfig.json
*.ipynb

# npm and eslint
.nvmrc
*/jsconfig.json
.eslintrc.*
node_modules/
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v19.6.0
v18.17.1
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rubintv2
21 changes: 11 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# - Runs a non-root user.
# - Sets up the entrypoint and port.

FROM python:3.10.7-slim-buster AS base-image
FROM python:3.11.1-slim-bullseye AS base-image

# Update system packages
COPY scripts/install-base-packages.sh .
Expand All @@ -38,30 +38,31 @@ RUN pip install --upgrade --no-cache-dir pip setuptools wheel
COPY requirements/main.txt ./requirements.txt
RUN pip install --quiet --no-cache-dir -r requirements.txt

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

# Use the virtualenv
COPY --from=dependencies-image /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

COPY . /app
WORKDIR /app
COPY . /workdir
WORKDIR /workdir
RUN pip install --no-cache-dir .

FROM base-image AS runtime-image

# Create a non-root user
RUN useradd --create-home appuser
WORKDIR /home/appuser

# Copy the virtualenv
COPY --from=install-image /opt/venv /opt/venv

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

COPY --from=install-image /opt/venv /opt/venv

# Switch to non-root user
# Switch to the non-root user.
USER appuser

# Expose the port.
EXPOSE 8080

ENTRYPOINT ["rubintv", "run", "--port", "8080"]
# Run the application.
CMD ["uvicorn", "rubintv.main:app", "--host", "0.0.0.0", "--port", "8080"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2023 Association of Universities for Research in Astronomy, Inc. (AURA)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include src/rubintv/models/models_data.yaml
graft src/rubintv/static/assets
15 changes: 11 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
.PHONY: update-deps
update-deps:
pip install --upgrade pip-tools pip setuptools
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
pip-compile --upgrade --resolver=backtracking --build-isolation --generate-hashes --output-file requirements/main.txt requirements/main.in
pip-compile --upgrade --resolver=backtracking --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 --resolver=backtracking --build-isolation --allow-unsafe --output-file requirements/main.txt requirements/main.in
pip-compile --upgrade --resolver=backtracking --build-isolation --allow-unsafe --output-file requirements/dev.txt requirements/dev.in

.PHONY: init
init:
pip install --editable .
pip install --upgrade -r requirements/main.txt -r requirements/dev.txt
rm -rf .tox
pip install --upgrade tox
pip install --upgrade pre-commit tox
pre-commit install

.PHONY: update
update: update-deps init

.PHONY: run
run:
adev runserver --app-factory create_app src/rubintv/app.py
tox run -e run
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# rubintv

Web app to display Butler-served data sets
Learn more at https://rubintv.lsst.io

rubintv is developed with [FastAPI](https://fastapi.tiangolo.com) and [Safir](https://safir.lsst.io).
8 changes: 0 additions & 8 deletions README.rst

This file was deleted.

12 changes: 0 additions & 12 deletions manifests/base/configmap.yaml

This file was deleted.

46 changes: 0 additions & 46 deletions manifests/base/deployment.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions manifests/base/kustomization.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions manifests/base/service.yaml

This file was deleted.

Loading
Loading