Skip to content

Commit 4e8da95

Browse files
committed
Moved link formatting
1 parent 3cbe7fe commit 4e8da95

File tree

3 files changed

+32
-61
lines changed

3 files changed

+32
-61
lines changed

notebooks_tsqr/NightLog.ipynb

Lines changed: 21 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
"cell_type": "code",
1818
"execution_count": null,
1919
"id": "1",
20-
"metadata": {
21-
"jupyter": {
22-
"source_hidden": true
23-
}
24-
},
20+
"metadata": {},
2521
"outputs": [],
2622
"source": [
2723
"# Parameters.\n",
@@ -52,11 +48,7 @@
5248
"cell_type": "code",
5349
"execution_count": null,
5450
"id": "2",
55-
"metadata": {
56-
"jupyter": {
57-
"source_hidden": true
58-
}
59-
},
51+
"metadata": {},
6052
"outputs": [],
6153
"source": [
6254
"# IMPORT everything\n",
@@ -84,19 +76,15 @@
8476
"from lsst.ts.logging_and_reporting.all_reports import AllReports\n",
8577
"import lsst.ts.logging_and_reporting.utils as ut\n",
8678
"import lsst.ts.logging_and_reporting.time_logs as tl\n",
87-
"from lsst.ts.logging_and_reporting.reports import md, mdlist, mdpathlink\n",
79+
"from lsst.ts.logging_and_reporting.reports import md, mdlist, mdpathlink, mdlink\n",
8880
"from lsst.ts.logging_and_reporting.reports import html_draft, html_beta"
8981
]
9082
},
9183
{
9284
"cell_type": "code",
9385
"execution_count": null,
9486
"id": "3",
95-
"metadata": {
96-
"jupyter": {
97-
"source_hidden": true
98-
}
99-
},
87+
"metadata": {},
10088
"outputs": [],
10189
"source": [
10290
"# Set default env to \"usdf\" and try before PUSH to repo.\n",
@@ -110,11 +98,7 @@
11098
"cell_type": "code",
11199
"execution_count": null,
112100
"id": "4",
113-
"metadata": {
114-
"jupyter": {
115-
"source_hidden": true
116-
}
117-
},
101+
"metadata": {},
118102
"outputs": [],
119103
"source": [
120104
"# Validate parameters, return usable ones\n",
@@ -143,11 +127,7 @@
143127
"cell_type": "code",
144128
"execution_count": null,
145129
"id": "5",
146-
"metadata": {
147-
"jupyter": {
148-
"source_hidden": true
149-
}
150-
},
130+
"metadata": {},
151131
"outputs": [],
152132
"source": [
153133
"# Read records from (almost) all sources\n",
@@ -168,11 +148,7 @@
168148
"cell_type": "code",
169149
"execution_count": null,
170150
"id": "6",
171-
"metadata": {
172-
"jupyter": {
173-
"source_hidden": true
174-
}
175-
},
151+
"metadata": {},
176152
"outputs": [],
177153
"source": [
178154
"instrum_str = \", \".join(list(allsrc.exp_src.instruments.keys()))\n",
@@ -220,11 +196,7 @@
220196
"cell_type": "code",
221197
"execution_count": null,
222198
"id": "9",
223-
"metadata": {
224-
"jupyter": {
225-
"source_hidden": true
226-
}
227-
},
199+
"metadata": {},
228200
"outputs": [],
229201
"source": [
230202
"display(allsrc.alm_src.dataframe)\n",
@@ -330,9 +302,7 @@
330302
{
331303
"cell_type": "markdown",
332304
"id": "18",
333-
"metadata": {
334-
"jp-MarkdownHeadingCollapsed": true
335-
},
305+
"metadata": {},
336306
"source": [
337307
"## Links to related resources <font style=\"background-color:green; color:white; font-size:20px\">BETA</font>\n",
338308
"These tools were created outside of the TSSW Logging and Reporting group. For more information about any of these, please see the respective tool owner."
@@ -354,16 +324,21 @@
354324
"nightsum_link_url = f\"{server}/times-square/github/lsst/schedview_notebooks/nightly/scheduler-nightsum?day_obs={min_date.date()}&visit_origin=lsstcomcam\"\n",
355325
"nightsum_link_string = f\"link to nightsum for day_obs = {min_date.date()}\"\n",
356326
"\n",
327+
"scriptqueue_url = f\"https://usdf-rsp-dev.slac.stanford.edu/times-square/github/lsst/schedview_notebooks/nightly/EvaluateScriptQueue?day_obs_min={min_date.date()}&day_obs_max={max_date.date()}&time_order=newest+first&show_salIndex=all&ts_hide_code=1\"\n",
328+
"\n",
357329
"md(\n",
358330
" f\"\"\"\n",
359331
"#### DDV part of RubinTV\n",
360-
" {ut.link_new_tab(DDV, 'RubinTV Visualization')}\n",
332+
" {mdlink(DDV, 'RubinTV Visualization')}\n",
361333
"\n",
362334
"#### Chronograf links\n",
363-
"{ut.link_new_tab(f'{server}/chronograf','Chronograph main page on {server}')}\n",
335+
"{mdlink(f'{server}/chronograf','Chronograph main page on {server}')}\n",
364336
"\n",
365337
"#### Scheduler Analysis Nightly Summary\n",
366-
"{ut.link_new_tab(nightsum_link_url, nightsum_link_string)}\n",
338+
"{mdlink(nightsum_link_url, nightsum_link_string)}\n",
339+
"\n",
340+
"### Integrated Narrative Log + EFD\n",
341+
"{mdlink(scriptqueue_url, f'ScriptQueue Miner for {min_date.date()}')}\n",
367342
"\n",
368343
"\"\"\"\n",
369344
")"
@@ -383,11 +358,7 @@
383358
"cell_type": "code",
384359
"execution_count": null,
385360
"id": "21",
386-
"metadata": {
387-
"jupyter": {
388-
"source_hidden": true
389-
}
390-
},
361+
"metadata": {},
391362
"outputs": [],
392363
"source": [
393364
"# Exposure Tally (v2)\n",
@@ -477,7 +448,7 @@
477448
"if allsrc.urls:\n",
478449
" text = \"\"\n",
479450
" for url in allsrc.urls:\n",
480-
" text += f\"- {ut.link_new_tab(mdpathlink(url))}\\n\"\n",
451+
" text += f\"- {mdpathlink(url)}\\n\"\n",
481452
" md(text)"
482453
]
483454
},
@@ -497,14 +468,12 @@
497468
" for day, url_list in tickets.items():\n",
498469
" mdstr += f\"\\n - {day}\"\n",
499470
" for ticket_url in url_list:\n",
500-
" mdstr += (\n",
501-
" f'\\n - {ut.link_new_tab(ticket_url, ticket_url.replace(front,\"\"))}'\n",
502-
" )\n",
471+
" mdstr += f'\\n - {mdlink(ticket_url, ticket_url.replace(front,\"\"))}'\n",
503472
" md(mdstr)\n",
504473
"else:\n",
505474
" endpoint_url = allsrc.nig_src.status[\"reports\"][\"endpoint_url\"]\n",
506475
" md(\n",
507-
" f\"No tickets found using: {ut.link_new_tab(endpoint_url,'API Data')} in `confluence_url`.\"\n",
476+
" f\"No tickets found using: {mdlink(endpoint_url,'API Data')} in `confluence_url`.\"\n",
508477
" )"
509478
]
510479
},

python/lsst/ts/logging_and_reporting/reports.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,21 @@ def html_draft(text):
6767
return msg
6868

6969

70+
def mdlink(url, string=None):
71+
"""Wrap link in html to open link in new tab, must be used in an md()"""
72+
string = url if string is None else string
73+
html = f'<a href="{url}" target="_blank" rel="noreferrer noopener">{string}</a>'
74+
return html
75+
76+
7077
def mdpathlink(url, remove="/browse/"):
71-
return f"[{urlparse(url).path.replace(remove, '')}]({url})"
78+
string = urlparse(url).path.replace(remove, "")
79+
return mdlink(string)
7280

7381

7482
def mdfragmentlink(url, remove="!/"):
75-
return f"[{urlparse(url).fragment.replace(remove, '')}]({url})"
83+
string = urlparse(url).fragment.replace(remove, "")
84+
return mdlink(string)
7685

7786

7887
def display_error(text, fgcolor="black", bgcolor="red", size="1em"):

python/lsst/ts/logging_and_reporting/utils.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,6 @@ def hhmmss(decimal_hours):
196196
return f"{hours:d}:{minutes:02d}:{seconds:02d}"
197197

198198

199-
def link_new_tab(url, string=None):
200-
"""Wrap links in html to open all links in new tab, must be used in md()"""
201-
string = url if string is None else string
202-
html = f'<a href="{url}" target="_blank" rel="noreferrer noopener">{string}</a>'
203-
return html
204-
205-
206199
def tic():
207200
"""Start timer."""
208201
tic.start = time.perf_counter()

0 commit comments

Comments
 (0)