Skip to content

Commit

Permalink
handle PARSED_NL in narrative log
Browse files Browse the repository at this point in the history
  • Loading branch information
pothiers committed Oct 28, 2024
1 parent 3a88a17 commit d037378
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 34 deletions.
14 changes: 3 additions & 11 deletions notebooks_tsqr/NightLog.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"# 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-25' # Value to use for local testing (Summit)\n",
"day_obs = \"2024-09-25\" # TODO Change to 'YESTERDAY' to test with default before push\n",
"day_obs = \"YESTERDAY\" # TODO Change to 'YESTERDAY' to test with default before push\n",
"\n",
"# Total number of days of data to display (ending on day_obs)\n",
"number_of_days = \"1\" # TODO Change to '1' to test with default before push"
Expand Down Expand Up @@ -67,11 +67,7 @@
"cell_type": "code",
"execution_count": null,
"id": "3",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"metadata": {},
"outputs": [],
"source": [
"# Normalize Parameters (both explicit Times Squares params, in implicit ones)\n",
Expand Down Expand Up @@ -103,11 +99,7 @@
"cell_type": "code",
"execution_count": null,
"id": "4",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"metadata": {},
"outputs": [],
"source": [
"# Set default env to \"usdf\" and try before PUSH to repo.\n",
Expand Down
27 changes: 4 additions & 23 deletions python/lsst/ts/logging_and_reporting/parse_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,12 @@

import lsst.ts.logging_and_reporting.reports as rep


def ignore_this(): # TODO remove
allsrc = all.AllSources(
server_url="https://summit-lsp.lsst.codes",
min_dayobs="2024-08-02",
max_dayobs="2024-10-21",
)

eidx = [
idx
for idx, r in enumerate(allsrc.nar_src.records[:125])
if "Error:" in r["message_text"]
]

allsrc.nar_src.records[eidx[6]]["message_text"]

re_err = re.compile(r"^.*(Error:.*)", re.DOTALL | re.DEBUG | re.MULTILINE)

re_err.match(allsrc.nar_src.records[eidx[6]]["message_text"]).group(1)
# => "Error: msg='Command failed', ackcmd=(ackcmd private_seqNum=1579091411, ack=<SalRetCode.CMD_FAILED: -302>, error=1, result='Failed: wavefrontError write(private_revCode: cdb25a59, private_sndStamp: 1725582543.3115678, private_rcvStamp: 0.0, private_seqNum: 1, private_identity: MTAOS, private_origin: 3159695, sensorId: 0, annularZernikeCoeff: 0.08561753960450617) failed: probably at least one array field is too short')\r\n" # noqa: E501


# Start after whitespace before error. End at string end.
# BLACK work-around
flags = re.DOTALL | re.ASCII | re.MULTILINE | re.IGNORECASE
re_err = re.compile(r"(?P<err>\S*error:.*)", flags=flags)
re_tb = re.compile(r"\b(Traceback \(most recent call last\):.*)", flags=flags)
re_pnl = re.compile(r"&lt;PARSED_NL&gt;", flags=re.ASCII | re.MULTILINE)


def highlight_code(matchobj):
Expand All @@ -53,6 +32,8 @@ def markup_errors(records, src_field="message_text"):

# #!re.search('|'.join([re_err, re_tb])
# #!new = re_err.sub(highlight_code, orig)
new = re_tb.sub(highlight_code, orig)

new = re_pnl.sub("<br>", orig)
new = re_tb.sub(highlight_code, new)
if orig != new:
r[dest_field] = new

0 comments on commit d037378

Please sign in to comment.