Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prototype into Develop 9/19 #26

Merged
merged 71 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
26ef1db
Added utils to support timing
pothiers Sep 6, 2024
3d6c056
Combine n Narrative and Exposure logs into NightLog, strip it to simp…
pothiers Sep 9, 2024
3906d20
working sources_dashboard
pothiers Sep 10, 2024
4887e48
prettier dashboard report
pothiers Sep 10, 2024
0a37497
recs name change and pasted source_adapters.py to NightLog
pothiers Sep 10, 2024
c27c8ca
Use USDF and outfields
pothiers Sep 10, 2024
5f17fac
Merge branch 'develop' into tickets/DM-46136
pothiers Sep 10, 2024
ae1691c
try to make notebooks disappear form Times Square
pothiers Sep 10, 2024
9fba943
WIP
pothiers Sep 11, 2024
7eb067a
WIP
pothiers Sep 12, 2024
e72d2ce
WIP
pothiers Sep 12, 2024
e224dba
WIP
pothiers Sep 12, 2024
6112206
WIP
pothiers Sep 13, 2024
57afd45
Display version
pothiers Sep 13, 2024
3bebc79
WIP
pothiers Sep 13, 2024
5afbf11
WIP
pothiers Sep 13, 2024
04f6641
WIP
pothiers Sep 13, 2024
b8bd681
WIP
pothiers Sep 13, 2024
db48d9d
Add draft Almanac
pothiers Sep 13, 2024
8dba2c1
Add draft Almanac
pothiers Sep 13, 2024
ee5e6b5
Add draft Almanac
pothiers Sep 13, 2024
1c878ef
WIP
pothiers Sep 13, 2024
bd03528
more almanac
pothiers Sep 14, 2024
5f35793
more almanac
pothiers Sep 14, 2024
4ba93d0
Add hyperlinks to BLOCK tickets
pothiers Sep 15, 2024
43d4524
minor fix
pothiers Sep 15, 2024
05adf9c
WIP
pothiers Sep 15, 2024
61e5d65
replace removed conditional for pip install
pothiers Sep 15, 2024
7c3df28
date-time log table cleanup
pothiers Sep 16, 2024
dbf830f
wip
pothiers Sep 16, 2024
28d3a81
cleaner tables
pothiers Sep 16, 2024
83a61e0
WIP
pothiers Sep 17, 2024
04abf5d
add telescope column to Exposure log
pothiers Sep 17, 2024
a1d138c
add used_endpoints method for include in notebook overview
pothiers Sep 18, 2024
2745ee4
updated requirements to add things that were being imported
Vebop Sep 18, 2024
e339ab3
Unsure how this version gets set but I updated it
Vebop Sep 18, 2024
0ddcf64
adding back two notebooks from other branch
Vebop Sep 18, 2024
90d22ff
attempting to add reference to run nb from nightlog
Vebop Sep 18, 2024
994756d
issues with importing from lsst.summit.utils
Vebop Sep 18, 2024
df588aa
issues with importing from lsst.summit.utils
Vebop Sep 18, 2024
c28a754
adding yaml for assorted plots
Vebop Sep 18, 2024
0ad97b2
Adding debugable prints
Vebop Sep 18, 2024
26ea2d4
Adding debugable prints
Vebop Sep 18, 2024
07d264e
added params to yaml
Vebop Sep 18, 2024
a396c0c
removing errors from Nightlog
Vebop Sep 18, 2024
09d8543
adding small edits
Vebop Sep 18, 2024
f1361f9
trying to apply pr comments
Vebop Sep 18, 2024
cca18f1
looping over provided instruments
Vebop Sep 18, 2024
7c75c50
Added DDV to Nightlog, Organized assorted plots for move to backend
Vebop Sep 19, 2024
2a95cf1
Added readme noting our development process and repository strucutre
Vebop Sep 19, 2024
668769c
Merge pull request #25 from lsst-ts/tickets/dm-46175-proto
Vebop Sep 19, 2024
0b40c40
parameter update
Vebop Sep 19, 2024
88ea259
Dashboard gives sample data for all endpoints
pothiers Sep 19, 2024
3de3eac
Dashboard gives sample data for all endpoints
pothiers Sep 19, 2024
0d8d58f
after lesser refactor to aid report
pothiers Sep 19, 2024
2361aeb
fixing prints
Vebop Sep 19, 2024
5c8bcf9
updated prints again
Vebop Sep 19, 2024
997917d
not sure why plots aren't showing in TS
Vebop Sep 19, 2024
e2fdba8
refactor, error handling, exceptions
pothiers Sep 20, 2024
750bf07
Merge branch 'report-design' into prototype
pothiers Sep 20, 2024
758ef48
Updated the different URL for DDV
Vebop Sep 20, 2024
423de1a
remove inline to see if plots show
Vebop Sep 23, 2024
17a59f8
cleaning up empty cells
Vebop Sep 23, 2024
99d3050
new plot attempt
Vebop Sep 23, 2024
ccbc7a7
adding inline back in
Vebop Sep 23, 2024
4165221
separate from the loop and function
Vebop Sep 23, 2024
5fc66b6
changes per PR review
pothiers Sep 24, 2024
6335eb9
trying another plot thing
Vebop Sep 24, 2024
697ac6b
removing old files that have been integrated to NightLog nb
Vebop Sep 24, 2024
d01286d
applying some PR comments
Vebop Sep 24, 2024
009c04e
Merge branch 'develop' into prototype
Vebop Sep 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
809 changes: 206 additions & 603 deletions notebooks_tsqr/NightLog.ipynb

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions notebooks_tsqr/NightLog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ tags:
- prototype
- exposure
parameters:
record_limit:
type: integer
description: Max number of records to output
default: 99
minimum: 1
maximum: 9999
day_obs:
type: string
description: The night to report on. (YYYY-MM-DD, TODAY, YESTERDAY)
description: >
The night to report on. (Allowed: YYYY-MM-DD, TODAY, YESTERDAY)
The report will include days upto, but not including, day_obs.
For a value of TODAY, the last observing night that will be
included in the report will be the one that started yesterday.
This is usually what you want.
default: "TODAY"
number_of_days:
type: integer
description: Number of days to show (ending in day_obs)
description: >
Number of days to show in the report.
default: 1
minimum: 1
maximum: 9
61 changes: 57 additions & 4 deletions notebooks_tsqr/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,58 @@
Times Square notebooks for (potential) use in project-wide Logging & Reporting
# Logging & Reporting Times Square Notebooks

