Skip to content

Commit

Permalink
Merge pull request #22 from lsst/tickets/PREOPS-3776
Browse files Browse the repository at this point in the history
Tickets/preops 3776
  • Loading branch information
ehneilsen committed Sep 25, 2023
2 parents 0e345a6 + aede8be commit 9299242
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
24 changes: 17 additions & 7 deletions docs/usage.rst
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand Down
7 changes: 5 additions & 2 deletions schedview/app/prenight/prenight.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import argparse
import importlib
import json
import logging
import os
Expand Down Expand Up @@ -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()
Expand All @@ -1004,3 +1003,7 @@ def prenight_app_with_params():
admin=True,
profiler=True,
)


if __name__ == "__main__":
main()
11 changes: 9 additions & 2 deletions schedview/app/scheduler_dashboard/scheduler_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

"""schedview docstring"""

import importlib.resources
import logging
import os
import traceback
Expand Down Expand Up @@ -1453,14 +1454,16 @@ 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:
scheduler_port = int(os.environ["SCHEDULER_PORT"])
else:
scheduler_port = 8080

assets_dir = os.path.join(importlib.resources.files("schedview"), "app", "scheduler_dashboard", "assets")

pn.serve(
scheduler_app,
port=scheduler_port,
Expand All @@ -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()

0 comments on commit 9299242

Please sign in to comment.