-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Capture MVP progress in Prototype (#29)
- Loading branch information
Showing
40 changed files
with
5,784 additions
and
1,186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,7 @@ | ||
name: Python CI | ||
name: lint | ||
|
||
env: | ||
PYTHON_VERSION: "3.12" # Default Python version | ||
|
||
"on": | ||
merge_group: {} | ||
pull_request: {} | ||
push: | ||
branches-ignore: | ||
# These should always correspond to pull requests, so ignore them for | ||
# the push trigger and let them be triggered by the pull_request | ||
# trigger, avoiding running the workflow twice. This is a minor | ||
# optimization so there's no need to ensure this is comprehensive. | ||
- "dependabot/**" | ||
- "renovate/**" | ||
- "tickets/**" | ||
- "u/**" | ||
on: push | ||
|
||
jobs: | ||
|
||
lint: | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: Run pre-commit | ||
uses: pre-commit/[email protected] | ||
call-workflow: | ||
uses: lsst-ts/tssw_workflows/.github/workflows/lint.yaml@main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
black: true | ||
clang-format: false | ||
flake8: true | ||
format-xmllint: false | ||
isort: true | ||
mypy: false | ||
check-yaml: true | ||
check-xml: true | ||
ruff: true | ||
towncrier: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,282 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "0", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Parameters.\n", | ||
"# Times Square replaces this cell with the user's parameters.\n", | ||
"# So, don't put anything else here!\n", | ||
"\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-25' # Value to use for local testing (usdf)\n", | ||
"day_obs = \"2024-11-20\" # TODO Change to 'YESTERDAY' to test with default before push\n", | ||
"instrument = \"LSSTComCam\" # LSSTComCam, LATISS, LSSTCam\n", | ||
"observation_reason = \"ALL\"\n", | ||
"observation_type = \"science\" # TODO: \"science\", \"acq\", default=\"ALL\"\n", | ||
"science_program = \"ALL\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "1", | ||
"metadata": { | ||
"jupyter": { | ||
"source_hidden": true | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# IMPORT everything\n", | ||
"import os\n", | ||
"import datetime as dt\n", | ||
"import pandas as pd\n", | ||
"from IPython.display import HTML, display\n", | ||
"\n", | ||
"# When running under Times Square, install pkg from github.\n", | ||
"# Otherwise use what is installed locally (intended to be dev editiable pkg)\n", | ||
"if os.environ.get(\"EXTERNAL_INSTANCE_URL\"):\n", | ||
" dev_msg = (\n", | ||
" 'Installing \"lsst.ts.logging_and_reporting\" from github using \"prototype\" branch. \\n'\n", | ||
" \"TODO: Make the need for this go away by getting Logging_and_Reporting installed in RSP.\"\n", | ||
" )\n", | ||
" !pip install --upgrade git+https://github.com/lsst-ts/ts_logging_and_reporting.git@prototype > /dev/null 2>&1\n", | ||
"else:\n", | ||
" dev_msg = \"Imported lsst.ts.logging_and_reporting from local packages.\"\n", | ||
"#! import lsst.ts.logging_and_reporting.source_adapters as sad\n", | ||
"import lsst.ts.logging_and_reporting.utils as ut\n", | ||
"from lsst.ts.logging_and_reporting.reports import md\n", | ||
"\n", | ||
"from lsst.ts.logging_and_reporting.all_sources import AllSources\n", | ||
"from lsst.ts.logging_and_reporting.all_reports import AllReports" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "2", | ||
"metadata": { | ||
"jupyter": { | ||
"source_hidden": true | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# Set default env to \"usdf\" and try before PUSH to repo.\n", | ||
"\n", | ||
"# The default provided here is for local testing.\n", | ||
"# Under Times Square it is ignored.\n", | ||
"server = os.environ.get(\n", | ||
" \"EXTERNAL_INSTANCE_URL\", ut.Server.usdf\n", | ||
") # TODO try with \"usdf\" before push (else \"summit\")\n", | ||
"\n", | ||
"# Normalize Parameters (both explicit Times Squares params and implicit ones)\n", | ||
"observation_reason = None if observation_reason == \"ALL\" else observation_reason\n", | ||
"observation_type = None if observation_type == \"ALL\" else observation_type\n", | ||
"science_program = None if science_program == \"ALL\" else science_program\n", | ||
"params = dict(\n", | ||
" day_obs=day_obs,\n", | ||
" instrument=instrument,\n", | ||
" observation_reason=observation_reason,\n", | ||
" observation_type=observation_type,\n", | ||
" science_program=science_program,\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "3", | ||
"metadata": { | ||
"jupyter": { | ||
"source_hidden": true | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# Normalize Parameters (both explicit Times Squares params, in implicit ones)\n", | ||
"date = ut.get_datetime_from_dayobs_str(day_obs)\n", | ||
"# date: is EXCLUSIVE (upto, but not including)\n", | ||
"days = 1\n", | ||
"\n", | ||
"# Thus: [min_day_obs,max_day_obs)\n", | ||
"# Format: string, YYYY-MM-DD\n", | ||
"min_date = date\n", | ||
"max_date = date + dt.timedelta(days=1)\n", | ||
"min_day_obs = min_date.strftime(\"%Y-%m-%d\") # Inclusive\n", | ||
"max_day_obs = max_date.strftime(\"%Y-%m-%d\") # prep for Exclusive" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "4", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Read records from (almost) all sources\n", | ||
"timer = ut.Timer()\n", | ||
"allsrc = AllSources(\n", | ||
" server_url=server,\n", | ||
" min_dayobs=min_day_obs,\n", | ||
" max_dayobs=max_day_obs,\n", | ||
" verbose=False, # TODO change to False before push\n", | ||
" warning=True, # TODO change to True before push\n", | ||
" limit=5000,\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "5", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# https://usdf-rsp-dev.slac.stanford.edu/consdb/query" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "6", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if observation_reason:\n", | ||
" md(f\"# Observation Reason: {observation_reason}\")\n", | ||
"if observation_type:\n", | ||
" md(f\"# Observation Type: {observation_type}\")\n", | ||
"if science_program:\n", | ||
" md(f\"# Science Program: {science_program}\")\n", | ||
"df = allsrc.exposure_detail(\n", | ||
" instrument=instrument,\n", | ||
" science_program=science_program,\n", | ||
" observation_reason=observation_reason,\n", | ||
" observation_type=observation_type,\n", | ||
")\n", | ||
"\n", | ||
"md(f\"The number of exposures in this filtered result is {len(df.index)}.\")\n", | ||
"md(\n", | ||
" f\"Exposures cover the day_obs range starting {allsrc.min_dayobs} and ending before {allsrc.max_dayobs}.\"\n", | ||
")\n", | ||
"display(HTML(df.to_html(index=False)))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "7", | ||
"metadata": {}, | ||
"source": [ | ||
"-----------------" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "8", | ||
"metadata": { | ||
"jp-MarkdownHeadingCollapsed": true | ||
}, | ||
"source": [ | ||
"# Developer Only Section" | ||
] | ||
}, | ||
{ | ||
"cell_type": "raw", | ||
"id": "9", | ||
"metadata": {}, | ||
"source": [ | ||
"| Symbol | Meaning |\n", | ||
"|:---|:---|\n", | ||
"| <font style=\"background-color:green; color:white; font-size:20px\"> G </font>| Good |\n", | ||
"| <font style=\"background-color:yellow; color:black; font-size:20px\"> ? </font> | Questionable |\n", | ||
"| <font style=\"background-color:red; color:black; font-size:20px\"> R </font> | Junk |" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "10", | ||
"metadata": { | ||
"jupyter": { | ||
"source_hidden": true | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"display(params)\n", | ||
"print(allsrc.exp_src)\n", | ||
"print(f\"{instrument=}, {science_program=}, {observation_reason=}, {observation_type=}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "11", | ||
"metadata": { | ||
"jupyter": { | ||
"source_hidden": true | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"print({k: len(v) for k, v in allsrc.exp_src.exposures.items()})" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "12", | ||
"metadata": { | ||
"jupyter": { | ||
"source_hidden": true | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"allsrc" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "13", | ||
"metadata": { | ||
"jupyter": { | ||
"source_hidden": true | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"print(f\"Elapsed time (excluding code import): {timer.toc:.1f} seconds\")\n", | ||
"print(f\"Finished {str(dt.datetime.now().replace(microsecond=0))} UTC\")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"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.10" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.