See [offical
documentation](https://rsp.lsst.io/v/usdfdev/guides/times-square/index.html)
on creating notebooks for use by Times Square.
Notebooks found here `./notebooks/` are meant to be run in Times Square towards use in project-wide Nightly Logging & Reporting
Times-Square: <https://usdf-rsp-dev.slac.stanford.edu/times-square>

See [official Times-Square documentation](https://rsp.lsst.io/v/usdfdev/guides/times-square/index.html) on creating notebooks for use by Times Square.

## Development Guidelines

Rapid Prototyping is enabled with the branch `prototype`
Times-Square for this repository displays the `prototype` branch.

- Create a branch for your Jira Ticket in the format `tickets/dm-####` off of `prototype`
- Communicate often with team mate when you want to push changes to `prototype`
- Rebase your branch off `prototype` before merging your branch into `prototype`

Example of flow:

1. `git checkout prototype; git pull`
2. `git checkout -b tickets/dm-23456`
3. `git commit -m "work happened"; git push`
4. `git checkout prototype; git pull`
5. `git checkout tickets/dm-23456`
6. `git rebase prototype`
7. `git checkout prototype; git merge tickets/dm-23456; git push`

&nbsp;

Once Per Sprint (2 week), the developers on this repository (Steve Pothier & Valerie Becker) gather to discuss updates made to `prototype`, outstanding pull requests, and tickets that have been completed.

Once they are in agreement, they merge `prototype` into the `develop` branch and close the related Jira Tickets. Squash commit should be used here with a descriptive title and description in the PR.


## NightLog.ipynb

NightLog.ipynb is our main Logging And Reporting notebook. This notebook is meant to display completed* views of logging information.
Each separate notebook should be used to mature a logging/reporting product, and then expect to be integrated into this 'main' notebook.

\*_Completed to an alpha\beta level -- quick improvements will continue to happen during Fall-Winter 2024_

## Dashboard

Dashboard.ipynb is intended for local development purposes and debugging. Run this notebook not from RSP to evaluate your connection to an array of data sources.
_RSP is not intended to have access to all of the data sources queried here._

## Kernel

Times Square developers/maintainers have indicated that the LSST Kernel should be used in notebooks displayed there.
[RSP Stack info](https://developer.lsst.io/stack/conda.html#rubin-science-platform-notebooks)

## Backend Code

We are working our way into a non-Times-Square dependent project. Towards that effort, we are incrementally abstracting common code out of the notebooks. This code is kept in `./python/lsst/ts/logging_and_reporting/`

`almanac.py` ...
`reports.py` ...
`source_adapters.py` ....
`utils.py` is used for ...
81 changes: 40 additions & 41 deletions notebooks_tsqr/consdb/access_consdb.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,22 @@
"source": [
Vebop marked this conversation as resolved.
Show resolved Hide resolved
"import os\n",
"from lsst.summit.utils import ConsDbClient\n",
"from lsst.summit.utils.utils import computeCcdExposureId\n",
"import sqlalchemy\n",
"import requests\n",
"import pandas as pd\n",
"from IPython.display import display, Markdown, display_markdown\n",
"\n",
"\n",
"URL = \"https://usdf-rsp.slac.stanford.edu/consdb/\" # Need to add that part about the headers to client flow through\n",
"# URL = \"https://usdf-rsp.slac.stanford.edu/consdb/\"\n",
"# Need to add that part about the headers to client flow through\n",
"URL = \"http://consdb-pq.consdb:8080/consdb\" # Don't use this one\n",
"\n",
"os.environ[\"no_proxy\"] += \",.consdb\"\n",
"\n",
"access_token = os.getenv(\"ACCESS_TOKEN\")\n",
"headers = {\"Authorization\": f\"Bearer {access_token}\"}\n",
"\n",
"sesh = requests.Session()\n",
"sesh.headers.update(headers)\n",
"# This is how the session object should access the ACCESS Token from the headers\n",
"#sesh = requests.Session()\n",
"#sesh.headers.update(headers)\n",
"\n",
"%matplotlib inline"
]
Expand All @@ -58,17 +57,13 @@
"metadata": {},
"outputs": [],
"source": [
"display_markdown('## Attempting to access Consolidated Database', raw=True)\n",
"\n",
"try:\n",
" from lsst.summit.utils import ConsDbClient\n",
" have_consdb = True\n",
"except ImportError:\n",
" have_consdb = False\n",
"\n",
"if have_consdb:\n",
" client = ConsDbClient(URL)\n",
" display_markdown('## Consolidated Database is accessible',raw=True)\n"
"from lsst.summit.utils import ConsDbClient\n",
"client = ConsDbClient(URL)\n",
"print(client)\n",
"#import sqlalchemy\n",
"#connection = sqlalchemy.create_engine('postgresql://[email protected]/exposurelog')\n",
"#print(connection)\n",
"display_markdown('### Consolidated Database is accessible',raw=True)"
]
},
{
Expand All @@ -87,7 +82,6 @@
"metadata": {},
"outputs": [],
"source": [
"# Add consdb\n",
"day_obs_int = int(day_obs.replace('-', ''))\n",
"\n",
"visit_query1 = f'''\n",
Expand All @@ -114,31 +108,33 @@
" WHERE v.day_obs = {day_obs_int} and q.visit_id = v.visit_id\n",
"'''\n",
"\n",
"if have_consdb:\n",
" # Potentially print some schema information for debugging\n",
" \n",
"# Potentially print some schema information for debugging\n",
"try:\n",
" print(client.schema()) # list the instruments\n",
" print(client.schema('latiss')) # list tables for an instrument\n",
" print(client.schema('latiss', 'cdb_latiss.exposure_flexdata')) # specifically flexdata table\n",
" \n",
" try:\n",
" visits_latiss = consdb.query(visit_query1).to_pandas()\n",
" visits_lsstcc = consdb.query(visit_query2).to_pandas()\n",
" visits_lsstccs = consdb.query(visit_query3).to_pandas()\n",
"except requests.HTTPError or requests.JSONDecodeError:\n",
" print(client.schema()) # list the instruments\n",
" print(client.schema('latiss')) # list tables for an instrument\n",
" print(client.schema('latiss', 'cdb_latiss.exposure_flexdata'))\n",
"\n",
"try:\n",
" visits_latiss = client.query(visit_query1).to_pandas()\n",
" visits_lsstcc = client.query(visit_query2).to_pandas()\n",
" visits_lsstccs = client.query(visit_query3).to_pandas()\n",
"\n",
" except requests.HTTPError or requests.JSONDecodeError:\n",
" # Try twice\n",
" visits_latiss = consdb.query(visit_query1).to_pandas()\n",
" visits_lsstcc = consdb.query(visit_query2).to_pandas()\n",
" visits_lsstccs = consdb.query(visit_query3).to_pandas()\n",
"except requests.HTTPError or requests.JSONDecodeError:\n",
" # Try twice\n",
" visits_latiss = client.query(visit_query1).to_pandas()\n",
" visits_lsstcc = client.query(visit_query2).to_pandas()\n",
" visits_lsstccs = client.query(visit_query3).to_pandas()\n",
"\n",
" quicklook = consdb.query(quicklook_query).to_pandas()\n",
"quicklook = client.query(quicklook_query).to_pandas()\n",
"\n",
"else:\n",
" # Assumes at the USDF\n",
" connection = sqlalchemy.create_engine('postgresql://[email protected]/exposurelog')\n",
" visits_latiss = pd.read_sql(visit_query1, connection)\n",
" quicklook = pd.read_sql(quicklook_query, connection)\n",
"# Assumes at the USDF\n",
"#visits_latiss_try = pd.read_sql(visit_query1, connection)\n",
"#quicklook_try = pd.read_sql(quicklook_query, connection)\n",
"\n",
"if len(visits_latiss) > 0:\n",
" print(f\"Retrieved {len(visits_latiss)} visits from consdb\")\n",
Expand Down Expand Up @@ -256,14 +252,17 @@
]
},
{
"cell_type": "markdown",
"cell_type": "code",
"execution_count": null,
"id": "15",
"metadata": {},
"outputs": [],
"source": [
"# Access DDV\n",
"Summit = https://summit-lsp.lsst.codes/rubintv-dev/ddv/index.html \n",
"\n",
"USDF = https://usdf-rsp-dev.slac.stanford.edu/rubintv/ddv/index.html"
"usdf = 'https://usdf-rsp-dev.slac.stanford.edu'\n",
"service_loc = os.environ.get('EXTERNAL_INSTANCE_URL', usdf)\n",
"DDV = f\"{service_loc}/rubintv-dev/ddv/index.html\"\n",
"display_markdown('## Access DDV part of RubinTV', raw=True)\n",
"DDV"
]
},
{
Expand Down
158 changes: 158 additions & 0 deletions notebooks_tsqr/consdb/assorted_plots.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
{
Vebop marked this conversation as resolved.
Show resolved Hide resolved
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "0",
"metadata": {},
"outputs": [],
"source": [
"# Parameters\n",
"day_obs = '2024-06-26'\n",
"instruments = 'latiss, lsstcomcamsim, lsstcomcam'"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import matplotlib.pyplot as plt\n",
"from IPython.display import display_markdown"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2",
"metadata": {},
"outputs": [],
"source": [
"### 'Get Consdb access'\n",
"from lsst.summit.utils import ConsDbClient\n",
"\n",
"URL = \"http://consdb-pq.consdb:8080/consdb\" # Don't use this one\n",
"os.environ[\"no_proxy\"] += \",.consdb\"\n",
"\n",
"client = ConsDbClient(URL)\n",
"display_markdown('### Consolidated Database is accessible',raw=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3",
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline # After all imports"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4",
"metadata": {},
"outputs": [],
"source": [
"# Put Plot in backend\n",
"plt.style.use('seaborn-v0_8-bright')\n",
"def plot(y, x):\n",
" # plot\n",
" fig = plt.figure(figsize=(6, 6))\n",
" ax = fig.subplots()\n",
" ax.scatter(x, y)\n",
"\n",
" plt.show()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5",
"metadata": {},
"outputs": [],
"source": [
"day_obs_int = int(day_obs.replace('-', ''))\n",
"instrument_list = [ins.strip() for ins in instruments.split(',')]\n",
"\n",
"for instrument in instrument_list:\n",
" print(\"------------------------------------------------------------\")\n",
" print()\n",
" display_markdown(f'# Instrument: {instrument}',raw=True)\n",
" #################### Put in Backend\n",
" ccdvisit1_quicklook = f'''\n",
" SELECT * FROM cdb_{instrument}.ccdvisit1_quicklook\n",
" '''\n",
"\n",
" visit1 = f'''\n",
" SELECT * FROM cdb_{instrument}.visit1\n",
" '''\n",
"\n",
" # Join Visit1 and ccdVisit1 to access data and day obs\n",
" visits = client.query(visit1).to_pandas()\n",
" quicklook = client.query(ccdvisit1_quicklook).to_pandas()\n",
"\n",
" visits = visits.join(quicklook, on='visit_id',lsuffix='',rsuffix='_q')\n",
" #################### Put in Backend - end\n",
"\n",
" # If we see data exist in psf, zero, then we should pare down like visits_today below\n",
" try:\n",
" visits_w_psf = visits[visits['psf_area'].notna()]\n",
" time = visits_w_psf['obs_start']\n",
" display_markdown(f'Number of visits with psf_area populated {len(visits_w_psf)}', raw=True)\n",
" display_markdown('## psf_area vs obs_start', raw=True)\n",
" plot(time, visits_w_psf['psf_area'])\n",
" except KeyError as err:\n",
" display_markdown(f\"Psf_area not a column in {instrument} dataframe\",raw=True)\n",
" display_markdown(f\"key error for {err}\", raw=True)\n",
"\n",
" try:\n",
" visits_w_zero = visits[visits['zero_point'].notna()]\n",
" time = visits_w_zero['obs_start']\n",
" display_markdown(f'Number of visits with zero_point populated {len(visits_w_zero)}', raw=True)\n",
" display_markdown('## zero_point vs obs_start', raw=True)\n",
" plot(time, visits_w_zero['zero_point'])\n",
" except KeyError as err:\n",
" display_markdown(f\"Zero_point not a column in {instrument} dataframe\", raw=True)\n",
" display_markdown(f\"key error for {err}\", raw=True)\n",
"\n",
" # Pare down to only day obs\n",
" visits_today = visits[(visits['day_obs'] == day_obs_int)]\n",
" display_markdown(f\"How many visits today? {len(visits_today)}\", raw=True)\n",
"\n",
" ra = visits_today['s_ra']\n",
" dec = visits_today['s_dec']\n",
" display_markdown(f\"How many ra? {len(ra)}\", raw=True)\n",
" display_markdown(f\"How many dec? {len(dec)}\", raw=True)\n",
"\n",
" display_markdown(f'Ra Dec should be populated for {instrument}', raw=True)\n",
" plot(ra, dec)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "LSST",
"language": "python",
"name": "lsst"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading