Skip to content

Commit

Permalink
Merge pull request #229 from lsst-ts/tickets/DM-47287
Browse files Browse the repository at this point in the history
DM-47287: Add installation of rubin_exp_checker
  • Loading branch information
ugyballoons authored Dec 11, 2024
2 parents db78c1f + 2fdb1f7 commit 27de2fe
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
26 changes: 24 additions & 2 deletions python/lsst/ts/rubintv/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from . import __version__
from .background.currentpoller import CurrentPoller
from .background.historicaldata import HistoricalPoller
from .config import config
from .config import config, rubintv_logger
from .handlers.api import api_router
from .handlers.ddv_routes_handler import ddv_router
from .handlers.ddv_websocket_handler import ddv_client_ws_router, internal_ws_router
Expand All @@ -33,6 +33,17 @@
from .models.models_init import ModelsInitiator
from .s3client import S3Client

logger = rubintv_logger()

exp_checker_installed = False
try:
from lsst.ts.exp_checker import app as exp_checker_app

logger.info("exp_checker is mounted")
exp_checker_installed = True
except (ModuleNotFoundError, ImportError):
logger.warn("exp-checker not found. Not mounting.")

__all__ = ["app", "config"]


Expand All @@ -59,7 +70,14 @@ async def lifespan(app: FastAPI) -> AsyncGenerator:
today_polling = asyncio.create_task(cp.poll_buckets_for_todays_data())
historical_polling = asyncio.create_task(hp.check_for_new_day())

yield
# Startup phase for the subapp
if exp_checker_installed and exp_checker_app.router.lifespan:
async with exp_checker_app.router.lifespan_context(exp_checker_app):
yield # Yield to the main app with subapp context active

# If no lifespan is needed for the subapp, still yield to the main app
else:
yield

historical_polling.cancel()
today_polling.cancel()
Expand Down Expand Up @@ -114,6 +132,10 @@ def create_app() -> FastAPI:
# Provide router that hooks up ddv/index.html
app.include_router(ddv_router, prefix=f"{config.path_prefix}/ddv")

# Mount exp_checker FastAPI app.
if exp_checker_installed:
app.mount(f"{config.path_prefix}/exp_checker", exp_checker_app)

# Attach the routers.

# Internal routing:
Expand Down
12 changes: 12 additions & 0 deletions scripts/install-exp_checker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
# Exit on error.
set -e

# Display each command as it's run.
set -x

cd /usr/src/rubintv
git clone https://github.com/lsst-sitcom/rubin_exp_checker.git exp_checker
cd exp_checker
pip install -e .
pip install -r requirements.txt
1 change: 1 addition & 0 deletions start-daemon.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
sh ./scripts/build-flutter-app.sh
sh ./scripts/install-exp_checker.sh
run_rubintv

0 comments on commit 27de2fe

Please sign in to comment.