From da7150973d2eff7407250ad85e999448ea39d16e Mon Sep 17 00:00:00 2001 From: Eric Neilsen Date: Fri, 22 Sep 2023 08:34:33 -0700 Subject: [PATCH 1/3] Lot scheduler_dashboard be launched from any cwd --- .../app/scheduler_dashboard/scheduler_dashboard.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/schedview/app/scheduler_dashboard/scheduler_dashboard.py b/schedview/app/scheduler_dashboard/scheduler_dashboard.py index 83ee52ba..72f52b7b 100644 --- a/schedview/app/scheduler_dashboard/scheduler_dashboard.py +++ b/schedview/app/scheduler_dashboard/scheduler_dashboard.py @@ -23,6 +23,7 @@ """schedview docstring""" +import importlib.resources import logging import os import traceback @@ -1453,7 +1454,7 @@ def scheduler_app(date=None, scheduler_pickle=None): return sched_app -if __name__ == "__main__": +def main(): print("Starting scheduler dashboard.") if "SCHEDULER_PORT" in os.environ: @@ -1461,6 +1462,8 @@ def scheduler_app(date=None, scheduler_pickle=None): else: scheduler_port = 8080 + assets_dir = os.path.join(importlib.resources.files("schedview"), "app", "scheduler_dashboard", "assets") + pn.serve( scheduler_app, port=scheduler_port, @@ -1469,5 +1472,9 @@ def scheduler_app(date=None, scheduler_pickle=None): start=True, autoreload=True, threaded=True, - static_dirs={"assets": "./assets"}, + static_dirs={"assets": assets_dir}, ) + + +if __name__ == "__main__": + main() From 7b730ba5b27d8ac03157cfa387263d901f95196a Mon Sep 17 00:00:00 2001 From: Eric Neilsen Date: Fri, 22 Sep 2023 09:00:35 -0700 Subject: [PATCH 2/3] Add project.scripts for starting the prenight and in-night dashboards --- pyproject.toml | 4 ++++ schedview/app/prenight/prenight.py | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 811898c5..090a0173 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,10 @@ classifiers = [ ] dynamic = [ "version" ] +[project.scripts] +prenight = "schedview.app.prenight.prenight:main" +scheduler_dashboard = "schedview.app.scheduler_dashboard.scheduler_dashboard:main" + [tool.setuptools.dynamic] version = { attr = "setuptools_scm.get_version" } diff --git a/schedview/app/prenight/prenight.py b/schedview/app/prenight/prenight.py index 0d1622e9..7b863e2a 100644 --- a/schedview/app/prenight/prenight.py +++ b/schedview/app/prenight/prenight.py @@ -1,5 +1,4 @@ import argparse -import importlib import json import logging import os @@ -977,7 +976,7 @@ def parse_prenight_args(): return prenight_app_parameters -if __name__ == "__main__": +def main(): print("Starting prenight dashboard") prenight_app_parameters = parse_prenight_args() @@ -1004,3 +1003,7 @@ def prenight_app_with_params(): admin=True, profiler=True, ) + + +if __name__ == "__main__": + main() From aede8bee426700fbffe6c92cc776f77611ee5dd6 Mon Sep 17 00:00:00 2001 From: Eric Neilsen Date: Fri, 22 Sep 2023 09:26:21 -0700 Subject: [PATCH 3/3] update usage instructions for new launch scripts --- docs/usage.rst | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index 759197c4..f764000b 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -1,26 +1,36 @@ Usage ===== -Running `sched_maps` +Running `sceduler_dashboard` -------------------- -Activate the environment, and start the `bokeh` app. If `SCHEDVIEW_DIR` is the -directory into which you cloned the `schedview` github repository, then +Activate the conda environment and start the app: :: $ conda activate schedview - $ bokeh serve ${SCHEDVIEW_DIR}/schedview/app/sched_maps + $ scheduler_dashboard The app will then give you the URL at which you can find the app. Running `prenight` ------------------ -Activate the environment, and start the `bokeh` app. If `SCHEDVIEW_DIR` is the -directory into which you cloned the `schedview` github repository, then: +Activate the conda environment and start the app: :: $ conda activate schedview - $ python ${SCHEDVIEW_DIR}/schedview/app/prenight/prenight.py + $ prenight + +The app will then give you the URL at which you can find the app. + +You can also supply an initial set of data files to show on startup: + +:: + $ conda activate schedview + $ prenight --night 2023-10-01 \ + > --opsim_db /sdf/data/rubin/user/neilsen/devel/schedview/schedview/data/sample_opsim.db \ + > --scheduler /sdf/data/rubin/user/neilsen/devel/schedview/schedview/data/sample_scheduler.pickle.xz \ + > --rewards /sdf/data/rubin/user/neilsen/devel/schedview/schedview/data/sample_rewards.h5 \ + > --port 8080