Skip to content

Commit

Permalink
add VERBOSE param for diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
pothiers committed Nov 11, 2024
1 parent ca209f2 commit fa0290f
Show file tree
Hide file tree
Showing 7 changed files with 3,111 additions and 663 deletions.
12 changes: 1 addition & 11 deletions notebooks_tsqr/ExposureDetail.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,7 @@
"execution_count": 4,
"id": "a78b6f36-12a3-4f76-806a-ee0805c89318",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"DEBUG add_exposure_flag instrument='LSSTComCamSim' set()\n",
"DEBUG add_exposure_flag instrument='LSSTComCam' set()\n",
"DEBUG add_exposure_flag instrument='LATISS' {'unknown', 'questionable'}\n"
]
}
],
"outputs": [],
"source": [
"src_exp = sad.ExposurelogAdapter(\n",
" server_url=server,\n",
Expand Down
3,671 changes: 3,088 additions & 583 deletions notebooks_tsqr/NightLog.ipynb

Large diffs are not rendered by default.

12 changes: 3 additions & 9 deletions notebooks_tsqr/NightLog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,8 @@ parameters:
default: 1
minimum: 1
maximum: 9
exp_parsing:
verbose:
type: boolean
description: >
Enable experimental parsing of error messages pasted into logs.
default: true
exp_tally:
type: boolean
description: >
Enable experimental tally of exposures with specific values of
selected fields.
default: true
Enable verbose output. (Generally for development use.)
default: false
45 changes: 2 additions & 43 deletions notebooks_tsqr/dashboard.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion python/lsst/ts/logging_and_reporting/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Dashboard: # TODO Move to its own file (utils.py).
we need for any of our sources.
"""

timeout = (5.05, 2) # connect, read (seconds)
timeout = (3.05, 2) # connect, read (seconds)

envs = dict( # key, server
summit="https://summit-lsp.lsst.codes",
Expand Down
10 changes: 7 additions & 3 deletions python/lsst/ts/logging_and_reporting/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def md(markdown_str, color=None, background=None):
fg = f"color:{color};" if color else ""
bg = f"background-color:{background};"
newtxt = f'<font style="{fg}{bg}">{markdown_str}</font>'
print(f"{newtxt=}")
display(Markdown(newtxt))
else:
display(Markdown(markdown_str))
Expand Down Expand Up @@ -149,7 +148,7 @@ def overview(self):
print(md(f'- Endpoint: {status["endpoint_url"]}'))
print(f"- {result} {more}")

def time_log_as_markdown(self, zero_message=False):
def time_log_as_markdown(self, zero_message=True):
"""Emit markdown for a date-time log."""
adapter = self.source_adapter
records = adapter.records
Expand All @@ -160,7 +159,12 @@ def time_log_as_markdown(self, zero_message=False):
if zero_message:
service = adapter.service
url = adapter.get_status().get("endpoint_url")
md(f"No {service} records found.", color="lightblue")
msg = (
f"No {service} records found "
f"{adapter.min_dayobs} to {adapter.max_dayobs}. "
# f"status={adapter.status}"
)
md(msg, color="lightblue")
md(f"Used [API Data]({url})")


Expand Down
22 changes: 9 additions & 13 deletions python/lsst/ts/logging_and_reporting/source_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import pandas as pd
import requests

MAX_CONNECT_TIMEOUT = 5.1 # seconds
MAX_CONNECT_TIMEOUT = 7.05 # seconds
MAX_READ_TIMEOUT = 180 # seconds
summit = "https://summit-lsp.lsst.codes"
usdf = "https://usdf-rsp-dev.slac.stanford.edu"
Expand Down Expand Up @@ -88,7 +88,8 @@ def invalid_response(response, endpoint_url, timeout=None, verbose=False):
# other sources may not.
# raise ex.StatusError(msg)
rep.display_error(msg)
msg2 = "".join(traceback.format_stack(limit=4))
msg2 = "TRACEBACK (4 levels)\n"
msg2 += "".join(traceback.format_stack(limit=4))
rep.display_error(msg2)
return msg

Expand All @@ -107,8 +108,8 @@ def __init__(
min_dayobs=None, # INCLUSIVE: default=max_dayobs - 1 day
offset=0,
limit=None, # max records to read in one API call
connect_timeout=1.05, # seconds
read_timeout=2, # seconds
connect_timeout=5.05, # seconds
read_timeout=20, # seconds
verbose=False,
):
"""Load the relevant data for the Source.
Expand Down Expand Up @@ -442,24 +443,19 @@ def get_records(
if len(page) < self.limit:
break # we defintely got all we asked for
qparams["offset"] += len(page)
# except Exception as err:
# if self.verbose:
# print(f"DBG NightLog.get_records error: {err!r}")
#
# recs = []
# # error = f"{response.text=} Exception={err}"
# error = f"{self.__class__.__name__} {url=} Exception={err}"

self.keep_fields(recs, self.outfields)

if recs and self.verbose:
print(f"DBG get_records-2 {len(page)=} {len(recs)=}")
self.records = recs
status = dict(
endpoint_url=url,
number_of_records=len(recs),
error=error,
)
if recs and self.verbose:
print(f"DBG get_records-2 {len(page)=} {len(recs)=}")
print(f"DBG get_records-2 {len(self.records)=} {status=}")

return status

def nightly_tickets(self):
Expand Down

0 comments on commit fa0290f

Please sign in to comment.