Skip to content

Commit

Permalink
add used_endpoints method for include in notebook overview
Browse files Browse the repository at this point in the history
  • Loading branch information
pothiers committed Sep 18, 2024
1 parent 04abf5d commit a1d138c
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 49 deletions.
119 changes: 70 additions & 49 deletions notebooks_tsqr/NightLog.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,22 @@
"\n",
"# day_obs values: TODAY, YESTERDAY, YYYY-MM-DD\n",
"# Report on observing nights that start upto but not included this day.\n",
"day_obs = '2024-09-04' # Value to use for local testing (Summit)\n",
"#!day_obs = 'TODAY' # TODO Change to 'TODAY' to test with default before push \n",
"#!day_obs = '2024-09-18' # Value to use for local testing (Summit)\n",
"day_obs = 'TODAY' # TODO Change to 'TODAY' to test with default before push \n",
"\n",
"# Total number of days of data to display (ending on day_obs)\n",
"number_of_days = '2' # TODO Change to '1' to test with default before push "
"number_of_days = '3' # TODO Change to '1' to test with default before push "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2",
"metadata": {},
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"outputs": [],
"source": [
"# Only use packages available in the Rubin Science Platform\n",
Expand All @@ -48,16 +52,8 @@
"from matplotlib import pyplot as plt\n",
"import os\n",
"from datetime import datetime, date, timedelta\n",
"#! from rubin_scheduler.site_models import Almanac"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3",
"metadata": {},
"outputs": [],
"source": [
"#! from rubin_scheduler.site_models import Almanac\n",
"\n",
"# Normalize Parameters (both explicit Times Squares params, in implicit ones)\n",
"limit = 50 # YAGNI: Auto get more if this isn't enough to get all requested DAYS\n",
"\n",
Expand All @@ -83,7 +79,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4",
"id": "3",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -100,8 +96,12 @@
{
"cell_type": "code",
"execution_count": null,
"id": "5",
"metadata": {},
"id": "4",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"outputs": [],
"source": [
"# When running under Times Square, install pkg from github.\n",
Expand All @@ -112,16 +112,8 @@
"import lsst.ts.logging_and_reporting.source_adapters as sad\n",
"import lsst.ts.logging_and_reporting.almanac as alm\n",
"import lsst.ts.logging_and_reporting.reports as rep \n",
"from lsst.ts.logging_and_reporting.reports import md,mdlist, NightlyLogReport"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6",
"metadata": {},
"outputs": [],
"source": [
"from lsst.ts.logging_and_reporting.reports import md,mdlist, NightlyLogReport\n",
"\n",
"try:\n",
" import lsst.ts.logging_and_reporting.version\n",
" lrversion = lsst.ts.logging_and_reporting.version.__version__\n",
Expand All @@ -137,15 +129,15 @@
},
{
"cell_type": "markdown",
"id": "7",
"id": "5",
"metadata": {},
"source": [
"# Overview"
]
},
{
"cell_type": "markdown",
"id": "8",
"id": "6",
"metadata": {},
"source": [
"The only environment that has everything needed for this page is\n",
Expand All @@ -157,7 +149,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9",
"id": "7",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -166,12 +158,25 @@
"Report for **{date}** covering the previous **{days}** observing night(s).\n",
"- Run on logs from **{server}/**\n",
"- Using *Prototype* Logging and Reporting Version: **{lrversion}**\n",
"''')"
"''')\n",
"\n",
"ul = '\\n- '.join(['',*sad.all_endpoints(server)])\n",
"md(f'This report will attempt to use the following log sources: {ul}')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8",
"metadata": {},
"outputs": [],
"source": [
"print()"
]
},
{
"cell_type": "markdown",
"id": "10",
"id": "9",
"metadata": {},
"source": [
"# Almanac"
Expand All @@ -180,7 +185,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "11",
"id": "10",
"metadata": {
"jupyter": {
"source_hidden": true
Expand All @@ -194,7 +199,7 @@
},
{
"cell_type": "markdown",
"id": "12",
"id": "11",
"metadata": {},
"source": [
"# Night Report"
Expand All @@ -203,8 +208,12 @@
{
"cell_type": "code",
"execution_count": null,
"id": "13",
"metadata": {},
"id": "12",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"outputs": [],
"source": [
"# Get data from Night Report log. Display nightly Jira BLOCKS.\n",
Expand Down Expand Up @@ -245,7 +254,7 @@
},
{
"cell_type": "markdown",
"id": "14",
"id": "13",
"metadata": {},
"source": [
"# Exposure Log"
Expand All @@ -254,8 +263,12 @@
{
"cell_type": "code",
"execution_count": null,
"id": "15",
"metadata": {},
"id": "14",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"outputs": [],
"source": [
"# Get data from Exposure log. Display time log.\n",
Expand Down Expand Up @@ -285,7 +298,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "16",
"id": "15",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -295,8 +308,12 @@
{
"cell_type": "code",
"execution_count": null,
"id": "17",
"metadata": {},
"id": "16",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"outputs": [],
"source": [
"# Display Observation gaps\n",
Expand All @@ -318,7 +335,7 @@
},
{
"cell_type": "markdown",
"id": "18",
"id": "17",
"metadata": {},
"source": [
"# Narrative Log\n"
Expand All @@ -327,8 +344,12 @@
{
"cell_type": "code",
"execution_count": null,
"id": "19",
"metadata": {},
"id": "18",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"outputs": [],
"source": [
"# Get data from Narrative log. Display time log.\n",
Expand Down Expand Up @@ -368,12 +389,12 @@
{
"cell_type": "code",
"execution_count": null,
"id": "20",
"id": "19",
"metadata": {},
"outputs": [],
"source": [
"# Conditionally display our current ability to connect to all needed endpoints.\n",
"if False and not os.environ.get('EXTERNAL_INSTANCE_URL'):\n",
"if not os.environ.get('EXTERNAL_INSTANCE_URL'):\n",
" md('# Dashboard')\n",
" md('(This is not done when running under Times Square.)')\n",
" %run ./dashboard.ipynb"
Expand All @@ -382,7 +403,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "21",
"id": "20",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -392,7 +413,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "22",
"id": "21",
"metadata": {},
"outputs": [],
"source": []
Expand Down
18 changes: 18 additions & 0 deletions python/lsst/ts/logging_and_reporting/source_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
MAX_READ_TIMEOUT = 180 # seconds


def all_endpoints(server):
endpoints = itertools.chain.from_iterable(
[sa(server_url=server).used_endpoints() for sa in adapters]
)
return list(endpoints)

class SourceAdapter(ABC):
"""Abstract Base Class for all source adapters.
"""
Expand Down Expand Up @@ -137,6 +143,12 @@ def obs_date(rec):
def source_url(self):
return f'{self.server}/{self.service}'

def used_endpoints(self):
used = list()
for ep in self.endpoints:
used.append(f'{self.server}/{self.service}/{ep}')
return used

def check_endpoints(self, timeout=None, verbose=True):
to = (timeout or self.timeout)
if verbose:
Expand Down Expand Up @@ -369,6 +381,7 @@ def row_str_func(self, datetime_str, rec):
f"| <pre>{rec['message_text']}</pre>"
)


def check_endpoints(self, timeout=None, verbose=True):
to = (timeout or self.timeout)
if verbose:
Expand Down Expand Up @@ -488,3 +501,8 @@ def get_observation_gaps(self, instruments=None):

return inst_day_rollup
# END: class ExposurelogAdapter

adapters = [ExposurelogAdapter,
NarrativelogAdapter,
NightReportAdapter,
]

0 comments on commit a1d138c

Please sign in to comment.